diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/class/syntax | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/class/syntax')
17 files changed, 359 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/syntax/browser.js b/js/src/tests/test262/language/statements/class/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/browser.js diff --git a/js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js b/js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js new file mode 100644 index 0000000000..4c8a3a1499 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js @@ -0,0 +1,25 @@ +// 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: > + The opposite of: + + 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 A {} +class B extends A { + constructor() { + super(); + } +} + + +assert.sameValue(typeof B, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js b/js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js new file mode 100644 index 0000000000..0d98925d67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js @@ -0,0 +1,25 @@ +// 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: > + No restrictions on SuperProperty +---*/ +class A { + constructor() { + super.toString(); + } + dontDoThis() { + super.makeBugs = 1; + } +} + + +assert.sameValue(typeof A, "function"); + +var a = new A(); + +a.dontDoThis(); +assert.sameValue(a.makeBugs, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js new file mode 100644 index 0000000000..bebea48ef1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js @@ -0,0 +1,37 @@ +// 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 +description: > + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + static MethodDefinition[?Yield] + ; + + +---*/ +class A { + method() {} + static method() {} + ; +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype.method, "function"); +assert.sameValue(typeof A.method, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js new file mode 100644 index 0000000000..01baa0e028 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js @@ -0,0 +1,32 @@ +// 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 +description: > + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + ... + +---*/ +class A { + [1]() {} +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype[1], "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js new file mode 100644 index 0000000000..1f209a0777 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js @@ -0,0 +1,32 @@ +// 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 +description: > + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + ... + +---*/ +class A { + *[1]() {} +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype[1], "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js new file mode 100644 index 0000000000..ddfca89cc9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js @@ -0,0 +1,56 @@ +// 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 +description: > + ClassHeritage[Yield] : + extends LeftHandSideExpression[?Yield] + + LeftHandSideExpression : + NewExpression + ... + + NewExpression : + MemberExpression + ... + + MemberExpression : + PrimaryExpression + ... + + PrimaryExpression : + IdentifierReference + ... + + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + static MethodDefinition[?Yield] + ; + +---*/ +class A {} +class B extends A { + method() {} + static method() {} + ; +} + +assert.sameValue(typeof B, "function"); +assert.sameValue(typeof B.prototype.method, "function"); +assert.sameValue(typeof B.method, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js b/js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js new file mode 100644 index 0000000000..a0822488c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js @@ -0,0 +1,41 @@ +// 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 +description: > + ClassExpression[Yield,GeneratorParameter] : + class BindingIdentifier[?Yield]opt ClassTail[?Yield,?GeneratorParameter] + + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + static MethodDefinition[?Yield] + ; + +---*/ +var A = class B { + method() {} + static method() {} + ; +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype.method, "function"); +assert.sameValue(typeof A.method, "function"); + +assert.sameValue(typeof B, "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js b/js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js new file mode 100644 index 0000000000..56c9faaa93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js @@ -0,0 +1,18 @@ +// 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 +description: > + ClassExpression[Yield,GeneratorParameter] : + class BindingIdentifier[?Yield]opt ClassTail[?Yield,?GeneratorParameter] + + ClassTail[Yield,GeneratorParameter] : + [~GeneratorParameter] ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } +---*/ +class A {} +var B = class extends A {} + +assert.sameValue(typeof B, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-expression.js b/js/src/tests/test262/language/statements/class/syntax/class-expression.js new file mode 100644 index 0000000000..eb3207be4d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-expression.js @@ -0,0 +1,12 @@ +// 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 +description: > + ClassExpression +---*/ +var A = class {} + +assert.sameValue(typeof A, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js b/js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js new file mode 100644 index 0000000000..36688dd52e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js @@ -0,0 +1,19 @@ +// 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: > + The opposite of: + + ClassBody : ClassElementList + + It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more than one occurrence of "constructor". +---*/ +class A { + constructor() {} +} + +assert.sameValue(typeof A, "function"); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/browser.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/early-errors/browser.js diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js new file mode 100644 index 0000000000..2217ee010e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1.1 +description: > + Block : { StatementList } + + It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains any duplicate entries. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +{ + class A {} + class A {} +} diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js new file mode 100644 index 0000000000..fa9fe2dbba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 15.1.1 +description: > + ScriptBody : StatementList + + It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains any duplicate entries. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class A {} +class A {} diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/shell.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/early-errors/shell.js diff --git a/js/src/tests/test262/language/statements/class/syntax/escaped-static.js b/js/src/tests/test262/language/statements/class/syntax/escaped-static.js new file mode 100644 index 0000000000..8c22111e0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/escaped-static.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `static` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + st\u0061tic m() {} +} diff --git a/js/src/tests/test262/language/statements/class/syntax/shell.js b/js/src/tests/test262/language/statements/class/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/shell.js |