mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Merge pull request #5 from hankyates/array-from-tests
* array-from-tests: Adding test for Array.from
This commit is contained in:
commit
5278df4721
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