diff --git a/test/language/expressions/class/syntax/early-errors/grammar-class-body-ctor-duplicate.js b/test/language/expressions/class/syntax/early-errors/grammar-class-body-ctor-duplicate.js new file mode 100644 index 0000000000..43078fc942 --- /dev/null +++ b/test/language/expressions/class/syntax/early-errors/grammar-class-body-ctor-duplicate.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-class-body-ctor-duplicate.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It is a SyntaxError if the class body has more than one constructor (class expression) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassBody : ClassElementList + It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more + than one occurrence of "constructor". + +---*/ + + +throw "Test262: This statement should not be evaluated."; + +var C = class { + constructor() {} + constructor() {} +}; diff --git a/test/language/expressions/class/syntax/early-errors/grammar-ctor-super-no-heritage.js b/test/language/expressions/class/syntax/early-errors/grammar-ctor-super-no-heritage.js new file mode 100644 index 0000000000..7face8374c --- /dev/null +++ b/test/language/expressions/class/syntax/early-errors/grammar-ctor-super-no-heritage.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-ctor-super-no-heritage.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It is a SyntaxError if class has no heritage and constructor has a direct super (class expression) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. + +---*/ + + +throw "Test262: This statement should not be evaluated."; + +var C = class { + constructor() { + super(); + } +}; diff --git a/test/language/expressions/class/syntax/valid/grammar-class-body-ctor-no-heritage.js b/test/language/expressions/class/syntax/valid/grammar-class-body-ctor-no-heritage.js new file mode 100644 index 0000000000..80e339b017 --- /dev/null +++ b/test/language/expressions/class/syntax/valid/grammar-class-body-ctor-no-heritage.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-class-body-ctor-no-heritage.case +// - src/class-elements/syntax/valid/cls-expr-elements-valid-syntax.template +/*--- +description: A constructor is valid without a super call in the constructor and heritage (class expression) +esid: prod-ClassElement +features: [class] +flags: [generated] +info: | + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. + +---*/ + + +var C = class { + constructor() {} +}; diff --git a/test/language/statements/class/syntax/early-errors/grammar-class-body-ctor-duplicate.js b/test/language/statements/class/syntax/early-errors/grammar-class-body-ctor-duplicate.js new file mode 100644 index 0000000000..f57cd6265d --- /dev/null +++ b/test/language/statements/class/syntax/early-errors/grammar-class-body-ctor-duplicate.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-class-body-ctor-duplicate.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It is a SyntaxError if the class body has more than one constructor (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassBody : ClassElementList + It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more + than one occurrence of "constructor". + +---*/ + + +throw "Test262: This statement should not be evaluated."; + +class C { + constructor() {} + constructor() {} +} diff --git a/test/language/statements/class/syntax/early-errors/grammar-ctor-super-no-heritage.js b/test/language/statements/class/syntax/early-errors/grammar-ctor-super-no-heritage.js new file mode 100644 index 0000000000..c200b9031f --- /dev/null +++ b/test/language/statements/class/syntax/early-errors/grammar-ctor-super-no-heritage.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-ctor-super-no-heritage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It is a SyntaxError if class has no heritage and constructor has a direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. + +---*/ + + +throw "Test262: This statement should not be evaluated."; + +class C { + constructor() { + super(); + } +} diff --git a/test/language/statements/class/syntax/valid/grammar-class-body-ctor-no-heritage.js b/test/language/statements/class/syntax/valid/grammar-class-body-ctor-no-heritage.js new file mode 100644 index 0000000000..105f343beb --- /dev/null +++ b/test/language/statements/class/syntax/valid/grammar-class-body-ctor-no-heritage.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-class-body-ctor-no-heritage.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: A constructor is valid without a super call in the constructor and heritage (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +info: | + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. + +---*/ + + +class C { + constructor() {} +}