OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 (function() { | |
6 function slowSloppyArgumentsElements(a, b, c) { | |
7 arguments[10000] = 1; | |
8 return Object.keys(arguments); | |
9 } | |
10 assertEquals(["0", "1", "2", "10000"], slowSloppyArgumentsElements(1, 2, 3)); | |
11 | |
12 function slowSloppyArguments(a, b, c) { | |
13 arguments[10000] = 1; | |
14 return arguments; | |
15 } | |
16 | |
17 var args = slowSloppyArguments(1,2,3); | |
18 var keys = []; | |
19 for (var key in args) keys.push(key); | |
20 | |
21 assertEquals(["0", "1", "2", "10000"], keys); | |
22 })(); | |
23 | |
24 (function() { | |
25 function slowSloppyArgumentsElements2(a, b, c) { | |
26 Object.defineProperty(arguments, 10000, { | |
27 enumerable: false, configurable: false, value: "NOPE" | |
28 }); | |
29 return Object.keys(arguments); | |
30 } | |
31 assertEquals(["0", "1", "2"], slowSloppyArgumentsElements2(1, 2, 3)); | |
32 | |
33 function slowSloppyArguments2(a, b, c) { | |
34 Object.defineProperty(arguments, 10000, { | |
35 enumerable: false, configurable: false, value: "NOPE" | |
36 }); | |
37 return arguments; | |
38 } | |
39 | |
40 var args = slowSloppyArguments2(1,2,3); | |
41 var keys = []; | |
42 for (var key in args) keys.push(key); | |
43 | |
44 assertEquals(["0", "1", "2"], keys); | |
45 })(); | |
Camillo Bruni
2016/03/10 09:15:14
Nice tests!
Could you create a second set with a l
caitp (gmail)
2016/03/10 16:58:34
Done
| |
OLD | NEW |