Add tests for function length with dflt parameters

This commit is contained in:
Mike Pennisi 2016-05-31 17:30:41 -04:00 committed by Leonardo Balter
parent 7dcccfcca6
commit 7e3019e382
No known key found for this signature in database
GPG Key ID: 3151533059133F60
20 changed files with 972 additions and 26 deletions

View File

@ -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);

View File

@ -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');

View File

@ -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');

View File

@ -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) {} };

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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) {} };

View File

@ -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')

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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) {} }

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');