Rename & merge "argArray not object" tests

This commit is contained in:
Aleksey Shvayka 2019-05-14 23:07:23 +03:00
parent 8c1819484e
commit 171b3ef083
3 changed files with 35 additions and 42 deletions

View File

@ -1,20 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: |
if argArray is neither an array nor an arguments object (see 10.1.8), a
TypeError exception is thrown
es5id: 15.3.4.3_A6_T2
description: argArray is (null,1)
---*/
//CHECK#1
try {
Function().apply(null, 1);
$ERROR('#1: if argArray is neither an array nor an arguments object (see 10.1.8), a TypeError exception is thrown');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: if argArray is neither an array nor an arguments object (see 10.1.8), a TypeError exception is thrown');
}
}

View File

@ -1,22 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: |
if argArray is neither an array nor an arguments object (see 10.1.8), a
TypeError exception is thrown
es5id: 15.3.4.3_A6_T3
description: argArray is (object,"1,3,4")
---*/
var obj = {};
//CHECK#1
try {
Function().apply(obj, "1,3,4");
$ERROR('#1: if argArray is neither an array nor an arguments object (see 10.1.8), a TypeError exception is thrown');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1.1: if argArray is neither an array nor an arguments object (see 10.1.8), a TypeError exception is thrown');
}
}

View File

@ -0,0 +1,35 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function.prototype.apply
description: >
Throws a TypeError exception if argArray is not an object
info: |
Function.prototype.apply ( thisArg, argArray )
[...]
4. Let argList be ? CreateListFromArrayLike(argArray).
CreateListFromArrayLike ( obj [ , elementTypes ] )
[...]
2. If Type(obj) is not Object, throw a TypeError exception.
---*/
function fn() {}
assert.throws(TypeError, function() {
fn.apply(null, true);
});
assert.throws(TypeError, function() {
fn.apply(null, NaN);
});
assert.throws(TypeError, function() {
fn.apply(null, '1,2,3');
});
assert.throws(TypeError, function() {
fn.apply(null, Symbol());
});