diff --git a/test/language/default-parameters/function-length.js b/test/language/default-parameters/function-length.js deleted file mode 100644 index c26f313a6eeac07275304b7291a5951c39c7afb7..0000000000000000000000000000000000000000 --- a/test/language/default-parameters/function-length.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.1.6 -description: > - Default parameters' effect on function length -info: > - Function length is counted by the non initialized parameters in the left. - - FormalsList : FormalParameter - - 1. If HasInitializer of FormalParameter is true return 0 - 2. Return 1. - - FormalsList : FormalsList , FormalParameter - - 1. Let count be the ExpectedArgumentCount of FormalsList. - 2. If HasInitializer of FormalsList is true or HasInitializer of - FormalParameter is true, return count. - 3. Return count+1. ----*/ - -assert.sameValue((function (x = 42) {}).length, 0); -assert.sameValue((function (x = 42, y) {}).length, 0); -assert.sameValue((function (x, y = 42) {}).length, 1); -assert.sameValue((function (x, y = 42, z) {}).length, 1); diff --git a/test/language/expressions/arrow-function/length-dflt.js b/test/language/expressions/arrow-function/length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..b06e5b1d5a63c2b5ca7e3992b646dbe6fed20e3a --- /dev/null +++ b/test/language/expressions/arrow-function/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = (x = 42) => {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = (x = 42, y) => {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = (x, y = 42) => {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = (x, y = 42, z) => {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/class/gen-method-length-dflt.js b/test/language/expressions/class/gen-method-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..0de44b844c48218065a46671dd4a83dfa1a4f912 --- /dev/null +++ b/test/language/expressions/class/gen-method-length-dflt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var m1 = class { *m(x = 42) {} }.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +var m2 = class { *m(x = 42, y) {} }.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +var m3 = class { *m(x, y = 42) {} }.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +var m4 = class { *m(x, y = 42, z) {} }.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/expressions/class/getter-param-dflt.js b/test/language/expressions/class/getter-param-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..a6cbb974ecb219d1795daf1cc069d32a690aa586 --- /dev/null +++ b/test/language/expressions/class/getter-param-dflt.js @@ -0,0 +1,19 @@ +// 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-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: SyntaxError +---*/ + +0, class { get a(param = null) {} }; diff --git a/test/language/expressions/class/method-length-dflt.js b/test/language/expressions/class/method-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..7d86f69902bb9e8d796705c9e6c1907379ee676e --- /dev/null +++ b/test/language/expressions/class/method-length-dflt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var m1 = class { m(x = 42) {} }.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +var m2 = class { m(x = 42, y) {} }.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +var m3 = class { m(x, y = 42) {} }.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +var m4 = class { m(x, y = 42, z) {} }.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/expressions/class/setter-length-dflt.js b/test/language/expressions/class/setter-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..49ec1512dcc351659f29afa313aead9e27d21538 --- /dev/null +++ b/test/language/expressions/class/setter-length-dflt.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var C = class { set m(x = 42) {} }; +var set = Object.getOwnPropertyDescriptor(C.prototype, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); diff --git a/test/language/expressions/class/static-method-length-dflt.js b/test/language/expressions/class/static-method-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..4e638ef2ad47786439b4d33619490fc0daa5bc99 --- /dev/null +++ b/test/language/expressions/class/static-method-length-dflt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var m1 = class { static m(x = 42) {} }.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +var m2 = class { static m(x = 42, y) {} }.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +var m3 = class { static m(x, y = 42) {} }.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +var m4 = class { static m(x, y = 42, z) {} }.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/expressions/function/length-dflt.js b/test/language/expressions/function/length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..724e8f7443ac9b64b0300ae3d5e6286991a82814 --- /dev/null +++ b/test/language/expressions/function/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = function (x = 42) {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = function (x = 42, y) {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = function (x, y = 42) {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = function (x, y = 42, z) {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/generators/length-dflt.js b/test/language/expressions/generators/length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..8ea33c79345b757df48f54d4331bc53817305072 --- /dev/null +++ b/test/language/expressions/generators/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = function* (x = 42) {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = function* (x = 42, y) {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = function* (x, y = 42) {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = function* (x, y = 42, z) {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/object/getter-param-dflt.js b/test/language/expressions/object/getter-param-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..12d1a159a4cac5ef081018127cdc85038f5c3e33 --- /dev/null +++ b/test/language/expressions/object/getter-param-dflt.js @@ -0,0 +1,19 @@ +// 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-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: SyntaxError +---*/ + +0, { get a(param = null) {} }; diff --git a/test/language/expressions/object/method-definition/generator-length-dflt.js b/test/language/expressions/object/method-definition/generator-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..97cfe97971473a27155e9fa4fac8f97e7435f8af --- /dev/null +++ b/test/language/expressions/object/method-definition/generator-length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = { *m(x = 42) {} }.m; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = { *m(x = 42, y) {} }.m; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = { *m(x, y = 42) {} }.m; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = { *m(x, y = 42, z) {} }.m; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length') diff --git a/test/language/expressions/object/method-definition/name-length-dflt.js b/test/language/expressions/object/method-definition/name-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..91db6172ad31c62ecb6785bedf5497803d22d4d2 --- /dev/null +++ b/test/language/expressions/object/method-definition/name-length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = { m(x = 42) {} }.m; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = { m(x = 42, y) {} }.m; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = { m(x, y = 42) {} }.m; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = { m(x, y = 42, z) {} }.m; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/object/setter-length-dflt.js b/test/language/expressions/object/setter-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..a5e44d602b03cc0a6e07a024c0147df23a4e59bc --- /dev/null +++ b/test/language/expressions/object/setter-length-dflt.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var set = Object.getOwnPropertyDescriptor({ set m(x = 42) {} }, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); diff --git a/test/language/statements/class/gen-method-length-dflt.js b/test/language/statements/class/gen-method-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..a26a287fe728d4bd1e3ab13f7b66ae1d4ed5897d --- /dev/null +++ b/test/language/statements/class/gen-method-length-dflt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { *m(x = 42) {} } + +var m1 = C1.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { *m(x = 42, y) {} } + +var m2 = C2.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { *m(x, y = 42) {} } + +var m3 = C3.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { *m(x, y = 42, z) {} } + +var m4 = C4.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/statements/class/getter-param-dflt.js b/test/language/statements/class/getter-param-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..460bec80b82d63d8935132926ed6f219fcd02166 --- /dev/null +++ b/test/language/statements/class/getter-param-dflt.js @@ -0,0 +1,19 @@ +// 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-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: SyntaxError +---*/ + +class C { get a(param = null) {} } diff --git a/test/language/statements/class/method-length-dflt.js b/test/language/statements/class/method-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..42a742ed4b1674ef4d36394c26afa43e9439aff1 --- /dev/null +++ b/test/language/statements/class/method-length-dflt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { m(x = 42) {} } + +var m1 = C1.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { m(x = 42, y) {} } + +var m2 = C2.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { m(x, y = 42) {} } + +var m3 = C3.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { m(x, y = 42, z) {} } + +var m4 = C4.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/statements/class/setter-length-dflt.js b/test/language/statements/class/setter-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..b6a962d686dc409fd9fe67829e979895035c2259 --- /dev/null +++ b/test/language/statements/class/setter-length-dflt.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C { set m(x = 42) {} } +var set = Object.getOwnPropertyDescriptor(C.prototype, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); diff --git a/test/language/statements/class/static-method-length-dflt.js b/test/language/statements/class/static-method-length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..4a008d9fc883dc1a9d6a21fdd7cc6bb23e63c2c0 --- /dev/null +++ b/test/language/statements/class/static-method-length-dflt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { static m(x = 42) {} } + +var m1 = C1.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { static m(x = 42, y) {} } + +var m2 = C2.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { static m(x, y = 42) {} } + +var m3 = C3.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { static m(x, y = 42, z) {} } + +var m4 = C4.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/statements/function/length-dflt.js b/test/language/statements/function/length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..edcc10fb856c8344d13705531ce3fe5bbeb262aa --- /dev/null +++ b/test/language/statements/function/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +function f1(x = 42) {} + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +function f2(x = 42, y) {} + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +function f3(x, y = 42) {} + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +function f4(x, y = 42, z) {} + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/statements/generators/length-dflt.js b/test/language/statements/generators/length-dflt.js new file mode 100644 index 0000000000000000000000000000000000000000..5fbf5704676b6f70c417010c7225516223d90a37 --- /dev/null +++ b/test/language/statements/generators/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +function* f1(x = 42) {} + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +function* f2(x = 42, y) {} + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +function* f3(x, y = 42) {} + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +function* f4(x, y = 42, z) {} + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length');