mirror of https://github.com/tc39/test262.git
Adding test for Array.from
This commit is contained in:
parent
262ce4d0d8
commit
7edb891fff
|
@ -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;
|
||||||
|
});
|
|
@ -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;
|
||||||
|
|
||||||
|
});
|
|
@ -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…
Reference in New Issue