]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/arguments-iterator.js
1980532107da9769ce98d281a6f5b145171859b9
1 function test(actual
, expected
) {
2 if (actual
!== expected
)
3 throw new Error('bad value: ' + actual
);
6 function testArguments(check
) {
12 check(arguments
, [a
, b
, c
]);
22 check(arguments
, [a
, b
, c
]);
26 testArguments(function (args
) {
27 var iteratorMethod
= args
[Symbol
.iterator
];
28 test(iteratorMethod
, Array
.prototype.values
);
29 var descriptor
= Object
.getOwnPropertyDescriptor(args
, Symbol
.iterator
);
30 test(descriptor
.writable
, true);
31 test(descriptor
.configurable
, true);
32 test(descriptor
.enumerable
, false);
33 test(descriptor
.value
, iteratorMethod
);
36 testArguments(function (args
, expected
) {
37 var iterator
= args
[Symbol
.iterator
]();
38 test(iterator
.toString(), '[object Array Iterator]');
40 for (var value
of iterator
) {
41 test(value
, expected
[index
++]);
43 test(args
.length
, index
);
46 for (var value
of args
) {
47 test(value
, expected
[index
++]);
49 test(args
.length
, index
);
52 testArguments(function (args
) {
53 var symbols
= Object
.getOwnPropertySymbols(args
);
54 test(symbols
.length
, 1);
55 test(symbols
[0], Symbol
.iterator
);
58 testArguments(function (args
) {
60 args
[Symbol
.iterator
] = 'not throw error';
63 testArguments(function (args
) {
65 delete args
[Symbol
.iterator
];
66 test(args
[Symbol
.iterator
], undefined);
68 var symbols
= Object
.getOwnPropertySymbols(args
);
69 test(symbols
.length
, 0);