Rename & merge "this not callable" tests

This commit is contained in:
Aleksey Shvayka 2019-05-15 01:36:22 +03:00
parent 9c93e05d90
commit 385848d449
5 changed files with 28 additions and 59 deletions

View File

@ -1,11 +0,0 @@
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.3.4.3_A13
description: If IsCallable(func) is false, then throw a TypeError exception.
---*/
assert.throws(TypeError, function() {
Function.prototype.apply.call(undefined, {}, []);
});

View File

@ -1,11 +0,0 @@
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.3.4.3_A14
description: If IsCallable(func) is false, then throw a TypeError exception.
---*/
assert.throws(TypeError, function() {
Function.prototype.apply.call(null, {}, []);
});

View File

@ -1,11 +0,0 @@
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.3.4.3_A15
description: If IsCallable(func) is false, then throw a TypeError exception.
---*/
assert.throws(TypeError, function() {
Function.prototype.apply.call({}, {}, []);
});

View File

@ -1,26 +0,0 @@
// Copyright 2011 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: If IsCallable(func) is false, then throw a TypeError exception.
es5id: 15.3.4.3_A16
description: >
A RegExp is not a function, but it may be callable. Iff it is,
it's typeof should be 'function', in which case apply should
accept it as a valid this value.
---*/
var re = (/x/);
if (typeof re === 'function') {
Function.prototype.apply.call(re, undefined, ['x']);
} else {
try {
Function.prototype.bind.call(re, undefined);
$ERROR('#1: If IsCallable(func) is false, ' +
'then (bind should) throw a TypeError exception');
} catch (e) {
if (!(e instanceof TypeError)) {
$ERROR('#1: TypeError expected. Actual: ' + e);
}
}
}

View File

@ -0,0 +1,28 @@
// 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 this value is not callable
info: |
Function.prototype.apply ( thisArg, argArray )
1. Let func be the this value.
2. If IsCallable(func) is false, throw a TypeError exception.
---*/
assert.throws(TypeError, function() {
Function.prototype.apply.call(undefined, {}, []);
});
assert.throws(TypeError, function() {
Function.prototype.apply.call(null, {}, []);
});
assert.throws(TypeError, function() {
Function.prototype.apply.call({}, {}, []);
});
assert.throws(TypeError, function() {
Function.prototype.apply.call(/re/, {}, []);
});