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/labeled | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/labeled')
26 files changed, 494 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/labeled/S12.12_A1_T1.js b/js/src/tests/test262/language/statements/labeled/S12.12_A1_T1.js new file mode 100644 index 0000000000..009339fa1b --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/S12.12_A1_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Labelled statements are only used in conjunction with labelled + break and continue statements +es5id: 12.12_A1_T1 +description: Checking if labelled break works. See continue and break sections +---*/ + +var object = {p1: 1, p2: 1}; +var result = 0; +lbl: for(var i in object){ + result += object[i]; + break lbl; +} + +if(!(result === 1)){ + throw new Test262Error("'break label' should break execution of labelled iteration statement"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/browser.js b/js/src/tests/test262/language/statements/labeled/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/browser.js diff --git a/js/src/tests/test262/language/statements/labeled/continue.js b/js/src/tests/test262/language/statements/labeled/continue.js new file mode 100644 index 0000000000..7eaae138b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/continue.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-labelled-statements-static-semantics-containsundefinedcontinuetarget +es6id: 13.13.4 +description: Does not modify `iterationSet` +info: | + With arguments iterationSet and labelSet. + + LabelledStatement : LabelIdentifier : LabelledItem + + 1. Let label be the StringValue of LabelIdentifier. + 2. Let newLabelSet be a copy of labelSet with label appended. + 3. Return ContainsUndefinedContinueTarget of LabelledItem with arguments + iterationSet and newLabelSet. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +do { + test262: { + continue test262; + } +} while (false) diff --git a/js/src/tests/test262/language/statements/labeled/cptn-break.js b/js/src/tests/test262/language/statements/labeled/cptn-break.js new file mode 100644 index 0000000000..5e374af5d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/cptn-break.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-labelled-statements-runtime-semantics-labelledevaluation +es6id: 13.13.14 +description: Completion value when LabelledItem returns a "break" completion +info: | + LabelledStatement : LabelIdentifier : LabelledItem + + 1. Let label be the StringValue of LabelIdentifier. + 2. Append label as an element of labelSet. + 3. Let stmtResult be LabelledEvaluation of LabelledItem with argument + labelSet. + 4. If stmtResult.[[Type]] is break and SameValue(stmtResult.[[Target]], + label) is true, then + a. Let stmtResult be NormalCompletion(stmtResult.[[Value]]). +---*/ + +assert.sameValue(eval('test262id: { 5; break test262id; 9; }'), 5); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/cptn-nrml.js b/js/src/tests/test262/language/statements/labeled/cptn-nrml.js new file mode 100644 index 0000000000..ad04ba0ba7 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/cptn-nrml.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-labelled-statements-runtime-semantics-labelledevaluation +es6id: 13.13.14 +description: Completion value when LabelledItem returns normally +info: | + LabelledStatement : LabelIdentifier : LabelledItem + + 1. Let label be the StringValue of LabelIdentifier. + 2. Append label as an element of labelSet. + 3. Let stmtResult be LabelledEvaluation of LabelledItem with argument + labelSet. + 4. If stmtResult.[[Type]] is break and SameValue(stmtResult.[[Target]], + label) is true, then + [...] + 5. Return Completion(stmtResult). +---*/ + +assert.sameValue(eval('test262id: 2;'), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/decl-async-function.js b/js/src/tests/test262/language/statements/labeled/decl-async-function.js new file mode 100644 index 0000000000..63b8e17016 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-async-function.js @@ -0,0 +1,21 @@ +// |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-labelled-statements +description: > + AsyncFunctionDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +label: async function f() {} diff --git a/js/src/tests/test262/language/statements/labeled/decl-async-generator.js b/js/src/tests/test262/language/statements/labeled/decl-async-generator.js new file mode 100644 index 0000000000..c11f582bb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-async-generator.js @@ -0,0 +1,21 @@ +// |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-labelled-statements +description: > + AsyncGeneratorDeclaration is not allowed in statement position +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +label: async function* g() {} diff --git a/js/src/tests/test262/language/statements/labeled/decl-cls.js b/js/src/tests/test262/language/statements/labeled/decl-cls.js new file mode 100644 index 0000000000..1dd24bd805 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-cls.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Class declaration not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +label: class C {} diff --git a/js/src/tests/test262/language/statements/labeled/decl-const.js b/js/src/tests/test262/language/statements/labeled/decl-const.js new file mode 100644 index 0000000000..903bbfe85e --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-const.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (const) not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +label: const x = null; diff --git a/js/src/tests/test262/language/statements/labeled/decl-fun-strict-strict.js b/js/src/tests/test262/language/statements/labeled/decl-fun-strict-strict.js new file mode 100644 index 0000000000..75ad6bc614 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-fun-strict-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-labelled-statements +es6id: 13.13 +description: > + function declarations in statement position in strict mode: + label: Statement +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +label: function g() {} diff --git a/js/src/tests/test262/language/statements/labeled/decl-gen.js b/js/src/tests/test262/language/statements/labeled/decl-gen.js new file mode 100644 index 0000000000..7811b09f31 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-gen.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Generator declaration not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: + phase: parse + type: SyntaxError +features: [generators] +---*/ + +$DONOTEVALUATE(); + +label: function* g() {} diff --git a/js/src/tests/test262/language/statements/labeled/decl-let.js b/js/src/tests/test262/language/statements/labeled/decl-let.js new file mode 100644 index 0000000000..758f884dbb --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/decl-let.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Lexical declaration (let) not allowed in statement position +esid: sec-labelled-statements +es6id: 13.13 +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +label: let x; diff --git a/js/src/tests/test262/language/statements/labeled/let-array-with-newline.js b/js/src/tests/test262/language/statements/labeled/let-array-with-newline.js new file mode 100644 index 0000000000..daa158c099 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/let-array-with-newline.js @@ -0,0 +1,25 @@ +// |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-labelled-statements +description: > + ExpressionStatement has a lookahead restriction for `let [`. +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +negative: + phase: parse + type: SyntaxError +flags: [noStrict] +---*/ + +$DONOTEVALUATE(); + +// Wrapped in an if-statement to avoid reference errors at runtime. +if (false) { + L: let + [a] = 0; +} diff --git a/js/src/tests/test262/language/statements/labeled/let-block-with-newline.js b/js/src/tests/test262/language/statements/labeled/let-block-with-newline.js new file mode 100644 index 0000000000..5ecd38824b --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/let-block-with-newline.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-labelled-statements +description: > + ExpressionStatement doesn't have a lookahead restriction for `let {`. +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +flags: [noStrict] +---*/ + +// Wrapped in an if-statement to avoid reference errors at runtime. +if (false) { + L: let // ASI + {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/let-identifier-with-newline.js b/js/src/tests/test262/language/statements/labeled/let-identifier-with-newline.js new file mode 100644 index 0000000000..97911aed22 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/let-identifier-with-newline.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-labelled-statements +description: > + ExpressionStatement doesn't have a lookahead restriction for `let <binding-identifier>`. +info: | + ExpressionStatement[Yield, Await] : + [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] + Expression[+In, ?Yield, ?Await] ; +flags: [noStrict] +---*/ + +// Wrapped in an if-statement to avoid reference errors at runtime. +if (false) { + L: let // ASI + x = 1; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/shell.js b/js/src/tests/test262/language/statements/labeled/shell.js new file mode 100644 index 0000000000..43295587f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/shell.js @@ -0,0 +1,16 @@ +// GENERATED, DO NOT EDIT +// file: tcoHelper.js +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +defines: [$MAX_ITERATIONS] +---*/ + + + + +var $MAX_ITERATIONS = 100000; diff --git a/js/src/tests/test262/language/statements/labeled/static-init-invalid-await.js b/js/src/tests/test262/language/statements/labeled/static-init-invalid-await.js new file mode 100644 index 0000000000..ac8268847a --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/static-init-invalid-await.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Restriction on `await` +info: | + LabelIdentifier : Identifier + + - It is a Syntax Error if the code matched by this production is nested, + directly or indirectly (but not crossing function or static initialization + block boundaries), within a ClassStaticBlock and the StringValue of + Identifier is "await". +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + await: 0; + } +} diff --git a/js/src/tests/test262/language/statements/labeled/tco-strict.js b/js/src/tests/test262/language/statements/labeled/tco-strict.js new file mode 100644 index 0000000000..b0889704a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/tco-strict.js @@ -0,0 +1,23 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Statement within statement is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + test262: return f(n - 1); +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/value-await-module-escaped.js b/js/src/tests/test262/language/statements/labeled/value-await-module-escaped.js new file mode 100644 index 0000000000..16c0f9cf1c --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-await-module-escaped.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError module +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is a reserved identifier in module code and may not be used as a label. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module and + the StringValue of IdentifierName is "await". +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +$DONOTEVALUATE(); + +aw\u0061it: 1; diff --git a/js/src/tests/test262/language/statements/labeled/value-await-module.js b/js/src/tests/test262/language/statements/labeled/value-await-module.js new file mode 100644 index 0000000000..7284a29126 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-await-module.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError module +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is a reserved identifier in module code and may not be used as a label. +info: | + LabelIdentifier : await + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +$DONOTEVALUATE(); + +await: 1; diff --git a/js/src/tests/test262/language/statements/labeled/value-await-non-module-escaped.js b/js/src/tests/test262/language/statements/labeled/value-await-non-module-escaped.js new file mode 100644 index 0000000000..4a8b7441bb --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-await-non-module-escaped.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is not a reserved identifier in non-module code and may be used as a label. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module and + the StringValue of IdentifierName is "await". +---*/ + +aw\u0061it: 1; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/value-await-non-module.js b/js/src/tests/test262/language/statements/labeled/value-await-non-module.js new file mode 100644 index 0000000000..4e6237d457 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-await-non-module.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `await` is not a reserved identifier in non-module code and may be used as a label. +info: | + LabelIdentifier : await + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +---*/ + +await: 1; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/value-yield-non-strict-escaped.js b/js/src/tests/test262/language/statements/labeled/value-yield-non-strict-escaped.js new file mode 100644 index 0000000000..4503bf2daf --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-yield-non-strict-escaped.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `yield` is not a reserved identifier in non-strict mode code and may be used as a label. +flags: [noStrict] +---*/ + +yi\u0065ld: 1; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/value-yield-non-strict.js b/js/src/tests/test262/language/statements/labeled/value-yield-non-strict.js new file mode 100644 index 0000000000..d9dce33d84 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-yield-non-strict.js @@ -0,0 +1,14 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is not a reserved identifier in non-strict mode code and may be + used as a label. + es6id: 12.1.1 + flags: [noStrict] +---*/ + +yield: 1; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/labeled/value-yield-strict-escaped-strict.js b/js/src/tests/test262/language/statements/labeled/value-yield-strict-escaped-strict.js new file mode 100644 index 0000000000..1b472202cf --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-yield-strict-escaped-strict.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `yield` is a reserved identifier in strict mode code and may not be used as a label. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if this phrase is contained in strict mode code and the + StringValue of IdentifierName is: "implements", "interface", "let", "package", + "private", "protected", "public", "static", or "yield". +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +yi\u0065ld: 1; diff --git a/js/src/tests/test262/language/statements/labeled/value-yield-strict-strict.js b/js/src/tests/test262/language/statements/labeled/value-yield-strict-strict.js new file mode 100644 index 0000000000..539a1ff351 --- /dev/null +++ b/js/src/tests/test262/language/statements/labeled/value-yield-strict-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved identifier in strict mode code and may not be used + as a label. + es6id: 12.1.1 + negative: + phase: parse + type: SyntaxError + flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +yield: 1; |