mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 13:04:39 +02:00
update Array/From files ESID to sec-array.from (#1077)
This commit is contained in:
parent
c74e1e4edf
commit
b07621ded1
@ -5,6 +5,7 @@
|
|||||||
description: Testing descriptor property of Array.from
|
description: Testing descriptor property of Array.from
|
||||||
includes:
|
includes:
|
||||||
- propertyHelper.js
|
- propertyHelper.js
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: '`name` property'
|
description: '`name` property'
|
||||||
info: >
|
info: >
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
The length property of the Array.from method is 1.
|
The length property of the Array.from method is 1.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
If this is a constructor, and items doesn't have an @@iterator,
|
If this is a constructor, and items doesn't have an @@iterator,
|
||||||
|
@ -1,66 +1,67 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
description: Map function without thisArg on non strict mode
|
es6id: 22.1.2.1
|
||||||
info: >
|
description: Map function without thisArg on non strict mode
|
||||||
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
info: >
|
||||||
|
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
||||||
...
|
|
||||||
10. Let len be ToLength(Get(arrayLike, "length")).
|
...
|
||||||
11. ReturnIfAbrupt(len).
|
10. Let len be ToLength(Get(arrayLike, "length")).
|
||||||
12. If IsConstructor(C) is true, then
|
11. ReturnIfAbrupt(len).
|
||||||
a. Let A be Construct(C, «len»).
|
12. If IsConstructor(C) is true, then
|
||||||
13. Else,
|
a. Let A be Construct(C, «len»).
|
||||||
b. Let A be ArrayCreate(len).
|
13. Else,
|
||||||
14. ReturnIfAbrupt(A).
|
b. Let A be ArrayCreate(len).
|
||||||
15. Let k be 0.
|
14. ReturnIfAbrupt(A).
|
||||||
16. Repeat, while k < len
|
15. Let k be 0.
|
||||||
a. Let Pk be ToString(k).
|
16. Repeat, while k < len
|
||||||
b. Let kValue be Get(arrayLike, Pk).
|
a. Let Pk be ToString(k).
|
||||||
c. ReturnIfAbrupt(kValue).
|
b. Let kValue be Get(arrayLike, Pk).
|
||||||
d. If mapping is true, then
|
c. ReturnIfAbrupt(kValue).
|
||||||
i. Let mappedValue be Call(mapfn, T, «kValue, k»).
|
d. If mapping is true, then
|
||||||
...
|
i. Let mappedValue be Call(mapfn, T, «kValue, k»).
|
||||||
flags: [noStrict]
|
...
|
||||||
---*/
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
var list = {
|
|
||||||
'0': 41,
|
var list = {
|
||||||
'1': 42,
|
'0': 41,
|
||||||
'2': 43,
|
'1': 42,
|
||||||
length: 3
|
'2': 43,
|
||||||
};
|
length: 3
|
||||||
var calls = [];
|
};
|
||||||
|
var calls = [];
|
||||||
function mapFn (value) {
|
|
||||||
calls.push({
|
function mapFn (value) {
|
||||||
args: arguments,
|
calls.push({
|
||||||
thisArg: this
|
args: arguments,
|
||||||
});
|
thisArg: this
|
||||||
return value * 2;
|
});
|
||||||
}
|
return value * 2;
|
||||||
|
}
|
||||||
var result = Array.from(list, mapFn);
|
|
||||||
|
var result = Array.from(list, mapFn);
|
||||||
assert.sameValue(result.length, 3, 'result.length');
|
|
||||||
assert.sameValue(result[0], 82, 'result[0]');
|
assert.sameValue(result.length, 3, 'result.length');
|
||||||
assert.sameValue(result[1], 84, 'result[1]');
|
assert.sameValue(result[0], 82, 'result[0]');
|
||||||
assert.sameValue(result[2], 86, 'result[2]');
|
assert.sameValue(result[1], 84, 'result[1]');
|
||||||
|
assert.sameValue(result[2], 86, 'result[2]');
|
||||||
assert.sameValue(calls.length, 3, 'calls.length');
|
|
||||||
|
assert.sameValue(calls.length, 3, 'calls.length');
|
||||||
assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length');
|
|
||||||
assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]');
|
assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length');
|
||||||
assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]');
|
assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]');
|
||||||
assert.sameValue(calls[0].thisArg, this, 'calls[0].thisArg');
|
assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]');
|
||||||
|
assert.sameValue(calls[0].thisArg, this, 'calls[0].thisArg');
|
||||||
assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length');
|
|
||||||
assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]');
|
assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length');
|
||||||
assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]');
|
assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]');
|
||||||
assert.sameValue(calls[1].thisArg, this, 'calls[1].thisArg');
|
assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]');
|
||||||
|
assert.sameValue(calls[1].thisArg, this, 'calls[1].thisArg');
|
||||||
assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length');
|
|
||||||
assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]');
|
assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length');
|
||||||
assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]');
|
assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]');
|
||||||
assert.sameValue(calls[2].thisArg, this, 'calls[2].thisArg');
|
assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]');
|
||||||
|
assert.sameValue(calls[2].thisArg, this, 'calls[2].thisArg');
|
||||||
|
@ -1,66 +1,67 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
description: Map function without thisArg on strict mode
|
es6id: 22.1.2.1
|
||||||
info: >
|
description: Map function without thisArg on strict mode
|
||||||
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
info: >
|
||||||
|
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
||||||
...
|
|
||||||
10. Let len be ToLength(Get(arrayLike, "length")).
|
...
|
||||||
11. ReturnIfAbrupt(len).
|
10. Let len be ToLength(Get(arrayLike, "length")).
|
||||||
12. If IsConstructor(C) is true, then
|
11. ReturnIfAbrupt(len).
|
||||||
a. Let A be Construct(C, «len»).
|
12. If IsConstructor(C) is true, then
|
||||||
13. Else,
|
a. Let A be Construct(C, «len»).
|
||||||
b. Let A be ArrayCreate(len).
|
13. Else,
|
||||||
14. ReturnIfAbrupt(A).
|
b. Let A be ArrayCreate(len).
|
||||||
15. Let k be 0.
|
14. ReturnIfAbrupt(A).
|
||||||
16. Repeat, while k < len
|
15. Let k be 0.
|
||||||
a. Let Pk be ToString(k).
|
16. Repeat, while k < len
|
||||||
b. Let kValue be Get(arrayLike, Pk).
|
a. Let Pk be ToString(k).
|
||||||
c. ReturnIfAbrupt(kValue).
|
b. Let kValue be Get(arrayLike, Pk).
|
||||||
d. If mapping is true, then
|
c. ReturnIfAbrupt(kValue).
|
||||||
i. Let mappedValue be Call(mapfn, T, «kValue, k»).
|
d. If mapping is true, then
|
||||||
...
|
i. Let mappedValue be Call(mapfn, T, «kValue, k»).
|
||||||
flags: [onlyStrict]
|
...
|
||||||
---*/
|
flags: [onlyStrict]
|
||||||
|
---*/
|
||||||
var list = {
|
|
||||||
'0': 41,
|
var list = {
|
||||||
'1': 42,
|
'0': 41,
|
||||||
'2': 43,
|
'1': 42,
|
||||||
length: 3
|
'2': 43,
|
||||||
};
|
length: 3
|
||||||
var calls = [];
|
};
|
||||||
|
var calls = [];
|
||||||
function mapFn (value) {
|
|
||||||
calls.push({
|
function mapFn (value) {
|
||||||
args: arguments,
|
calls.push({
|
||||||
thisArg: this
|
args: arguments,
|
||||||
});
|
thisArg: this
|
||||||
return value * 2;
|
});
|
||||||
}
|
return value * 2;
|
||||||
|
}
|
||||||
var result = Array.from(list, mapFn);
|
|
||||||
|
var result = Array.from(list, mapFn);
|
||||||
assert.sameValue(result.length, 3, 'result.length');
|
|
||||||
assert.sameValue(result[0], 82, 'result[0]');
|
assert.sameValue(result.length, 3, 'result.length');
|
||||||
assert.sameValue(result[1], 84, 'result[1]');
|
assert.sameValue(result[0], 82, 'result[0]');
|
||||||
assert.sameValue(result[2], 86, 'result[2]');
|
assert.sameValue(result[1], 84, 'result[1]');
|
||||||
|
assert.sameValue(result[2], 86, 'result[2]');
|
||||||
assert.sameValue(calls.length, 3, 'calls.length');
|
|
||||||
|
assert.sameValue(calls.length, 3, 'calls.length');
|
||||||
assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length');
|
|
||||||
assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]');
|
assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length');
|
||||||
assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]');
|
assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]');
|
||||||
assert.sameValue(calls[0].thisArg, undefined, 'calls[0].thisArg');
|
assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]');
|
||||||
|
assert.sameValue(calls[0].thisArg, undefined, 'calls[0].thisArg');
|
||||||
assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length');
|
|
||||||
assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]');
|
assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length');
|
||||||
assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]');
|
assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]');
|
||||||
assert.sameValue(calls[1].thisArg, undefined, 'calls[1].thisArg');
|
assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]');
|
||||||
|
assert.sameValue(calls[1].thisArg, undefined, 'calls[1].thisArg');
|
||||||
assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length');
|
|
||||||
assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]');
|
assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length');
|
||||||
assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]');
|
assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]');
|
||||||
assert.sameValue(calls[2].thisArg, undefined, 'calls[2].thisArg');
|
assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]');
|
||||||
|
assert.sameValue(calls[2].thisArg, undefined, 'calls[2].thisArg');
|
||||||
|
@ -1,67 +1,68 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
description: Calling from with a valid map function with thisArg
|
es6id: 22.1.2.1
|
||||||
info: >
|
description: Calling from with a valid map function with thisArg
|
||||||
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
info: >
|
||||||
|
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
||||||
...
|
|
||||||
10. Let len be ToLength(Get(arrayLike, "length")).
|
...
|
||||||
11. ReturnIfAbrupt(len).
|
10. Let len be ToLength(Get(arrayLike, "length")).
|
||||||
12. If IsConstructor(C) is true, then
|
11. ReturnIfAbrupt(len).
|
||||||
a. Let A be Construct(C, «len»).
|
12. If IsConstructor(C) is true, then
|
||||||
13. Else,
|
a. Let A be Construct(C, «len»).
|
||||||
b. Let A be ArrayCreate(len).
|
13. Else,
|
||||||
14. ReturnIfAbrupt(A).
|
b. Let A be ArrayCreate(len).
|
||||||
15. Let k be 0.
|
14. ReturnIfAbrupt(A).
|
||||||
16. Repeat, while k < len
|
15. Let k be 0.
|
||||||
a. Let Pk be ToString(k).
|
16. Repeat, while k < len
|
||||||
b. Let kValue be Get(arrayLike, Pk).
|
a. Let Pk be ToString(k).
|
||||||
c. ReturnIfAbrupt(kValue).
|
b. Let kValue be Get(arrayLike, Pk).
|
||||||
d. If mapping is true, then
|
c. ReturnIfAbrupt(kValue).
|
||||||
i. Let mappedValue be Call(mapfn, T, «kValue, k»).
|
d. If mapping is true, then
|
||||||
...
|
i. Let mappedValue be Call(mapfn, T, «kValue, k»).
|
||||||
---*/
|
...
|
||||||
|
---*/
|
||||||
var list = {
|
|
||||||
'0': 41,
|
var list = {
|
||||||
'1': 42,
|
'0': 41,
|
||||||
'2': 43,
|
'1': 42,
|
||||||
length: 3
|
'2': 43,
|
||||||
};
|
length: 3
|
||||||
var calls = [];
|
};
|
||||||
var thisArg = {};
|
var calls = [];
|
||||||
|
var thisArg = {};
|
||||||
function mapFn (value) {
|
|
||||||
calls.push({
|
function mapFn (value) {
|
||||||
args: arguments,
|
calls.push({
|
||||||
thisArg: this
|
args: arguments,
|
||||||
});
|
thisArg: this
|
||||||
return value * 2;
|
});
|
||||||
}
|
return value * 2;
|
||||||
|
}
|
||||||
var result = Array.from(list, mapFn, thisArg);
|
|
||||||
|
var result = Array.from(list, mapFn, thisArg);
|
||||||
assert.sameValue(result.length, 3, 'result.length');
|
|
||||||
assert.sameValue(result[0], 82, 'result[0]');
|
assert.sameValue(result.length, 3, 'result.length');
|
||||||
assert.sameValue(result[1], 84, 'result[1]');
|
assert.sameValue(result[0], 82, 'result[0]');
|
||||||
assert.sameValue(result[2], 86, 'result[2]');
|
assert.sameValue(result[1], 84, 'result[1]');
|
||||||
|
assert.sameValue(result[2], 86, 'result[2]');
|
||||||
assert.sameValue(calls.length, 3, 'calls.length');
|
|
||||||
|
assert.sameValue(calls.length, 3, 'calls.length');
|
||||||
assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length');
|
|
||||||
assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]');
|
assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length');
|
||||||
assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]');
|
assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]');
|
||||||
assert.sameValue(calls[0].thisArg, thisArg, 'calls[0].thisArg');
|
assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]');
|
||||||
|
assert.sameValue(calls[0].thisArg, thisArg, 'calls[0].thisArg');
|
||||||
assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length');
|
|
||||||
assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]');
|
assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length');
|
||||||
assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]');
|
assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]');
|
||||||
assert.sameValue(calls[1].thisArg, thisArg, 'calls[1].thisArg');
|
assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]');
|
||||||
|
assert.sameValue(calls[1].thisArg, thisArg, 'calls[1].thisArg');
|
||||||
assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length');
|
|
||||||
assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]');
|
assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length');
|
||||||
assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]');
|
assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]');
|
||||||
assert.sameValue(calls[2].thisArg, thisArg, 'calls[2].thisArg');
|
assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]');
|
||||||
|
assert.sameValue(calls[2].thisArg, thisArg, 'calls[2].thisArg');
|
||||||
|
@ -1,37 +1,38 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Elements added after the call to from
|
description: Elements added after the call to from
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var arrayIndex = -1;
|
|
||||||
var originalLength = 7;
|
var arrayIndex = -1;
|
||||||
var obj = {
|
var originalLength = 7;
|
||||||
length: originalLength,
|
var obj = {
|
||||||
0: 2,
|
length: originalLength,
|
||||||
1: 4,
|
0: 2,
|
||||||
2: 8,
|
1: 4,
|
||||||
3: 16,
|
2: 8,
|
||||||
4: 32,
|
3: 16,
|
||||||
5: 64,
|
4: 32,
|
||||||
6: 128
|
5: 64,
|
||||||
};
|
6: 128
|
||||||
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
};
|
||||||
function mapFn(value, index) {
|
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
||||||
arrayIndex++;
|
function mapFn(value, index) {
|
||||||
assert.sameValue(value, obj[arrayIndex], "Value mismatch in mapFn at index " + index + ".");
|
arrayIndex++;
|
||||||
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
|
assert.sameValue(value, obj[arrayIndex], "Value mismatch in mapFn at index " + index + ".");
|
||||||
obj[originalLength + arrayIndex] = 2 * arrayIndex + 1;
|
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
|
||||||
|
obj[originalLength + arrayIndex] = 2 * arrayIndex + 1;
|
||||||
return obj[arrayIndex];
|
|
||||||
}
|
return obj[arrayIndex];
|
||||||
|
}
|
||||||
|
|
||||||
var a = Array.from(obj, mapFn);
|
|
||||||
assert.sameValue(a.length, array.length, "Length mismatch.");
|
var a = Array.from(obj, mapFn);
|
||||||
|
assert.sameValue(a.length, array.length, "Length mismatch.");
|
||||||
for (var j = 0; j < a.length; j++) {
|
|
||||||
assert.sameValue(a[j], array[j], "Element mismatch for array at index " + j + ".");
|
for (var j = 0; j < a.length; j++) {
|
||||||
}
|
assert.sameValue(a[j], array[j], "Element mismatch for array at index " + j + ".");
|
||||||
|
}
|
||||||
|
@ -1,31 +1,32 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
description: >
|
||||||
Elements deleted after the call started and before visited are not
|
Elements deleted after the call started and before visited are not
|
||||||
visited
|
visited
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var originalArray = [ 0, 1, -2, 4, -8, 16 ];
|
|
||||||
var array = [ 0, 1, -2, 4, -8, 16 ];
|
var originalArray = [ 0, 1, -2, 4, -8, 16 ];
|
||||||
var a = [];
|
var array = [ 0, 1, -2, 4, -8, 16 ];
|
||||||
var arrayIndex = -1;
|
var a = [];
|
||||||
function mapFn(value, index) {
|
var arrayIndex = -1;
|
||||||
this.arrayIndex++;
|
function mapFn(value, index) {
|
||||||
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
|
this.arrayIndex++;
|
||||||
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
|
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
|
||||||
|
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
|
||||||
array.splice(array.length - 1, 1);
|
|
||||||
return 127;
|
array.splice(array.length - 1, 1);
|
||||||
}
|
return 127;
|
||||||
|
}
|
||||||
|
|
||||||
a = Array.from(array, mapFn, this);
|
|
||||||
|
a = Array.from(array, mapFn, this);
|
||||||
assert.sameValue(a.length, originalArray.length / 2, "Length mismatch. Old array : " + (originalArray.length / 2) + ". array : " + a.length + ".");
|
|
||||||
|
assert.sameValue(a.length, originalArray.length / 2, "Length mismatch. Old array : " + (originalArray.length / 2) + ". array : " + a.length + ".");
|
||||||
for (var j = 0; j < originalArray.length / 2; j++) {
|
|
||||||
assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + ".");
|
for (var j = 0; j < originalArray.length / 2; j++) {
|
||||||
}
|
assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + ".");
|
||||||
|
}
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Elements are updated after the call to from
|
description: Elements are updated after the call to from
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [ 127, 4, 8, 16, 32, 64, 128 ];
|
|
||||||
var arrayIndex = -1;
|
var array = [ 127, 4, 8, 16, 32, 64, 128 ];
|
||||||
function mapFn(value, index) {
|
var arrayIndex = -1;
|
||||||
arrayIndex++;
|
function mapFn(value, index) {
|
||||||
if (index + 1 < array.length) {
|
arrayIndex++;
|
||||||
array[index + 1] = 127;
|
if (index + 1 < array.length) {
|
||||||
}
|
array[index + 1] = 127;
|
||||||
assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + ".");
|
}
|
||||||
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
|
assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + ".");
|
||||||
|
assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
|
||||||
return value;
|
|
||||||
}
|
return value;
|
||||||
|
}
|
||||||
var a = Array.from(array, mapFn);
|
|
||||||
assert.sameValue(a.length, array.length, "Length mismatch.");
|
var a = Array.from(array, mapFn);
|
||||||
for (var j = 0; j < a.length; j++) {
|
assert.sameValue(a.length, array.length, "Length mismatch.");
|
||||||
assert.sameValue(a[j], 127, "Element mismatch for mapped array.");
|
for (var j = 0; j < a.length; j++) {
|
||||||
}
|
assert.sameValue(a[j], 127, "Element mismatch for mapped array.");
|
||||||
|
}
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Passing a valid array
|
description: Passing a valid array
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [0, 'foo', , Infinity];
|
|
||||||
var result = Array.from(array);
|
var array = [0, 'foo', , Infinity];
|
||||||
|
var result = Array.from(array);
|
||||||
assert.sameValue(result.length, 4, 'result.length');
|
|
||||||
assert.sameValue(result[0], 0, 'result[0]');
|
assert.sameValue(result.length, 4, 'result.length');
|
||||||
assert.sameValue(result[1], 'foo', 'result[1]');
|
assert.sameValue(result[0], 0, 'result[0]');
|
||||||
assert.sameValue(result[2], undefined, 'result[2]');
|
assert.sameValue(result[1], 'foo', 'result[1]');
|
||||||
assert.sameValue(result[3], Infinity, 'result[3]');
|
assert.sameValue(result[2], undefined, 'result[2]');
|
||||||
|
assert.sameValue(result[3], Infinity, 'result[3]');
|
||||||
assert.notSameValue(
|
|
||||||
result, array,
|
assert.notSameValue(
|
||||||
'result is not the object from items argument'
|
result, array,
|
||||||
);
|
'result is not the object from items argument'
|
||||||
|
);
|
||||||
assert(result instanceof Array, 'result instanceof Array');
|
|
||||||
|
assert(result instanceof Array, 'result instanceof Array');
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: 22.1.2.1_T1
|
esid: sec-array.from
|
||||||
|
es6id: 22.1.2.1
|
||||||
description: Testing Array.from when passed a String
|
description: Testing Array.from when passed a String
|
||||||
author: Hank Yates (hankyates@gmail.com)
|
author: Hank Yates (hankyates@gmail.com)
|
||||||
---*/
|
---*/
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error accessing items' `Symbol.iterator` attribute
|
description: Error accessing items' `Symbol.iterator` attribute
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright 2015 Leonardo Balter. All rights reserved.
|
// Copyright 2015 Leonardo Balter. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Return empty array if items argument is an ArrayBuffer
|
description: Return empty array if items argument is an ArrayBuffer
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright 2015 Leonardo Balter. All rights reserved.
|
// Copyright 2015 Leonardo Balter. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Throws a TypeError if items argument is null
|
description: Throws a TypeError if items argument is null
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error advancing iterator
|
description: Error advancing iterator
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
Error creating object with custom constructor (traversed via iterator)
|
Error creating object with custom constructor (traversed via iterator)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Creating object with custom constructor (traversed via iterator)
|
description: Creating object with custom constructor (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error creating iterator object
|
description: Error creating iterator object
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error retrieving value of iterator result
|
description: Error retrieving value of iterator result
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
Arguments of mapping function (traversed via iterator)
|
Arguments of mapping function (traversed via iterator)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error invoking map function (traversed via iterator)
|
description: Error invoking map function (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Value returned by mapping function (traversed via iterator)
|
description: Value returned by mapping function (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
`this` value of mapping function with custom `this` argument (traversed via iterator)
|
`this` value of mapping function with custom `this` argument (traversed via iterator)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
`this` value of mapping function in non-strict mode (traversed via iterator)
|
`this` value of mapping function in non-strict mode (traversed via iterator)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: >
|
description: >
|
||||||
`this` value of mapping function in strict mode (traversed via iterator)
|
`this` value of mapping function in strict mode (traversed via iterator)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error setting property on result value (traversed via iterator)
|
description: Error setting property on result value (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Setting property on result value (traversed via iterator)
|
description: Setting property on result value (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Error setting length of object (traversed via iterator)
|
description: Error setting length of object (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Setting length of object (traversed via iterator)
|
description: Setting length of object (traversed via iterator)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,34 +1,35 @@
|
|||||||
// Copyright 2015 Leonardo Balter. All rights reserved.
|
// Copyright 2015 Leonardo Balter. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
description: Throws a TypeError if mapFn is not callable
|
es6id: 22.1.2.1
|
||||||
info: >
|
description: Throws a TypeError if mapFn is not callable
|
||||||
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
info: >
|
||||||
|
22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] )
|
||||||
...
|
|
||||||
2. If mapfn is undefined, let mapping be false.
|
...
|
||||||
3. else
|
2. If mapfn is undefined, let mapping be false.
|
||||||
a. If IsCallable(mapfn) is false, throw a TypeError exception.
|
3. else
|
||||||
...
|
a. If IsCallable(mapfn) is false, throw a TypeError exception.
|
||||||
---*/
|
...
|
||||||
|
---*/
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Array.from([], null);
|
assert.throws(TypeError, function() {
|
||||||
});
|
Array.from([], null);
|
||||||
|
});
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Array.from([], {});
|
assert.throws(TypeError, function() {
|
||||||
});
|
Array.from([], {});
|
||||||
|
});
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Array.from([], 'string');
|
assert.throws(TypeError, function() {
|
||||||
});
|
Array.from([], 'string');
|
||||||
|
});
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Array.from([], true);
|
assert.throws(TypeError, function() {
|
||||||
});
|
Array.from([], true);
|
||||||
|
});
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Array.from([], 42);
|
assert.throws(TypeError, function() {
|
||||||
});
|
Array.from([], 42);
|
||||||
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright 2015 Leonardo Balter. All rights reserved.
|
// Copyright 2015 Leonardo Balter. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
|
esid: sec-array.from
|
||||||
es6id: 22.1.2.1
|
es6id: 22.1.2.1
|
||||||
description: Throws a TypeError if mapFn is not callable (Symbol)
|
description: Throws a TypeError if mapFn is not callable (Symbol)
|
||||||
info: >
|
info: >
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: mapFn throws an exception
|
description: mapFn throws an exception
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
|
||||||
function mapFn(value, index, obj) {
|
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
||||||
throw new Test262Error();
|
function mapFn(value, index, obj) {
|
||||||
}
|
throw new Test262Error();
|
||||||
|
}
|
||||||
assert.throws(Test262Error, function(){Array.from(array, mapFn);});
|
|
||||||
|
assert.throws(Test262Error, function(){Array.from(array, mapFn);});
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Source array with boundary values
|
description: Source array with boundary values
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [ Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY ];
|
|
||||||
var arrayIndex = -1;
|
var array = [ Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY ];
|
||||||
function mapFn(value, index) {
|
var arrayIndex = -1;
|
||||||
this.arrayIndex++;
|
function mapFn(value, index) {
|
||||||
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
|
this.arrayIndex++;
|
||||||
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
|
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + ".");
|
||||||
|
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn.");
|
||||||
return value;
|
|
||||||
}
|
return value;
|
||||||
|
}
|
||||||
var a = Array.from(array, mapFn, this);
|
|
||||||
|
var a = Array.from(array, mapFn, this);
|
||||||
assert.sameValue(a.length, array.length, "Length mismatch.");
|
|
||||||
assert.sameValue(a[0], Number.MAX_VALUE, "Element mismatch for mapped array at index 0.");
|
assert.sameValue(a.length, array.length, "Length mismatch.");
|
||||||
assert.sameValue(a[1], Number.MIN_VALUE, "Element mismatch for mapped array at index 1.");
|
assert.sameValue(a[0], Number.MAX_VALUE, "Element mismatch for mapped array at index 0.");
|
||||||
assert.sameValue(a[2], Number.NaN, "Element mismatch for mapped array at index 2.");
|
assert.sameValue(a[1], Number.MIN_VALUE, "Element mismatch for mapped array at index 1.");
|
||||||
assert.sameValue(a[3], Number.NEGATIVE_INFINITY, "Element mismatch for mapped array at index 3.");
|
assert.sameValue(a[2], Number.NaN, "Element mismatch for mapped array at index 2.");
|
||||||
assert.sameValue(a[4], Number.POSITIVE_INFINITY, "Element mismatch for mapped array at index 4.");
|
assert.sameValue(a[3], Number.NEGATIVE_INFINITY, "Element mismatch for mapped array at index 3.");
|
||||||
|
assert.sameValue(a[4], Number.POSITIVE_INFINITY, "Element mismatch for mapped array at index 4.");
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
description: >
|
||||||
Array.from uses a constructor other than Array.
|
Array.from uses a constructor other than Array.
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
assert.sameValue(Array.from.call(Object, []).constructor, Object);
|
|
||||||
|
assert.sameValue(Array.from.call(Object, []).constructor, Object);
|
||||||
|
@ -1,28 +1,29 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Source object has iterator which throws
|
description: Source object has iterator which throws
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
|
||||||
var obj = {
|
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
||||||
[Symbol.iterator]() {
|
var obj = {
|
||||||
return {
|
[Symbol.iterator]() {
|
||||||
index: 0,
|
return {
|
||||||
next() {
|
index: 0,
|
||||||
throw new Test262Error();
|
next() {
|
||||||
},
|
throw new Test262Error();
|
||||||
isDone : false,
|
},
|
||||||
get val() {
|
isDone : false,
|
||||||
this.index++;
|
get val() {
|
||||||
if (this.index > 7) {
|
this.index++;
|
||||||
this.isDone = true;
|
if (this.index > 7) {
|
||||||
}
|
this.isDone = true;
|
||||||
return 1 << this.index;
|
}
|
||||||
}
|
return 1 << this.index;
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
assert.throws(Test262Error, function(){Array.from(obj);});
|
};
|
||||||
|
assert.throws(Test262Error, function(){Array.from(obj);});
|
||||||
|
@ -1,35 +1,36 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Source object has iterator
|
description: Source object has iterator
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
|
||||||
var obj = {
|
var array = [ 2, 4, 8, 16, 32, 64, 128 ];
|
||||||
[Symbol.iterator]() {
|
var obj = {
|
||||||
return {
|
[Symbol.iterator]() {
|
||||||
index: 0,
|
return {
|
||||||
next() {
|
index: 0,
|
||||||
return {
|
next() {
|
||||||
value: this.val,
|
return {
|
||||||
done: this.isDone
|
value: this.val,
|
||||||
};
|
done: this.isDone
|
||||||
},
|
};
|
||||||
isDone : false,
|
},
|
||||||
get val() {
|
isDone : false,
|
||||||
this.index++;
|
get val() {
|
||||||
if (this.index > 7) {
|
this.index++;
|
||||||
this.isDone = true;
|
if (this.index > 7) {
|
||||||
}
|
this.isDone = true;
|
||||||
return 1 << this.index;
|
}
|
||||||
}
|
return 1 << this.index;
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
var a = Array.from.call(Object, obj);
|
};
|
||||||
assert.sameValue(typeof a, typeof {}, "The returned type is expected to be object.");
|
var a = Array.from.call(Object, obj);
|
||||||
for (var j = 0; j < a.length; j++) {
|
assert.sameValue(typeof a, typeof {}, "The returned type is expected to be object.");
|
||||||
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
|
for (var j = 0; j < a.length; j++) {
|
||||||
}
|
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
|
||||||
|
}
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
description: >
|
||||||
Source is an object with length property and one item is deleted
|
Source is an object with length property and one item is deleted
|
||||||
from the source
|
from the source
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [2, 4, 0, 16];
|
|
||||||
var expectedArray = [2, 4, , 16];
|
var array = [2, 4, 0, 16];
|
||||||
var obj = {
|
var expectedArray = [2, 4, , 16];
|
||||||
length : 4,
|
var obj = {
|
||||||
0 : 2,
|
length : 4,
|
||||||
1 : 4,
|
0 : 2,
|
||||||
2 : 0,
|
1 : 4,
|
||||||
3 : 16
|
2 : 0,
|
||||||
};
|
3 : 16
|
||||||
delete obj[2];
|
};
|
||||||
var a = Array.from(obj);
|
delete obj[2];
|
||||||
for (var j = 0; j < expectedArray.length; j++) {
|
var a = Array.from(obj);
|
||||||
assert.sameValue(a[j], expectedArray[j], "Elements mismatch at " + j + ".");
|
for (var j = 0; j < expectedArray.length; j++) {
|
||||||
}
|
assert.sameValue(a[j], expectedArray[j], "Elements mismatch at " + j + ".");
|
||||||
|
}
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Source is an object with missing values
|
description: Source is an object with missing values
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var array = [2, 4, , 16];
|
|
||||||
var obj = {
|
var array = [2, 4, , 16];
|
||||||
length: 4,
|
var obj = {
|
||||||
0: 2,
|
length: 4,
|
||||||
1: 4,
|
0: 2,
|
||||||
3: 16
|
1: 4,
|
||||||
};
|
3: 16
|
||||||
|
};
|
||||||
var a = Array.from.call(Object, obj);
|
|
||||||
assert.sameValue(typeof a, "object", "The returned type is expected to be object.");
|
var a = Array.from.call(Object, obj);
|
||||||
for (var j = 0; j < a.length; j++) {
|
assert.sameValue(typeof a, "object", "The returned type is expected to be object.");
|
||||||
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
|
for (var j = 0; j < a.length; j++) {
|
||||||
}
|
assert.sameValue(a[j], array[j], "Elements mismatch at " + j + ".");
|
||||||
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Source is an object without length property
|
description: Source is an object without length property
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
---*/
|
es6id: 22.1.2.1
|
||||||
|
---*/
|
||||||
var obj = {
|
|
||||||
0: 2,
|
var obj = {
|
||||||
1: 4,
|
0: 2,
|
||||||
2: 8,
|
1: 4,
|
||||||
3: 16
|
2: 8,
|
||||||
}
|
3: 16
|
||||||
|
}
|
||||||
var a = Array.from(obj);
|
|
||||||
assert.sameValue(a.length, 0, "Expected an array of length 0.");
|
var a = Array.from(obj);
|
||||||
|
assert.sameValue(a.length, 0, "Expected an array of length 0.");
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// Copyright 2015 Leonardo Balter. All rights reserved.
|
// Copyright 2015 Leonardo Balter. All rights reserved.
|
||||||
// This code is governed by the license found in the LICENSE file.
|
// This code is governed by the license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 22.1.2.1
|
esid: sec-array.from
|
||||||
description: Does not throw if this is null
|
es6id: 22.1.2.1
|
||||||
---*/
|
description: Does not throw if this is null
|
||||||
|
---*/
|
||||||
var result = Array.from.call(null, []);
|
|
||||||
|
var result = Array.from.call(null, []);
|
||||||
assert(result instanceof Array, 'Does not throw if this is null');
|
|
||||||
assert.sameValue(result.length, 0, 'result.length');
|
assert(result instanceof Array, 'Does not throw if this is null');
|
||||||
|
assert.sameValue(result.length, 0, 'result.length');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user