Adding test for Array.from

This commit is contained in:
Hank Yates 2014-07-14 05:15:05 +00:00 committed by Brian Terlson
parent 262ce4d0d8
commit 7edb891fff
3 changed files with 60 additions and 0 deletions

View 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;
});

View 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;
});

View 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;
});