mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 14:30:27 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
function test(actual, expected) {
|
|
if (actual !== expected)
|
|
throw new Error('bad value: ' + actual);
|
|
}
|
|
|
|
function testArguments(check) {
|
|
(function () {
|
|
check(arguments, []);
|
|
}());
|
|
|
|
(function (a, b, c) {
|
|
check(arguments, [a, b, c]);
|
|
}());
|
|
|
|
(function () {
|
|
'use strict';
|
|
check(arguments, []);
|
|
}());
|
|
|
|
(function (a, b, c) {
|
|
'use strict';
|
|
check(arguments, [a, b, c]);
|
|
}());
|
|
}
|
|
|
|
testArguments(function (args) {
|
|
var iteratorMethod = args[Symbol.iterator];
|
|
test(iteratorMethod, Array.prototype.values);
|
|
var descriptor = Object.getOwnPropertyDescriptor(args, Symbol.iterator);
|
|
test(descriptor.writable, true);
|
|
test(descriptor.configurable, true);
|
|
test(descriptor.enumerable, false);
|
|
test(descriptor.value, iteratorMethod);
|
|
});
|
|
|
|
testArguments(function (args, expected) {
|
|
var iterator = args[Symbol.iterator]();
|
|
test(iterator.toString(), '[object Array Iterator]');
|
|
var index = 0;
|
|
for (var value of iterator) {
|
|
test(value, expected[index++]);
|
|
}
|
|
test(args.length, index);
|
|
|
|
var index = 0;
|
|
for (var value of args) {
|
|
test(value, expected[index++]);
|
|
}
|
|
test(args.length, index);
|
|
});
|
|
|
|
testArguments(function (args) {
|
|
var symbols = Object.getOwnPropertySymbols(args);
|
|
test(symbols.length, 1);
|
|
test(symbols[0], Symbol.iterator);
|
|
});
|
|
|
|
testArguments(function (args) {
|
|
'use strict';
|
|
args[Symbol.iterator] = 'not throw error';
|
|
});
|
|
|
|
testArguments(function (args) {
|
|
'use strict';
|
|
delete args[Symbol.iterator];
|
|
test(args[Symbol.iterator], undefined);
|
|
|
|
var symbols = Object.getOwnPropertySymbols(args);
|
|
test(symbols.length, 0);
|
|
});
|