diff --git a/test/annexB/language/function-code/block-decl-nested-blocks-with-fun-decl.js b/test/annexB/language/function-code/block-decl-nested-blocks-with-fun-decl.js new file mode 100644 index 0000000000..d3fc1274ba --- /dev/null +++ b/test/annexB/language/function-code/block-decl-nested-blocks-with-fun-decl.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-web-compat-functiondeclarationinstantiation +description: > + Nested function declarations, the second declaration is not Annex-B applicable. +info: | + B.3.3.1 Changes to FunctionDeclarationInstantiation + + 1. If strict is false, then + a. For each FunctionDeclaration f that is directly contained in the + StatementList of a Block, CaseClause, or DefaultClause, do + i. Let F be StringValue of the BindingIdentifier of FunctionDeclaration f. + ii. If replacing the FunctionDeclaration f with a VariableStatement that + has F as a BindingIdentifier would not produce any Early Errors for + func and F is not an element of parameterNames, then + ... +flags: [noStrict] +---*/ + +function g() { + // Create an outer block-statement. + { + // A lexically declared function declaration. + // This function is applicable for Annex-B semantics. + function f() { return 1; } + + // An inner block-statement with another function declaration. + // This function is not applicable for Annex-B semantics, because + // replacing it with |var f| would result in a SyntaxError. + { + function f() { return 2; } + } + } + + assert.sameValue(f(), 1); +} + +g(); diff --git a/test/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js b/test/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..0197c1d9ac --- /dev/null +++ b/test/built-ins/Array/prototype/filter/target-array-with-non-writable-property.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.filter +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.filter(function(){ return true; }); + +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); diff --git a/test/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js b/test/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 0000000000..436f32bf06 --- /dev/null +++ b/test/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,43 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.indexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +info: | + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) + ... + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ... +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var array = [1, null, 3]; + +Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); + +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + array.length = 0; + return 0; + } +}; + +Array.prototype.indexOf.call(array, 100, fromIndex); diff --git a/test/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js b/test/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 0000000000..c9101a4e20 --- /dev/null +++ b/test/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,43 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +info: | + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. If fromIndex is present, let n be ? ToInteger(fromIndex); else let n be len-1. + ... + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ... +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var array = [5, undefined, 7]; + +Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); + +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + array.length = 0; + return 2; + } +}; + +Array.prototype.lastIndexOf.call(array, 100, fromIndex); diff --git a/test/built-ins/Array/prototype/map/target-array-with-non-writable-property.js b/test/built-ins/Array/prototype/map/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..842388af49 --- /dev/null +++ b/test/built-ins/Array/prototype/map/target-array-with-non-writable-property.js @@ -0,0 +1,36 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.map +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.16 Array.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat, while k < len + ... + c. If kPresent is true, then + ... + iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.map(function(){ return 2; }); + +verifyProperty(r, 0, { + value: 2, writable: true, configurable: true, enumerable: true, +}); diff --git a/test/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js b/test/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..ec7d1f05f7 --- /dev/null +++ b/test/built-ins/Array/prototype/slice/target-array-with-non-writable-property.js @@ -0,0 +1,36 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.slice +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.23 Array.prototype.slice ( start, end ) + + ... + 10. Repeat, while k < final + ... + c. If kPresent is true, then + ... + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), kValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.slice(0); + +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); diff --git a/test/built-ins/Array/prototype/splice/property-traps-order-with-species.js b/test/built-ins/Array/prototype/splice/property-traps-order-with-species.js new file mode 100644 index 0000000000..4c8211b56d --- /dev/null +++ b/test/built-ins/Array/prototype/splice/property-traps-order-with-species.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Ensure the correct property traps are called on the new array. +features: [Proxy, Symbol.species] +includes: [compareArray.js] +---*/ + +var log = []; + +var a = [0, 1]; +a.constructor = {}; + +a.constructor[Symbol.species] = function(len) { + return new Proxy(new Array(len), new Proxy({}, { + get(t, pk, r) { + log.push(pk); + } + })); +}; + +var r = a.splice(0); + +assert.compareArray([ + // Step 11.c.ii: CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + "defineProperty", + + // Step 11.c.ii: CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + "defineProperty", + + // Step 12: Perform ? Set(A, "length", actualDeleteCount, true). + "set", + "getOwnPropertyDescriptor", + "defineProperty", +], log); diff --git a/test/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js b/test/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js new file mode 100644 index 0000000000..dfb03318a2 --- /dev/null +++ b/test/built-ins/Array/prototype/splice/target-array-with-non-writable-property.js @@ -0,0 +1,36 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.splice +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.26 Array.prototype.splice ( start, deleteCount, ...items ) + + ... + 11. Repeat, while k < actualDeleteCount + ... + c. If fromPresent is true, then + ... + ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + ... +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; + +var r = a.splice(0); + +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); diff --git a/test/built-ins/Function/prototype/bind/length-exceeds-int32.js b/test/built-ins/Function/prototype/bind/length-exceeds-int32.js new file mode 100644 index 0000000000..95fd81c0c4 --- /dev/null +++ b/test/built-ins/Function/prototype/bind/length-exceeds-int32.js @@ -0,0 +1,26 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-function.prototype.bind +description: > + The target function length can exceed 2**31-1. +info: | + 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) + + ... + 6. If targetHasLength is true, then + a. Let targetLen be ? Get(Target, "length"). + b. If Type(targetLen) is not Number, let L be 0. + c. Else, + i. Let targetLen be ToInteger(targetLen). + ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. + ... + 8. Perform ! SetFunctionLength(F, L). + ... +---*/ + +function f(){} +Object.defineProperty(f, "length", {value: 2147483648}); + +assert.sameValue(f.bind().length, 2147483648); diff --git a/test/built-ins/Object/assign/strings-and-symbol-order.js b/test/built-ins/Object/assign/strings-and-symbol-order.js new file mode 100644 index 0000000000..8372154f95 --- /dev/null +++ b/test/built-ins/Object/assign/strings-and-symbol-order.js @@ -0,0 +1,61 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.assign +description: > + Symbol-valued properties are copied after String-valued properties. +info: | + 19.1.2.1 Object.assign ( target, ...sources ) + + ... + 4. For each element nextSource of sources, in ascending index order, do + a. ... + b. Else, + i. Let from be ! ToObject(nextSource). + ii. Let keys be ? from.[[OwnPropertyKeys]](). + c. For each element nextKey of keys in List order, do + ... + ... + + 9.1.11.1 OrdinaryOwnPropertyKeys ( O ) + + ... + 3. For each own property key P of O that is a String but is not an integer index, + in ascending chronological order of property creation, do + a. Add P as the last element of keys. + 4. For each own property key P of O that is a Symbol, in ascending chronological + order of property creation, do + a. Add P as the last element of keys. + ... + +includes: [compareArray.js] +---*/ + +var log = []; + +var sym1 = Symbol("x"); +var sym2 = Symbol("y"); + +var source = {}; + +Object.defineProperty(source, sym1, { + get: function(){ log.push("get sym(x)") }, + enumerable: true, configurable: true, +}); +Object.defineProperty(source, "a", { + get: function(){ log.push("get a") }, + enumerable: true, configurable: true, +}); +Object.defineProperty(source, sym2, { + get: function(){ log.push("get sym(y)") }, + enumerable: true, configurable: true, +}); +Object.defineProperty(source, "b", { + get: function(){ log.push("get b") }, + enumerable: true, configurable: true, +}); + +var target = Object.assign({}, source); + +assert.compareArray(log, ["get a", "get b", "get sym(x)", "get sym(y)"]); diff --git a/test/built-ins/Object/keys/property-traps-order-with-proxied-array.js b/test/built-ins/Object/keys/property-traps-order-with-proxied-array.js new file mode 100644 index 0000000000..c93d72771e --- /dev/null +++ b/test/built-ins/Object/keys/property-traps-order-with-proxied-array.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.keys +description: > + Ensure the correct property traps are called on a proxy of an array. +info: | + 19.1.2.16 Object.keys ( O ) + ... + 2. Let nameList be ? EnumerableOwnPropertyNames(obj, "key"). + ... + + 7.3.21 EnumerableOwnPropertyNames ( O, kind ) + ... + 2. Let ownKeys be ? O.[[OwnPropertyKeys]](). + ... + 4. For each element key of ownKeys in List order, do + a. If Type(key) is String, then + i. Let desc be ? O.[[GetOwnProperty]](key). + ... +features: [Proxy] +includes: [compareArray.js] +---*/ + +var log = []; + +Object.keys(new Proxy([], new Proxy({},{ + get(t, pk, r) { + log.push(pk); + } +}))); + +assert.compareArray([ + "ownKeys", + "getOwnPropertyDescriptor", +], log); diff --git a/test/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js b/test/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js new file mode 100644 index 0000000000..62de5101b4 --- /dev/null +++ b/test/intl402/Array/prototype/toLocaleString/calls-toLocaleString-number-elements.js @@ -0,0 +1,17 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sup-array.prototype.tolocalestring +description: > + Ensure "toLocaleString" is called with locale and options on number elements. +---*/ + +var n = 0; + +var locale = "th-u-nu-thai"; +var options = { + minimumFractionDigits: 3 +}; + +assert.sameValue([n].toLocaleString(locale, options), n.toLocaleString(locale, options)); diff --git a/test/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js b/test/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js new file mode 100644 index 0000000000..db9d45d23d --- /dev/null +++ b/test/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sup-array.prototype.tolocalestring +description: > + Ensure "toLocaleString" is called with locale and options on number elements. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var n = 0; + +var locale = "th-u-nu-thai"; +var options = { + minimumFractionDigits: 3 +}; + +var expected = n.toLocaleString(locale, options); + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(new TA([n]).toLocaleString(locale, options), expected); +}); diff --git a/test/language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js b/test/language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js new file mode 100644 index 0000000000..0c638faf6c --- /dev/null +++ b/test/language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-block-static-semantics-early-errors +description: > + Redeclaration with VariableDeclaration (FunctionDeclaration in BlockStatement) +info: | + 13.2.1 Static Semantics: Early Errors + + It is a Syntax Error if any element of the LexicallyDeclaredNames of + StatementList also occurs in the VarDeclaredNames of StatementList. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +function g() { + // Create an outer block-statement. + { + // A lexically declared function declaration. + function f() {} + + // An inner block-statement with a variable-declared name. + { + var f; + } + } +} diff --git a/test/language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js b/test/language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js new file mode 100644 index 0000000000..8823023178 --- /dev/null +++ b/test/language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js @@ -0,0 +1,15 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-arrow-function-definitions +description: > + It is a SyntaxError if FormalParameters' default expressions contains await. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +async(a = await => {}) => {}; diff --git a/test/language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.js b/test/language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.js new file mode 100644 index 0000000000..bf6d180bf0 --- /dev/null +++ b/test/language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.js @@ -0,0 +1,15 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-arrow-function-definitions +description: > + It is a SyntaxError if FormalParameters' default expressions contains await. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +async() => { (a = await/r/g) => {} }; diff --git a/test/language/expressions/async-arrow-function/await-as-param-nested-arrow-parameter-position.js b/test/language/expressions/async-arrow-function/await-as-param-nested-arrow-parameter-position.js new file mode 100644 index 0000000000..79266eaa54 --- /dev/null +++ b/test/language/expressions/async-arrow-function/await-as-param-nested-arrow-parameter-position.js @@ -0,0 +1,15 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-arrow-function-definitions +description: > + It is a SyntaxError if FormalParameters' default expressions contains await. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +async(a = (await) => {}) => {}; diff --git a/test/language/expressions/async-arrow-function/await-as-param-rest-nested-arrow-parameter-position.js b/test/language/expressions/async-arrow-function/await-as-param-rest-nested-arrow-parameter-position.js new file mode 100644 index 0000000000..ca65bf19a7 --- /dev/null +++ b/test/language/expressions/async-arrow-function/await-as-param-rest-nested-arrow-parameter-position.js @@ -0,0 +1,15 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-arrow-function-definitions +description: > + It is a SyntaxError if FormalParameters' default expressions contains await. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +async(a = (...await) => {}) => {}; diff --git a/test/language/expressions/async-arrow-function/escaped-async-line-terminator.js b/test/language/expressions/async-arrow-function/escaped-async-line-terminator.js new file mode 100644 index 0000000000..ee3a7a0547 --- /dev/null +++ b/test/language/expressions/async-arrow-function/escaped-async-line-terminator.js @@ -0,0 +1,29 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-async-arrow-function-definitions +description: > + Escaped "async" followed by a line-terminator is not misinterpreted as an AsyncArrowFunction. +info: | + 14.7 Async Function Definitions + + async [no LineTerminator here] AsyncArrowBindingIdentifier[?Yield] [no LineTerminator here] => AsyncConciseBody[?In] + + 5.1.5 Grammar Notation + + Terminal symbols of the lexical, RegExp, and numeric string grammars 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. +features: [async-functions] +---*/ + +// Throws ReferenceError because reference for "async" cannot be resolved. +assert.throws(ReferenceError, function() { + \u0061sync + p => {} +}); diff --git a/test/language/expressions/async-generator/generator-created-after-decl-inst.js b/test/language/expressions/async-generator/generator-created-after-decl-inst.js new file mode 100644 index 0000000000..d492e5ef16 --- /dev/null +++ b/test/language/expressions/async-generator/generator-created-after-decl-inst.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgenerator-definitions-evaluatebody +description: > + The generator object is created after FunctionDeclarationInstantiation. +info: | + 14.5.10 Runtime Semantics: EvaluateBody + + 1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList). + 2. Let generator be ? OrdinaryCreateFromConstructor(functionObject, "%AsyncGeneratorPrototype%", + « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). + 3. Perform ! AsyncGeneratorStart(generator, FunctionBody). + ... + +features: [async-iteration] +---*/ + +var g = async function*(a = (g.prototype = null)) {} +var oldPrototype = g.prototype; +var it = g(); + +assert.notSameValue(Object.getPrototypeOf(it), oldPrototype); diff --git a/test/language/expressions/class/class-name-ident-await-escaped-module.js b/test/language/expressions/class/class-name-ident-await-escaped-module.js new file mode 100644 index 0000000000..8fc155c4ba --- /dev/null +++ b/test/language/expressions/class/class-name-ident-await-escaped-module.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` with escape sequence is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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] +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class aw\u0061it {}; diff --git a/test/language/expressions/class/class-name-ident-await-escaped.js b/test/language/expressions/class/class-name-ident-await-escaped.js new file mode 100644 index 0000000000..b3dd022b49 --- /dev/null +++ b/test/language/expressions/class/class-name-ident-await-escaped.js @@ -0,0 +1,17 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` with escape sequence is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". +---*/ + +var C = class aw\u0061it {}; diff --git a/test/language/expressions/class/class-name-ident-await-module.js b/test/language/expressions/class/class-name-ident-await-module.js new file mode 100644 index 0000000000..e9ba2b5930 --- /dev/null +++ b/test/language/expressions/class/class-name-ident-await-module.js @@ -0,0 +1,22 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : yield + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class await {}; diff --git a/test/language/expressions/class/class-name-ident-await.js b/test/language/expressions/class/class-name-ident-await.js new file mode 100644 index 0000000000..8fbf07e990 --- /dev/null +++ b/test/language/expressions/class/class-name-ident-await.js @@ -0,0 +1,16 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : yield + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +---*/ + +var C = class await {}; diff --git a/test/language/expressions/class/class-name-ident-let-escaped.js b/test/language/expressions/class/class-name-ident-let-escaped.js new file mode 100644 index 0000000000..e9beb52c1d --- /dev/null +++ b/test/language/expressions/class/class-name-ident-let-escaped.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `let` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class l\u0065t {}; diff --git a/test/language/expressions/class/class-name-ident-let.js b/test/language/expressions/class/class-name-ident-let.js new file mode 100644 index 0000000000..d08620fde6 --- /dev/null +++ b/test/language/expressions/class/class-name-ident-let.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `let` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class let {}; diff --git a/test/language/expressions/class/class-name-ident-static-escaped.js b/test/language/expressions/class/class-name-ident-static-escaped.js new file mode 100644 index 0000000000..8680e6909b --- /dev/null +++ b/test/language/expressions/class/class-name-ident-static-escaped.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `static` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class st\u0061tic {}; diff --git a/test/language/expressions/class/class-name-ident-static.js b/test/language/expressions/class/class-name-ident-static.js new file mode 100644 index 0000000000..a914e599be --- /dev/null +++ b/test/language/expressions/class/class-name-ident-static.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `static` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class static {}; diff --git a/test/language/expressions/class/class-name-ident-yield-escaped.js b/test/language/expressions/class/class-name-ident-yield-escaped.js new file mode 100644 index 0000000000..6adf12d757 --- /dev/null +++ b/test/language/expressions/class/class-name-ident-yield-escaped.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `yield` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class yi\u0065ld {}; diff --git a/test/language/expressions/class/class-name-ident-yield.js b/test/language/expressions/class/class-name-ident-yield.js new file mode 100644 index 0000000000..ecc3f44dda --- /dev/null +++ b/test/language/expressions/class/class-name-ident-yield.js @@ -0,0 +1,25 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `yield` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : yield + + It is a Syntax Error if the code matched by this production is contained in strict mode code. + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class yield {}; diff --git a/test/language/expressions/generators/generator-created-after-decl-inst.js b/test/language/expressions/generators/generator-created-after-decl-inst.js new file mode 100644 index 0000000000..c7c198f233 --- /dev/null +++ b/test/language/expressions/generators/generator-created-after-decl-inst.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluatebody +description: > + The generator object is created after FunctionDeclarationInstantiation. +info: | + 14.4.10 Runtime Semantics: EvaluateBody + + 1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList). + 2. Let G be ? OrdinaryCreateFromConstructor(functionObject, "%GeneratorPrototype%", + « [[GeneratorState]], [[GeneratorContext]] »). + 3. Perform GeneratorStart(G, FunctionBody). + ... + +features: [generators] +---*/ + +var g = function*(a = (g.prototype = null)) {} +var oldPrototype = g.prototype; +var it = g(); + +assert.notSameValue(Object.getPrototypeOf(it), oldPrototype); diff --git a/test/language/statements/async-generator/generator-created-after-decl-inst.js b/test/language/statements/async-generator/generator-created-after-decl-inst.js new file mode 100644 index 0000000000..4ca30a528e --- /dev/null +++ b/test/language/statements/async-generator/generator-created-after-decl-inst.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgenerator-definitions-evaluatebody +description: > + The generator object is created after FunctionDeclarationInstantiation. +info: | + 14.5.10 Runtime Semantics: EvaluateBody + + 1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList). + 2. Let generator be ? OrdinaryCreateFromConstructor(functionObject, "%AsyncGeneratorPrototype%", + « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] »). + 3. Perform ! AsyncGeneratorStart(generator, FunctionBody). + ... + +features: [async-iteration] +---*/ + +async function* g(a = (g.prototype = null)) {} +var oldPrototype = g.prototype; +var it = g(); + +assert.notSameValue(Object.getPrototypeOf(it), oldPrototype); diff --git a/test/language/statements/class/class-name-ident-await-escaped-module.js b/test/language/statements/class/class-name-ident-await-escaped-module.js new file mode 100644 index 0000000000..5c1eb1c465 --- /dev/null +++ b/test/language/statements/class/class-name-ident-await-escaped-module.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` with escape sequence is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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] +---*/ + +throw "Test262: This statement should not be evaluated."; + +class aw\u0061it {} diff --git a/test/language/statements/class/class-name-ident-await-escaped.js b/test/language/statements/class/class-name-ident-await-escaped.js new file mode 100644 index 0000000000..b1f28aaaac --- /dev/null +++ b/test/language/statements/class/class-name-ident-await-escaped.js @@ -0,0 +1,17 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` with escape sequence is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". +---*/ + +class aw\u0061it {} diff --git a/test/language/statements/class/class-name-ident-await-module.js b/test/language/statements/class/class-name-ident-await-module.js new file mode 100644 index 0000000000..ec6af342ee --- /dev/null +++ b/test/language/statements/class/class-name-ident-await-module.js @@ -0,0 +1,22 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : await + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +throw "Test262: This statement should not be evaluated."; + +class await {} diff --git a/test/language/statements/class/class-name-ident-await.js b/test/language/statements/class/class-name-ident-await.js new file mode 100644 index 0000000000..0237382e7e --- /dev/null +++ b/test/language/statements/class/class-name-ident-await.js @@ -0,0 +1,16 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : await + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +---*/ + +class await {} diff --git a/test/language/statements/class/class-name-ident-let-escaped.js b/test/language/statements/class/class-name-ident-let-escaped.js new file mode 100644 index 0000000000..eb54d47529 --- /dev/null +++ b/test/language/statements/class/class-name-ident-let-escaped.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `let` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class l\u0065t {} diff --git a/test/language/statements/class/class-name-ident-let.js b/test/language/statements/class/class-name-ident-let.js new file mode 100644 index 0000000000..62da2542af --- /dev/null +++ b/test/language/statements/class/class-name-ident-let.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `let` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class let {} diff --git a/test/language/statements/class/class-name-ident-static-escaped.js b/test/language/statements/class/class-name-ident-static-escaped.js new file mode 100644 index 0000000000..fe1e1e7960 --- /dev/null +++ b/test/language/statements/class/class-name-ident-static-escaped.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `static` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class st\u0061tic {} diff --git a/test/language/statements/class/class-name-ident-static.js b/test/language/statements/class/class-name-ident-static.js new file mode 100644 index 0000000000..43b7c9ca9b --- /dev/null +++ b/test/language/statements/class/class-name-ident-static.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `static` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class static {} diff --git a/test/language/statements/class/class-name-ident-yield-escaped.js b/test/language/statements/class/class-name-ident-yield-escaped.js new file mode 100644 index 0000000000..e2992b51d3 --- /dev/null +++ b/test/language/statements/class/class-name-ident-yield-escaped.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `yield` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + 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". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class yi\u0065ld {} diff --git a/test/language/statements/class/class-name-ident-yield.js b/test/language/statements/class/class-name-ident-yield.js new file mode 100644 index 0000000000..6ef5165992 --- /dev/null +++ b/test/language/statements/class/class-name-ident-yield.js @@ -0,0 +1,25 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `yield` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : yield + + It is a Syntax Error if the code matched by this production is contained in strict mode code. + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class yield {} diff --git a/test/language/statements/generators/generator-created-after-decl-inst.js b/test/language/statements/generators/generator-created-after-decl-inst.js new file mode 100644 index 0000000000..a0f49f9790 --- /dev/null +++ b/test/language/statements/generators/generator-created-after-decl-inst.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluatebody +description: > + The generator object is created after FunctionDeclarationInstantiation. +info: | + 14.4.10 Runtime Semantics: EvaluateBody + + 1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList). + 2. Let G be ? OrdinaryCreateFromConstructor(functionObject, "%GeneratorPrototype%", + « [[GeneratorState]], [[GeneratorContext]] »). + 3. Perform GeneratorStart(G, FunctionBody). + ... + +features: [generators] +---*/ + +function* g(a = (g.prototype = null)) {} +var oldPrototype = g.prototype; +var it = g(); + +assert.notSameValue(Object.getPrototypeOf(it), oldPrototype); diff --git a/test/language/statements/try/early-catch-function.js b/test/language/statements/try/early-catch-function.js new file mode 100644 index 0000000000..f51c16701a --- /dev/null +++ b/test/language/statements/try/early-catch-function.js @@ -0,0 +1,25 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-try-statement-static-semantics-early-errors +description: > + Redeclaration of CatchParameter with directly nested FunctionDeclaration in function context. +info: | + 13.15.1 Static Semantics: Early Errors + + It is a Syntax Error if any element of the BoundNames of CatchParameter also + occurs in the LexicallyDeclaredNames of Block. +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +function f() { + try { + } catch (e) { + function e(){} + } +}