diff --git a/test/built-ins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js new file mode 100644 index 0000000000000000000000000000000000000000..465b4664ecf5b937401502c656a840da3ec81c8c --- /dev/null +++ b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js @@ -0,0 +1,28 @@ +// 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-bound-function-exotic-objects-construct-argumentslist-newtarget +es6id: 9.4.1.2 +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using Reflect.construct and the "bound target" is + specified as the NewTarget value (and the bound target is itself a bound + function) +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [Reflect, new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = Reflect.construct(C, [], B); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/built-ins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js new file mode 100644 index 0000000000000000000000000000000000000000..b889634db4c169c09646963ef192fce94b0a9988 --- /dev/null +++ b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js @@ -0,0 +1,27 @@ +// 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-bound-function-exotic-objects-construct-argumentslist-newtarget +es6id: 9.4.1.2 +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using Reflect.construct and the "bound target" is + specified as the NewTarget value +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [Reflect, new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = Reflect.construct(C, [], A); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/built-ins/Function/prototype/bind/instance-construct-newtarget-self-new.js b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-self-new.js new file mode 100644 index 0000000000000000000000000000000000000000..f183dbf79a35eb92b0bce0128f86e24818ae86dd --- /dev/null +++ b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-self-new.js @@ -0,0 +1,26 @@ +// 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-bound-function-exotic-objects-construct-argumentslist-newtarget +es6id: 9.4.1.2 +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using the `new` operator +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = new C(); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/built-ins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js new file mode 100644 index 0000000000000000000000000000000000000000..8664a6eea6b55752fa3eb96b70bceb91cf71174d --- /dev/null +++ b/test/built-ins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js @@ -0,0 +1,27 @@ +// 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-bound-function-exotic-objects-construct-argumentslist-newtarget +es6id: 9.4.1.2 +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using Reflect.construct and the bound function is + specified as the NewTarget value +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [Reflect, new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = Reflect.construct(C, [], C); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/built-ins/String/numeric-properties.js b/test/built-ins/String/numeric-properties.js new file mode 100644 index 0000000000000000000000000000000000000000..d5981f73ada2131e46ace2338945c6c73b328145 --- /dev/null +++ b/test/built-ins/String/numeric-properties.js @@ -0,0 +1,32 @@ +// 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-string-exotic-objects-getownproperty-p +es6id: 9.4.3.1 +description: > + Property descriptor for numeric "own" properties of an exotic String object +info: | + [...] + 12. Let resultStr be a String value of length 1, containing one code unit + from str, specifically the code unit at index index. + 13. Return a PropertyDescriptor{[[Value]]: resultStr, [[Writable]]: false, + [[Enumerable]]: true, [[Configurable]]: false}. +includes: [propertyHelper.js] +---*/ + +var str = new String('abc'); + +assert.sameValue(str[0], 'a'); +verifyEnumerable(str, '0'); +verifyNotWritable(str, '0'); +verifyNotConfigurable(str, '0'); + +assert.sameValue(str[1], 'b'); +verifyEnumerable(str, '1'); +verifyNotWritable(str, '1'); +verifyNotConfigurable(str, '1'); + +assert.sameValue(str[2], 'c'); +verifyEnumerable(str, '2'); +verifyNotWritable(str, '2'); +verifyNotConfigurable(str, '2'); diff --git a/test/language/arguments-object/unmapped/via-params-dflt.js b/test/language/arguments-object/unmapped/via-params-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..32dda527cef06637dd9e29e945f3d6300765abbf --- /dev/null +++ b/test/language/arguments-object/unmapped/via-params-dflt.js @@ -0,0 +1,28 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments are "unmapped" when paramater list is non-simple due to "default" + parameter +info: | + [...] + 9. Let simpleParameterList be IsSimpleParameterList of formals. + [...] + 22. If argumentsObjectNeeded is true, then + a. If strict is true or if simpleParameterList is false, then + i. Let ao be CreateUnmappedArgumentsObject(argumentsList). + [...] +---*/ + +var value; + +function dflt(a, b = 0) { + arguments[0] = 2; + value = a; +} + +dflt(1); + +assert.sameValue(value, 1); diff --git a/test/language/arguments-object/unmapped/via-params-dstr.js b/test/language/arguments-object/unmapped/via-params-dstr.js new file mode 100644 index 0000000000000000000000000000000000000000..1d816ceb79f40eaa0ef8d93ee90ea487c0904d57 --- /dev/null +++ b/test/language/arguments-object/unmapped/via-params-dstr.js @@ -0,0 +1,28 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments are "unmapped" when paramater list is non-simple due to + destructuring pattern +info: | + [...] + 9. Let simpleParameterList be IsSimpleParameterList of formals. + [...] + 22. If argumentsObjectNeeded is true, then + a. If strict is true or if simpleParameterList is false, then + i. Let ao be CreateUnmappedArgumentsObject(argumentsList). + [...] +---*/ + +var value; + +function dstr(a, [b]) { + arguments[0] = 2; + value = a; +} + +dstr(1, []); + +assert.sameValue(value, 1); diff --git a/test/language/arguments-object/unmapped/via-params-rest.js b/test/language/arguments-object/unmapped/via-params-rest.js new file mode 100644 index 0000000000000000000000000000000000000000..dad30c920ac2f25c8cb21067f40cde099337a578 --- /dev/null +++ b/test/language/arguments-object/unmapped/via-params-rest.js @@ -0,0 +1,28 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments are "unmapped" when paramater list is non-simple due to "rest" + parameter +info: | + [...] + 9. Let simpleParameterList be IsSimpleParameterList of formals. + [...] + 22. If argumentsObjectNeeded is true, then + a. If strict is true or if simpleParameterList is false, then + i. Let ao be CreateUnmappedArgumentsObject(argumentsList). + [...] +---*/ + +var value; + +function rest(a, ...b) { + arguments[0] = 2; + value = a; +} + +rest(1); + +assert.sameValue(value, 1); diff --git a/test/language/arguments-object/10.6-10-c-ii-2-s.js b/test/language/arguments-object/unmapped/via-strict.js similarity index 100% rename from test/language/arguments-object/10.6-10-c-ii-2-s.js rename to test/language/arguments-object/unmapped/via-strict.js diff --git a/test/language/expressions/function/arguments-with-arguments-fn.js b/test/language/expressions/function/arguments-with-arguments-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..7cb9211b8d36f5c1bd6eb89d09bc0aca96be814a --- /dev/null +++ b/test/language/expressions/function/arguments-with-arguments-fn.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a lexically-scoped + binding named "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +var f = function(x = args = arguments) { + function arguments() {} +}; + +f(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/expressions/function/arguments-with-arguments-lex.js b/test/language/expressions/function/arguments-with-arguments-lex.js new file mode 100644 index 0000000000000000000000000000000000000000..9e19d3088eb28df2248df63a1e590682fe6b8168 --- /dev/null +++ b/test/language/expressions/function/arguments-with-arguments-lex.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a function named + "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +var f = function (x = args = arguments) { + let arguments; +}; + +f(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/expressions/generators/arguments-with-arguments-fn.js b/test/language/expressions/generators/arguments-with-arguments-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..946fd22b5018211918de1a644e3b40d55121032a --- /dev/null +++ b/test/language/expressions/generators/arguments-with-arguments-fn.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a lexically-scoped + binding named "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +var g = function* (x = args = arguments) { + function arguments() {} +}; + +g().next(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/expressions/generators/arguments-with-arguments-lex.js b/test/language/expressions/generators/arguments-with-arguments-lex.js new file mode 100644 index 0000000000000000000000000000000000000000..9cfe234a681867e6e1de37e873bc401d949d518d --- /dev/null +++ b/test/language/expressions/generators/arguments-with-arguments-lex.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a function named + "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +var g = function* (x = args = arguments) { + let arguments; +}; + +g().next(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/statements/function/arguments-with-arguments-fn.js b/test/language/statements/function/arguments-with-arguments-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..87b98de934d5476b657a3edef3eb6aa0193e9c8c --- /dev/null +++ b/test/language/statements/function/arguments-with-arguments-fn.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a lexically-scoped + binding named "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +function f(x = args = arguments) { + function arguments() {} +} + +f(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/statements/function/arguments-with-arguments-lex.js b/test/language/statements/function/arguments-with-arguments-lex.js new file mode 100644 index 0000000000000000000000000000000000000000..27ec6361d6dbf12bb441a491764c9a497a4de93e --- /dev/null +++ b/test/language/statements/function/arguments-with-arguments-lex.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a function named + "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +function f(x = args = arguments) { + let arguments; +} + +f(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/statements/generators/arguments-with-arguments-fn.js b/test/language/statements/generators/arguments-with-arguments-fn.js new file mode 100644 index 0000000000000000000000000000000000000000..728962cb4d839d8e22d6e77aabd800030a095c57 --- /dev/null +++ b/test/language/statements/generators/arguments-with-arguments-fn.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a lexically-scoped + binding named "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +function* g(x = args = arguments) { + function arguments() {} +} + +g().next(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0); diff --git a/test/language/statements/generators/arguments-with-arguments-lex.js b/test/language/statements/generators/arguments-with-arguments-lex.js new file mode 100644 index 0000000000000000000000000000000000000000..407908eedf2050213fb765750c1ecd8cabb047e0 --- /dev/null +++ b/test/language/statements/generators/arguments-with-arguments-lex.js @@ -0,0 +1,30 @@ +// 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-functiondeclarationinstantiation +es6id: 9.2.12 +description: > + Arguments object is created even when the body contains a function named + "arguments" +info: | + [...] + 19. Else if "arguments" is an element of parameterNames, then + a. Let argumentsObjectNeeded be false. + 20. Else if hasParameterExpressions is false, then + a. If "arguments" is an element of functionNames or if "arguments" is an + element of lexicalNames, then + i. Let argumentsObjectNeeded be false. + [...] +flags: [noStrict] +---*/ + +var args; + +function* g(x = args = arguments) { + let arguments; +} + +g().next(); + +assert.sameValue(typeof args, 'object'); +assert.sameValue(args.length, 0);