| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 14.1.6 |
| 5 |
description: > |
| 6 |
Default parameters' effect on function length |
| 7 |
info: | |
| 8 |
Function length is counted by the non initialized parameters in the left. |
| 9 |
|
| 10 |
9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) |
| 11 |
|
| 12 |
[...] |
| 13 |
2. Let len be the ExpectedArgumentCount of ParameterList. |
| 14 |
3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: |
| 15 |
len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). |
| 16 |
[...] |
| 17 |
|
| 18 |
FormalsList : FormalParameter |
| 19 |
|
| 20 |
1. If HasInitializer of FormalParameter is true return 0 |
| 21 |
2. Return 1. |
| 22 |
|
| 23 |
FormalsList : FormalsList , FormalParameter |
| 24 |
|
| 25 |
1. Let count be the ExpectedArgumentCount of FormalsList. |
| 26 |
2. If HasInitializer of FormalsList is true or HasInitializer of |
| 27 |
FormalParameter is true, return count. |
| 28 |
3. Return count+1. |
| 29 |
features: [default-parameters] |
| 30 |
includes: [propertyHelper.js] |
| 31 |
---*/ |
| 32 |
|
| 33 |
var m1 = class { static m(x = 42) {} }.m; |
| 34 |
|
| 35 |
verifyProperty(m1, "length", { |
| 36 |
value: 0, |
| 37 |
writable: false, |
| 38 |
enumerable: false, |
| 39 |
configurable: true, |
| 40 |
}); |
| 41 |
|
| 42 |
var m2 = class { static m(x = 42, y) {} }.m; |
| 43 |
|
| 44 |
verifyProperty(m2, "length", { |
| 45 |
value: 0, |
| 46 |
writable: false, |
| 47 |
enumerable: false, |
| 48 |
configurable: true, |
| 49 |
}); |
| 50 |
|
| 51 |
var m3 = class { static m(x, y = 42) {} }.m; |
| 52 |
|
| 53 |
verifyProperty(m3, "length", { |
| 54 |
value: 1, |
| 55 |
writable: false, |
| 56 |
enumerable: false, |
| 57 |
configurable: true, |
| 58 |
}); |
| 59 |
|
| 60 |
var m4 = class { static m(x, y = 42, z) {} }.m; |
| 61 |
|
| 62 |
verifyProperty(m4, "length", { |
| 63 |
value: 1, |
| 64 |
writable: false, |
| 65 |
enumerable: false, |
| 66 |
configurable: true, |
| 67 |
}); |
| 68 |
|
| 69 |
reportCompare(0, 0); |