| 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 |
|
| 34 |
var set = Object.getOwnPropertyDescriptor({ set m(x = 42) {} }, 'm').set; |
| 35 |
|
| 36 |
assert.sameValue(set.length, 0, 'FormalsList: x = 42'); |
| 37 |
verifyNotEnumerable(set, 'length'); |
| 38 |
verifyNotWritable(set, 'length'); |
| 39 |
verifyConfigurable(set, 'length'); |