Home | History | Annotate | Download | only in es6
      1 // Copyright 2015 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 
      6 (function Method() {
      7   class C {
      8     eval() {
      9       return 1;
     10     }
     11     arguments() {
     12       return 2;
     13     }
     14     static eval() {
     15       return 3;
     16     }
     17     static arguments() {
     18       return 4;
     19     }
     20   };
     21 
     22   assertEquals(1, new C().eval());
     23   assertEquals(2, new C().arguments());
     24   assertEquals(3, C.eval());
     25   assertEquals(4, C.arguments());
     26 })();
     27 
     28 
     29 (function Getters() {
     30   class C {
     31     get eval() {
     32       return 1;
     33     }
     34     get arguments() {
     35       return 2;
     36     }
     37     static get eval() {
     38       return 3;
     39     }
     40     static get arguments() {
     41       return 4;
     42     }
     43   };
     44 
     45   assertEquals(1, new C().eval);
     46   assertEquals(2, new C().arguments);
     47   assertEquals(3, C.eval);
     48   assertEquals(4, C.arguments);
     49 })();
     50 
     51 
     52 (function Setters() {
     53   var x = 0;
     54   class C {
     55     set eval(v) {
     56       x = v;
     57     }
     58     set arguments(v) {
     59       x = v;
     60     }
     61     static set eval(v) {
     62       x = v;
     63     }
     64     static set arguments(v) {
     65       x = v;
     66     }
     67   };
     68 
     69   new C().eval = 1;
     70   assertEquals(1, x);
     71   new C().arguments = 2;
     72   assertEquals(2, x);
     73   C.eval = 3;
     74   assertEquals(3, x);
     75   C.arguments = 4;
     76   assertEquals(4, x);
     77 })();
     78