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/annexB/language/statements | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/annexB/language/statements')
48 files changed, 632 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/statements/browser.js b/js/src/tests/test262/annexB/language/statements/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/class/browser.js b/js/src/tests/test262/annexB/language/statements/class/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/class/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/class/shell.js b/js/src/tests/test262/annexB/language/statements/class/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/class/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/class/subclass/browser.js b/js/src/tests/test262/annexB/language/statements/class/subclass/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/class/subclass/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/class/subclass/shell.js b/js/src/tests/test262/annexB/language/statements/class/subclass/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/class/subclass/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/class/subclass/superclass-emulates-undefined.js b/js/src/tests/test262/annexB/language/statements/class/subclass/superclass-emulates-undefined.js new file mode 100644 index 0000000000..245e7d402b --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/class/subclass/superclass-emulates-undefined.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + [[IsHTMLDDA]] object as superclass: `null` check uses strict equality. + IsConstructor check is performed before "prototype" lookup. +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + d. Let superclass be ? GetValue(superclassRef). + e. If superclass is null, then + [...] + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. +features: [class, IsHTMLDDA] +---*/ + +var superclass = $262.IsHTMLDDA; +var prototypeGets = 0; +Object.defineProperty(superclass, "prototype", { + get: function() { + prototypeGets += 1; + }, +}); + +assert.throws(TypeError, function() { + class C extends superclass {} +}); + +assert.sameValue(prototypeGets, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/class/subclass/superclass-prototype-emulates-undefined.js b/js/src/tests/test262/annexB/language/statements/class/subclass/superclass-prototype-emulates-undefined.js new file mode 100644 index 0000000000..542dbb0756 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/class/subclass/superclass-prototype-emulates-undefined.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + [[IsHTMLDDA]] object as "prototype" of superclass: `null` check uses strict equality. +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + g. Else, + i. Let protoParent be ? Get(superclass, "prototype"). + ii. If Type(protoParent) is neither Object nor Null, throw a TypeError exception. + iii. Let constructorParent be superclass. + 6. Let proto be OrdinaryObjectCreate(protoParent). + [...] +features: [class, IsHTMLDDA] +---*/ + +function Superclass() {} +Superclass.prototype = $262.IsHTMLDDA; + +class C extends Superclass {} +var c = new C(); + +assert(c instanceof C); +assert(c instanceof Superclass); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/const/browser.js b/js/src/tests/test262/annexB/language/statements/const/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/const/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/const/dstr/array-pattern-emulates-undefined.js b/js/src/tests/test262/annexB/language/statements/const/dstr/array-pattern-emulates-undefined.js new file mode 100644 index 0000000000..ebc12e7a3a --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/const/dstr/array-pattern-emulates-undefined.js @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization +description: > + Destructuring initializer is not evaluated when value is an object + with [[IsHTMLDDA]] internal slot. +info: | + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + 2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments + iteratorRecord and environment. + 3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result). + 4. Return result. + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer[opt] + + [...] + 5. If Initializer is present and v is undefined, then + [...] + 6. If environment is undefined, return ? PutValue(lhs, v). +features: [destructuring-binding, IsHTMLDDA] +---*/ + +let initCount = 0; +const counter = function() { + initCount += 1; +}; + +const IsHTMLDDA = $262.IsHTMLDDA; +const [x = counter()] = [IsHTMLDDA]; + +assert.sameValue(x, IsHTMLDDA); +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/const/dstr/browser.js b/js/src/tests/test262/annexB/language/statements/const/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/const/dstr/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/const/dstr/object-pattern-emulates-undefined.js b/js/src/tests/test262/annexB/language/statements/const/dstr/object-pattern-emulates-undefined.js new file mode 100644 index 0000000000..5db5558567 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/const/dstr/object-pattern-emulates-undefined.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization +description: > + Destructuring initializer is not evaluated when value is an object + with [[IsHTMLDDA]] internal slot. +info: | + BindingPattern : ObjectBindingPattern + + 1. Perform ? RequireObjectCoercible(value). + 2. Return the result of performing BindingInitialization for + ObjectBindingPattern using value and environment as arguments. + + Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer[opt] + + [...] + 4. If Initializer is present and v is undefined, then + [...] + 5. If environment is undefined, return ? PutValue(lhs, v). +features: [destructuring-binding, IsHTMLDDA] +---*/ + +let initCount = 0; +const counter = function() { + initCount += 1; +}; + +const IsHTMLDDA = $262.IsHTMLDDA; +const {x = counter()} = {x: IsHTMLDDA}; + +assert.sameValue(x, IsHTMLDDA); +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/const/dstr/shell.js b/js/src/tests/test262/annexB/language/statements/const/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/const/dstr/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/const/shell.js b/js/src/tests/test262/annexB/language/statements/const/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/const/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/for-await-of/browser.js b/js/src/tests/test262/annexB/language/statements/for-await-of/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-await-of/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js b/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js new file mode 100644 index 0000000000..21860d325e --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-await-of/iterator-close-return-emulates-undefined-throws-when-called.js @@ -0,0 +1,40 @@ +// |reftest| async +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-getiterator +description: > + `GetIterator(obj, ~async~)` must attempt to call `obj[@@asyncIterator]` when + that value is an object with an [[IsHTMLDDA]] internal slot, not act as if + the value were `undefined`. +features: [async-iteration, IsHTMLDDA] +flags: [async] +---*/ + +async function f() { + var IsHTMLDDA = $262.IsHTMLDDA; + var iter = { + [Symbol.asyncIterator]: IsHTMLDDA, + get [Symbol.iterator]() { + throw new Test262Error("shouldn't touch Symbol.iterator"); + }, + }; + + // `IsHTMLDDA` is called here with `iter` as `this` and no arguments, and it's + // expected to return `null` under these conditions. Then the iteration + // protocol throws a `TypeError` because `null` isn't an object. + for await (var x of iter) + return "for-await-of body shouldn't be reached"; + + return "should have failed earlier"; +} + +f().then($DONE, + function (e) { + assert.sameValue(e.constructor, TypeError, + "expected TypeError because " + + "`iter[Symbol.asyncIterator]() returned a " + + "non-object: " + e); + }) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/annexB/language/statements/for-await-of/shell.js b/js/src/tests/test262/annexB/language/statements/for-await-of/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-await-of/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/for-in/bare-initializer.js b/js/src/tests/test262/annexB/language/statements/for-in/bare-initializer.js new file mode 100644 index 0000000000..6c9ecce1ea --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/bare-initializer.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. +/*--- +esid: sec-initializers-in-forin-statement-heads +description: > + for-in heads prohibit AssignmentExpressions +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +var a; + +for (a = 0 in {}); diff --git a/js/src/tests/test262/annexB/language/statements/for-in/browser.js b/js/src/tests/test262/annexB/language/statements/for-in/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/for-in/const-initializer.js b/js/src/tests/test262/annexB/language/statements/for-in/const-initializer.js new file mode 100644 index 0000000000..940a14be19 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/const-initializer.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. +/*--- +esid: sec-initializers-in-forin-statement-heads +description: > + for-in initializers with const are prohibited +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +for (const a = 0 in {}); + diff --git a/js/src/tests/test262/annexB/language/statements/for-in/let-initializer.js b/js/src/tests/test262/annexB/language/statements/for-in/let-initializer.js new file mode 100644 index 0000000000..ff14bf6542 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/let-initializer.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. +/*--- +esid: sec-initializers-in-forin-statement-heads +description: > + for-in initializers with let are prohibited +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +for (let a = 0 in {}); + diff --git a/js/src/tests/test262/annexB/language/statements/for-in/nonstrict-initializer.js b/js/src/tests/test262/annexB/language/statements/for-in/nonstrict-initializer.js new file mode 100644 index 0000000000..10d492827f --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/nonstrict-initializer.js @@ -0,0 +1,41 @@ +// 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-initializers-in-forin-statement-heads +description: > + for-in initializers in nonstrict mode +flags: [noStrict] +---*/ +(function() { + var effects = 0; + for (var a = ++effects in {}); + assert.sameValue(effects, 1); +})(); + + +(function() { + var stored; + for (var a = 0 in stored = a, {}); + assert.sameValue(stored, 0); +})(); + + +(function() { + for (var a = 0 in {}); + assert.sameValue(a, 0); +})(); + + +(function() { + var effects = 0; + var iterations = 0; + var stored; + for (var a = (++effects, -1) in stored = a, {a: 0, b: 1, c: 2}) { + ++iterations; + } + assert.sameValue(stored, -1, "Initialized value should be available to RHS"); + assert.sameValue(effects, 1, "Initializer should only be executed once"); + assert.sameValue(iterations, 3, "Loop body should be executed the appropriate number of times"); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/for-in/shell.js b/js/src/tests/test262/annexB/language/statements/for-in/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/for-in/strict-initializer-strict.js b/js/src/tests/test262/annexB/language/statements/for-in/strict-initializer-strict.js new file mode 100644 index 0000000000..afc84b3489 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/strict-initializer-strict.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +'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. +/*--- +esid: sec-initializers-in-forin-statement-heads +description: > + for-in initializers in strict mode are prohibited +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +for (var a = 0 in {}); diff --git a/js/src/tests/test262/annexB/language/statements/for-in/var-arraybindingpattern-initializer.js b/js/src/tests/test262/annexB/language/statements/for-in/var-arraybindingpattern-initializer.js new file mode 100644 index 0000000000..9857e0fcf6 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/var-arraybindingpattern-initializer.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. +/*--- +esid: sec-initializers-in-forin-statement-heads +description: > + for-in initializers with ArrayBindingPatterns are always prohibited +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +for (var [a] = 0 in {}); diff --git a/js/src/tests/test262/annexB/language/statements/for-in/var-objectbindingpattern-initializer.js b/js/src/tests/test262/annexB/language/statements/for-in/var-objectbindingpattern-initializer.js new file mode 100644 index 0000000000..dfa077eade --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-in/var-objectbindingpattern-initializer.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. +/*--- +esid: sec-initializers-in-forin-statement-heads +description: > + for-in initializers with ObjectBindingPattern are always prohibited +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +for (var {a} = 0 in {}); + diff --git a/js/src/tests/test262/annexB/language/statements/for-of/browser.js b/js/src/tests/test262/annexB/language/statements/for-of/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-of/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js b/js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js new file mode 100644 index 0000000000..6a81a3ec29 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-iteratorclose +description: > + If <iterator>.return is an object emulating `undefined` (e.g. `document.all` + in browsers), it shouldn't be treated as if it were actually `undefined`. +features: [generators, IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; +var iter = { + [Symbol.iterator]() { return this; }, + next() { return {}; }, + return: IsHTMLDDA, +}; + +assert.throws(TypeError, function() { + // `IsHTMLDDA` is called here with `iter` as `this` and no arguments, and it's + // specified to return `null` under these conditions. Then the iteration + // protocol throws a `TypeError` because `null` isn't an object. + for (var x of iter) + break; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/for-of/shell.js b/js/src/tests/test262/annexB/language/statements/for-of/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/for-of/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/function/browser.js b/js/src/tests/test262/annexB/language/statements/function/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/function/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/function/default-parameters-emulates-undefined.js b/js/src/tests/test262/annexB/language/statements/function/default-parameters-emulates-undefined.js new file mode 100644 index 0000000000..fac48fab79 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/function/default-parameters-emulates-undefined.js @@ -0,0 +1,74 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +description: > + Initializer is not evaluated when argument is an object with + [[IsHTMLDDA]] internal slot. +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +features: [default-parameters, IsHTMLDDA] +---*/ + +let initCount = 0; +const counter = function() { + initCount += 1; +}; + +const arrow = (x = counter()) => x; +const IsHTMLDDA = $262.IsHTMLDDA; + +assert.sameValue(arrow(IsHTMLDDA), IsHTMLDDA); +assert.sameValue(initCount, 0); + +function fn(x, y = counter()) { + return y; +} + +assert.sameValue(fn(1, IsHTMLDDA), IsHTMLDDA); +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/function/shell.js b/js/src/tests/test262/annexB/language/statements/function/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/function/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/if/browser.js b/js/src/tests/test262/annexB/language/statements/if/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/if/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/if/emulated-undefined.js b/js/src/tests/test262/annexB/language/statements/if/emulated-undefined.js new file mode 100644 index 0000000000..46f73419f8 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/if/emulated-undefined.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-if-statement-runtime-semantics-evaluation +description: > + ToBoolean returns `false` for [[IsHTMLDDA]] object; first Statement is not evaluated. +info: | + IfStatement : if ( Expression ) Statement else Statement + + 1. Let exprRef be the result of evaluating Expression. + 2. Let exprValue be ! ToBoolean(? GetValue(exprRef)). + 3. If exprValue is true, then + [...] + 4. Else, + a. Let stmtCompletion be the result of evaluating the second Statement. + + The [[IsHTMLDDA]] Internal Slot / Changes to ToBoolean + + 1. If argument has an [[IsHTMLDDA]] internal slot, return false. + 2. Return true. +features: [IsHTMLDDA] +---*/ + +var result = false; +if ($262.IsHTMLDDA) { + throw new Test262Error("unreachable"); +} else { + result = true; +} + +assert(result); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/if/shell.js b/js/src/tests/test262/annexB/language/statements/if/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/if/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/labeled/browser.js b/js/src/tests/test262/annexB/language/statements/labeled/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/labeled/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/labeled/function-declaration.js b/js/src/tests/test262/annexB/language/statements/labeled/function-declaration.js new file mode 100644 index 0000000000..ff3e9cf207 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/labeled/function-declaration.js @@ -0,0 +1,14 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + function declarations in statement position in non-strict mode: + label: Statement +flags: [noStrict] +---*/ +label: function g() {} + +label1: label2: function f() {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/labeled/shell.js b/js/src/tests/test262/annexB/language/statements/labeled/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/labeled/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/shell.js b/js/src/tests/test262/annexB/language/statements/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/switch/browser.js b/js/src/tests/test262/annexB/language/statements/switch/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/switch/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/switch/emulates-undefined.js b/js/src/tests/test262/annexB/language/statements/switch/emulates-undefined.js new file mode 100644 index 0000000000..a0452c5454 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/switch/emulates-undefined.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-caseclauseisselected +description: > + `switch` statement uses Strict Equality Comparison, + which doesn't special-case [[IsHTMLDDA]] objects. +info: | + Runtime Semantics: CaseClauseIsSelected ( C, input ) + + [...] + 4. Return the result of performing Strict Equality Comparison input === clauseSelector. + + Strict Equality Comparison + + 1. If Type(x) is different from Type(y), return false. +features: [IsHTMLDDA] +---*/ + +var IsHTMLDDA = $262.IsHTMLDDA; + +assert.sameValue( + (function() { + switch (IsHTMLDDA) { + case undefined: return 1; + case null: return 2; + case IsHTMLDDA: return 3; + } + })(), + 3 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/switch/shell.js b/js/src/tests/test262/annexB/language/statements/switch/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/switch/shell.js diff --git a/js/src/tests/test262/annexB/language/statements/try/browser.js b/js/src/tests/test262/annexB/language/statements/try/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-in-var.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-in-var.js new file mode 100644 index 0000000000..2a8efd5591 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-in-var.js @@ -0,0 +1,29 @@ +// 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-variablestatements-in-catch-blocks +es6id: B.3.5 +description: Re-declaration of catch parameter (for-in statement) +info: | + It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block, unless CatchParameter is + CatchParameter : BindingIdentifier. +---*/ + +var before, during, after; + +try { + throw 'exception'; +} catch (err) { + before = err; + for (var err in { propertyName: null }) { + during = err; + } + after = err; +} + +assert.sameValue(before, 'exception'); +assert.sameValue(during, 'propertyName', 'during loop body evaluation'); +assert.sameValue(after, 'propertyName', 'after loop body evaluation'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-of-var.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-of-var.js new file mode 100644 index 0000000000..2a9da1e1f9 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-of-var.js @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +author: Ross Kirsling +esid: sec-variablestatements-in-catch-blocks +description: Re-declaration of catch parameter (for-of statement) +info: | + It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block, unless CatchParameter is + CatchParameter : BindingIdentifier. +---*/ + +var before, during, after; + +try { + throw 'exception'; +} catch (err) { + before = err; + for (var err of [2]) { + during = err; + } + after = err; +} + +assert.sameValue(before, 'exception'); +assert.sameValue(during, 2, 'during loop body evaluation'); +assert.sameValue(after, 2, 'after loop body evaluation'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-var.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-var.js new file mode 100644 index 0000000000..0ca15f0af9 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-var.js @@ -0,0 +1,29 @@ +// 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-variablestatements-in-catch-blocks +es6id: B.3.5 +description: Re-declaration of catch parameter (for statement) +info: | + It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block, unless CatchParameter is + CatchParameter : BindingIdentifier. +---*/ + +var before, during, after; + +try { + throw 'exception'; +} catch (err) { + before = err; + for (var err = 'loop initializer'; err !== 'increment'; err = 'increment') { + during = err; + } + after = err; +} + +assert.sameValue(before, 'exception'); +assert.sameValue(during, 'loop initializer'); +assert.sameValue(after, 'increment'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement-captured.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement-captured.js new file mode 100644 index 0000000000..b9865d0a03 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement-captured.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.14-2 +es6id: B.3.5 +description: > + catch doesn't change declaration scope - var initializer in catch + with same name as catch parameter changes parameter +---*/ + + function capturedFoo() {return foo}; + foo = "prior to throw"; + try { + throw new Error(); + } + catch (foo) { + var foo = "initializer in catch"; + } + +assert.sameValue(capturedFoo(), "prior to throw"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement.js new file mode 100644 index 0000000000..6cfcbde4f7 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.14-1 +es6id: B.3.5 +description: > + catch doesn't change declaration scope - var initializer in catch + with same name as catch parameter changes parameter +---*/ + + foo = "prior to throw"; + try { + throw new Error(); + } + catch (foo) { + var foo = "initializer in catch"; + } + +assert.sameValue(foo, "prior to throw"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/shell.js b/js/src/tests/test262/annexB/language/statements/try/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/shell.js |