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 // Flags: --harmony-sloppy
      6 
      7 
      8 (function Method() {
      9   class C {
     10     eval() {
     11       return 1;
     12     }
     13     arguments() {
     14       return 2;
     15     }
     16     static eval() {
     17       return 3;
     18     }
     19     static arguments() {
     20       return 4;
     21     }
     22   };
     23 
     24   assertEquals(1, new C().eval());
     25   assertEquals(2, new C().arguments());
     26   assertEquals(3, C.eval());
     27   assertEquals(4, C.arguments());
     28 })();
     29 
     30 
     31 (function Getters() {
     32   class C {
     33     get eval() {
     34       return 1;
     35     }
     36     get arguments() {
     37       return 2;
     38     }
     39     static get eval() {
     40       return 3;
     41     }
     42     static get arguments() {
     43       return 4;
     44     }
     45   };
     46 
     47   assertEquals(1, new C().eval);
     48   assertEquals(2, new C().arguments);
     49   assertEquals(3, C.eval);
     50   assertEquals(4, C.arguments);
     51 })();
     52 
     53 
     54 (function Setters() {
     55   var x = 0;
     56   class C {
     57     set eval(v) {
     58       x = v;
     59     }
     60     set arguments(v) {
     61       x = v;
     62     }
     63     static set eval(v) {
     64       x = v;
     65     }
     66     static set arguments(v) {
     67       x = v;
     68     }
     69   };
     70 
     71   new C().eval = 1;
     72   assertEquals(1, x);
     73   new C().arguments = 2;
     74   assertEquals(2, x);
     75   C.eval = 3;
     76   assertEquals(3, x);
     77   C.arguments = 4;
     78   assertEquals(4, x);
     79 })();
     80