1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Array.prototype.splice sets length when called with no arguments
info: |
22.1.3.25 Array.prototype.splice (start, deleteCount , ...items )
...
24. Let setStatus be Set(O, "length", len – actualDeleteCount + itemCount, true).
25. ReturnIfAbrupt(setStatus).
esid: sec-array.prototype.splice
---*/
var getCallCount = 0,
setCallCount = 0;
var lengthValue;
var obj = {
get length() {
getCallCount += 1;
return "0";
},
set length(v) {
setCallCount += 1;
lengthValue = v;
}
};
Array.prototype.splice.call(obj);
assert.sameValue(getCallCount, 1, "Get('length') called exactly once");
assert.sameValue(setCallCount, 1, "Set('length') called exactly once");
assert.sameValue(lengthValue, 0, "Set('length') called with ToLength('0')");
reportCompare(0, 0);
|