Home | History | Annotate | Download | only in webkit
      1 Tests for ES6 class name semantics in class statements and expressions
      2 
      3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
      4 
      5 
      6 Class statement
      7 PASS A threw exception ReferenceError: A is not defined.
      8 PASS 'use strict'; A threw exception ReferenceError: A is not defined.
      9 PASS class {} threw exception SyntaxError: Unexpected token {.
     10 PASS 'use strict'; class {} threw exception SyntaxError: Unexpected token {.
     11 PASS class { constructor() {} } threw exception SyntaxError: Unexpected token {.
     12 PASS 'use strict'; class { constructor() {} } threw exception SyntaxError: Unexpected token {.
     13 PASS class A { constructor() {} } did not throw exception.
     14 PASS 'use strict'; class A { constructor() {} } did not throw exception.
     15 PASS class A { constructor() {} }; A.toString() is 'class A { constructor() {} }'
     16 PASS 'use strict'; class A { constructor() {} }; A.toString() is 'class A { constructor() {} }'
     17 PASS class A { constructor() {} }; (new A) instanceof A is true
     18 PASS 'use strict'; class A { constructor() {} }; (new A) instanceof A is true
     19 PASS class A { constructor() { this.base = A; } }; (new A).base.toString() is 'class A { constructor() { this.base = A; } }'
     20 PASS 'use strict'; class A { constructor() { this.base = A; } }; (new A).base.toString() is 'class A { constructor() { this.base = A; } }'
     21 PASS class A { constructor() {} }; class B extends A {}; did not throw exception.
     22 PASS 'use strict'; class A { constructor() {} }; class B extends A {}; did not throw exception.
     23 PASS class A { constructor() {} }; class B extends A { constructor() {} }; B.toString() is 'class B extends A { constructor() {} }'
     24 PASS 'use strict'; class A { constructor() {} }; class B extends A { constructor() {} }; B.toString() is 'class B extends A { constructor() {} }'
     25 PASS class A { constructor() {} }; class B extends A {}; (new B) instanceof A is true
     26 PASS 'use strict'; class A { constructor() {} }; class B extends A {}; (new B) instanceof A is true
     27 PASS class A { constructor() {} }; class B extends A {}; (new B) instanceof B is true
     28 PASS 'use strict'; class A { constructor() {} }; class B extends A {}; (new B) instanceof B is true
     29 PASS class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).base.toString() is 'class A { constructor() {} }'
     30 PASS 'use strict'; class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).base.toString() is 'class A { constructor() {} }'
     31 PASS class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }'
     32 PASS 'use strict'; class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }'
     33 
     34 Class expression
     35 PASS A threw exception ReferenceError: A is not defined.
     36 PASS 'use strict'; A threw exception ReferenceError: A is not defined.
     37 PASS (class {}) did not throw exception.
     38 PASS 'use strict'; (class {}) did not throw exception.
     39 PASS (class { constructor(){} }) did not throw exception.
     40 PASS 'use strict'; (class { constructor(){} }) did not throw exception.
     41 PASS typeof (class {}) is "function"
     42 PASS 'use strict'; typeof (class {}) is "function"
     43 PASS (class A {}) did not throw exception.
     44 PASS 'use strict'; (class A {}) did not throw exception.
     45 PASS typeof (class A {}) is "function"
     46 PASS 'use strict'; typeof (class A {}) is "function"
     47 PASS (class A {}); A threw exception ReferenceError: A is not defined.
     48 PASS 'use strict'; (class A {}); A threw exception ReferenceError: A is not defined.
     49 PASS new (class A {}) did not throw exception.
     50 PASS 'use strict'; new (class A {}) did not throw exception.
     51 PASS typeof (new (class A {})) is "object"
     52 PASS 'use strict'; typeof (new (class A {})) is "object"
     53 PASS (new (class A { constructor() { this.base = A; } })).base did not throw exception.
     54 PASS 'use strict'; (new (class A { constructor() { this.base = A; } })).base did not throw exception.
     55 PASS (new (class A { constructor() { this.base = A; } })).base.toString() is "class A { constructor() { this.base = A; } }"
     56 PASS 'use strict'; (new (class A { constructor() { this.base = A; } })).base.toString() is "class A { constructor() { this.base = A; } }"
     57 PASS class A {}; (class B extends A {}) did not throw exception.
     58 PASS 'use strict'; class A {}; (class B extends A {}) did not throw exception.
     59 PASS class A {}; (class B extends A {}); B threw exception ReferenceError: B is not defined.
     60 PASS 'use strict'; class A {}; (class B extends A {}); B threw exception ReferenceError: B is not defined.
     61 PASS class A {}; new (class B extends A {}) did not throw exception.
     62 PASS 'use strict'; class A {}; new (class B extends A {}) did not throw exception.
     63 PASS class A {}; new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } }) did not throw exception.
     64 PASS 'use strict'; class A {}; new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } }) did not throw exception.
     65 PASS class A {}; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })) instanceof A is true
     66 PASS 'use strict'; class A {}; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })) instanceof A is true
     67 PASS class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).base.toString() is 'class A { constructor() {} }'
     68 PASS 'use strict'; class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).base.toString() is 'class A { constructor() {} }'
     69 PASS class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }'
     70 PASS 'use strict'; class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }'
     71 
     72 Class expression assignment to variable
     73 PASS A threw exception ReferenceError: A is not defined.
     74 PASS 'use strict'; A threw exception ReferenceError: A is not defined.
     75 PASS var VarA = class {} did not throw exception.
     76 PASS 'use strict'; var VarA = class {} did not throw exception.
     77 PASS var VarA = class { constructor() {} }; VarA.toString() is 'class { constructor() {} }'
     78 PASS 'use strict'; var VarA = class { constructor() {} }; VarA.toString() is 'class { constructor() {} }'
     79 PASS VarA threw exception ReferenceError: VarA is not defined.
     80 PASS 'use strict'; VarA threw exception ReferenceError: VarA is not defined.
     81 PASS var VarA = class A { constructor() {} } did not throw exception.
     82 PASS 'use strict'; var VarA = class A { constructor() {} } did not throw exception.
     83 PASS var VarA = class A { constructor() {} }; VarA.toString() is 'class A { constructor() {} }'
     84 PASS 'use strict'; var VarA = class A { constructor() {} }; VarA.toString() is 'class A { constructor() {} }'
     85 PASS var VarA = class A { constructor() {} }; A.toString() threw exception ReferenceError: A is not defined.
     86 PASS 'use strict'; var VarA = class A { constructor() {} }; A.toString() threw exception ReferenceError: A is not defined.
     87 PASS var VarA = class A { constructor() {} }; (new VarA) instanceof VarA is true
     88 PASS 'use strict'; var VarA = class A { constructor() {} }; (new VarA) instanceof VarA is true
     89 PASS var VarA = class A { constructor() { this.base = A; } }; (new VarA).base.toString() is 'class A { constructor() { this.base = A; } }'
     90 PASS 'use strict'; var VarA = class A { constructor() { this.base = A; } }; (new VarA).base.toString() is 'class A { constructor() { this.base = A; } }'
     91 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; did not throw exception.
     92 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; did not throw exception.
     93 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; B threw exception ReferenceError: B is not defined.
     94 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; B threw exception ReferenceError: B is not defined.
     95 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; VarB.toString() is 'class B extends VarA { constructor() {} }'
     96 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; VarB.toString() is 'class B extends VarA { constructor() {} }'
     97 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarA is true
     98 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarA is true
     99 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarB is true
    100 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarB is true
    101 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).base === VarA is true
    102 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).base === VarA is true
    103 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derived === VarB is true
    104 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derived === VarB is true
    105 PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derivedVar === VarB is true
    106 PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derivedVar === VarB is true
    107 
    108 Class statement binding in other circumstances
    109 PASS var result = A; result threw exception ReferenceError: A is not defined.
    110 PASS 'use strict'; var result = A; result threw exception ReferenceError: A is not defined.
    111 PASS var result = A; class A {}; result threw exception ReferenceError: A is not defined.
    112 PASS 'use strict'; var result = A; class A {}; result threw exception ReferenceError: A is not defined.
    113 PASS class A { constructor() { A = 1; } }; new A threw exception TypeError: Assignment to constant variable..
    114 PASS 'use strict'; class A { constructor() { A = 1; } }; new A threw exception TypeError: Assignment to constant variable..
    115 PASS class A { constructor() { } }; A = 1; A is 1
    116 PASS 'use strict'; class A { constructor() { } }; A = 1; A is 1
    117 PASS class A {}; var result = A; result did not throw exception.
    118 PASS 'use strict'; class A {}; var result = A; result did not throw exception.
    119 PASS eval('var Foo = 10'); Foo is 10
    120 PASS 'use strict'; eval('var Foo = 10'); Foo threw exception ReferenceError: Foo is not defined.
    121 PASS eval('class Bar { constructor() {} }; Bar.toString()') is 'class Bar { constructor() {} }'
    122 PASS 'use strict'; eval('class Bar { constructor() {} }'); Bar.toString() threw exception ReferenceError: Bar is not defined.
    123 PASS successfullyParsed is true
    124 
    125 TEST COMPLETE
    126