From 8524805f2535f4dda53055f09eca7be30c5477c1 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Wed, 5 Sep 2018 17:57:16 -0400 Subject: [PATCH] Final cases to move to tests generation --- .../grammar-class-body-ctor-duplicate.case | 16 ++++++++++++++ .../grammar-class-body-ctor-no-heritage.case | 14 +++++++----- .../grammar-ctor-super-no-heritage.case | 22 ++++++++----------- ...lass-body-contains-multiple-constructor.js | 20 ----------------- 4 files changed, 33 insertions(+), 39 deletions(-) create mode 100644 src/class-elements/grammar-class-body-ctor-duplicate.case rename test/language/statements/class/syntax/early-errors/class-body-constructor-empty-missing-class-heritage.js => src/class-elements/grammar-class-body-ctor-no-heritage.case (64%) rename test/language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js => src/class-elements/grammar-ctor-super-no-heritage.case (62%) delete mode 100644 test/language/statements/class/syntax/early-errors/class-body-contains-multiple-constructor.js diff --git a/src/class-elements/grammar-class-body-ctor-duplicate.case b/src/class-elements/grammar-class-body-ctor-duplicate.case new file mode 100644 index 0000000000..fccb13ab07 --- /dev/null +++ b/src/class-elements/grammar-class-body-ctor-duplicate.case @@ -0,0 +1,16 @@ +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: > + It is a SyntaxError if the class body has more than one constructor +info: | + ClassBody : ClassElementList + It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more + than one occurrence of "constructor". +template: syntax/invalid +---*/ + +//- elements +constructor() {} +constructor() {} diff --git a/test/language/statements/class/syntax/early-errors/class-body-constructor-empty-missing-class-heritage.js b/src/class-elements/grammar-class-body-ctor-no-heritage.case similarity index 64% rename from test/language/statements/class/syntax/early-errors/class-body-constructor-empty-missing-class-heritage.js rename to src/class-elements/grammar-class-body-ctor-no-heritage.case index 660792327f..f423419b61 100644 --- a/test/language/statements/class/syntax/early-errors/class-body-constructor-empty-missing-class-heritage.js +++ b/src/class-elements/grammar-class-body-ctor-no-heritage.case @@ -1,16 +1,18 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. + /*--- -es6id: 14.5.1 -description: > +desc: > + A constructor is valid without a super call in the constructor and heritage +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. +template: syntax/valid ---*/ -class A { - constructor() {} -} +//- elements +constructor() {} diff --git a/test/language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js b/src/class-elements/grammar-ctor-super-no-heritage.case similarity index 62% rename from test/language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js rename to src/class-elements/grammar-ctor-super-no-heritage.case index 38f37dd246..4c389afae1 100644 --- a/test/language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js +++ b/src/class-elements/grammar-ctor-super-no-heritage.case @@ -1,24 +1,20 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. + /*--- -es6id: 14.5.1 -description: > +desc: > + It is a SyntaxError if class has no heritage and constructor has a direct super +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. - -negative: - phase: parse - type: SyntaxError +template: syntax/invalid ---*/ -throw "Test262: This statement should not be evaluated."; -class A { - constructor() { - super(); - } +//- elements +constructor() { + super(); } - diff --git a/test/language/statements/class/syntax/early-errors/class-body-contains-multiple-constructor.js b/test/language/statements/class/syntax/early-errors/class-body-contains-multiple-constructor.js deleted file mode 100644 index ab5db8969c..0000000000 --- a/test/language/statements/class/syntax/early-errors/class-body-contains-multiple-constructor.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.5.1 -description: > - ClassBody : ClassElementList - - It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more than one occurrence of "constructor". - -negative: - phase: parse - type: SyntaxError ----*/ - -throw "Test262: This statement should not be evaluated."; -class A { - constructor() {} - constructor() {} -} -