mirror of
https://github.com/tc39/test262.git
synced 2025-07-03 20:24:38 +02:00
Adding test for Array.from
This commit is contained in:
parent
262ce4d0d8
commit
7edb891fff
18
test/suite/es6/ch22/22.1/22.1.2/S22.1.2.1_T1.js
Normal file
18
test/suite/es6/ch22/22.1/22.1.2/S22.1.2.1_T1.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (c) 2014 Hank Yates. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @description Testing Array.from when passed a String
|
||||||
|
* @author Hank Yates (hankyates@gmail.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
runTestCase(function () {
|
||||||
|
var arrLikeSource = 'testValue',
|
||||||
|
testArr = Array.from(arrLikeSource);
|
||||||
|
|
||||||
|
if (testArr.length != 9) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
23
test/suite/es6/ch22/22.1/22.1.2/S22.1.2.1_T2.js
Normal file
23
test/suite/es6/ch22/22.1/22.1.2/S22.1.2.1_T2.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2014 Hank Yates. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @description Testing Array.from when passed an Object is passed
|
||||||
|
* @author Hank Yates (hankyates@gmail.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
runTestCase(function () {
|
||||||
|
var testArr = Array.from({
|
||||||
|
'a': 1,
|
||||||
|
'b': '2',
|
||||||
|
'c': 'three',
|
||||||
|
'length': '3'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (testArr.length != 3) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
});
|
19
test/suite/es6/ch22/22.1/22.1.2/S22.1.2.1_T3.js
Normal file
19
test/suite/es6/ch22/22.1/22.1.2/S22.1.2.1_T3.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) 2014 Hank Yates. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @description Testing Array.from when passed an undefined
|
||||||
|
* @author Hank Yates (hankyates@gmail.com)
|
||||||
|
* /
|
||||||
|
|
||||||
|
runTestCase(function () {
|
||||||
|
try {
|
||||||
|
Array.from(undefined);
|
||||||
|
} catch (e) {
|
||||||
|
return e instanceof TypeError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user