mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Add tests for Array methods throwing with string receiver. (#2463)
This commit is contained in:
parent
6e4d442cc6
commit
623e9d199a
test/built-ins/Array/prototype
29
test/built-ins/Array/prototype/pop/throws-with-string-receiver.js
vendored
Normal file
29
test/built-ins/Array/prototype/pop/throws-with-string-receiver.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-array.prototype.pop
|
||||
description: >
|
||||
Array#pop throws TypeError upon attempting to modify a string
|
||||
info: |
|
||||
Array.prototype.pop ( )
|
||||
...
|
||||
3. If len is zero, then
|
||||
a. Perform ? Set(O, "length", 0, true).
|
||||
...
|
||||
4. Else,
|
||||
...
|
||||
f. Perform ? Set(O, "length", newLen, true).
|
||||
|
||||
Set ( O, P, V, Throw )
|
||||
...
|
||||
4. Let success be ? O.[[Set]](P, V, O).
|
||||
5. If success is false and Throw is true, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.pop.call('');
|
||||
}, "Array.prototype.pop.call('')");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.pop.call('abc');
|
||||
}, "Array.prototype.pop.call('abc')");
|
36
test/built-ins/Array/prototype/push/throws-with-string-receiver.js
vendored
Normal file
36
test/built-ins/Array/prototype/push/throws-with-string-receiver.js
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-array.prototype.push
|
||||
description: >
|
||||
Array#push throws TypeError upon attempting to modify a string
|
||||
info: |
|
||||
Array.prototype.push ( ...items )
|
||||
...
|
||||
6. Repeat, while items is not empty
|
||||
...
|
||||
b. Perform ? Set(O, ! ToString(len), E, true).
|
||||
...
|
||||
7. Perform ? Set(O, "length", len, true).
|
||||
|
||||
Set ( O, P, V, Throw )
|
||||
...
|
||||
4. Let success be ? O.[[Set]](P, V, O).
|
||||
5. If success is false and Throw is true, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.push.call('');
|
||||
}, "Array.prototype.push.call('')");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.push.call('', 1);
|
||||
}, "Array.prototype.push.call('', 1)");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.push.call('abc');
|
||||
}, "Array.prototype.push.call('abc')");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.push.call('abc', 1);
|
||||
}, "Array.prototype.push.call('abc', 1)");
|
27
test/built-ins/Array/prototype/shift/throws-with-string-receiver.js
vendored
Normal file
27
test/built-ins/Array/prototype/shift/throws-with-string-receiver.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-array.prototype.shift
|
||||
description: >
|
||||
Array#shift throws TypeError upon attempting to modify a string
|
||||
info: |
|
||||
Array.prototype.shift ( )
|
||||
...
|
||||
3. If len is zero, then
|
||||
a. Perform ? Set(O, "length", 0, true).
|
||||
...
|
||||
8. Perform ? Set(O, "length", len - 1, true).
|
||||
|
||||
Set ( O, P, V, Throw )
|
||||
...
|
||||
4. Let success be ? O.[[Set]](P, V, O).
|
||||
5. If success is false and Throw is true, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.shift.call('');
|
||||
}, "Array.prototype.shift.call('')");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.shift.call('abc');
|
||||
}, "Array.prototype.shift.call('abc')");
|
45
test/built-ins/Array/prototype/unshift/throws-with-string-receiver.js
vendored
Normal file
45
test/built-ins/Array/prototype/unshift/throws-with-string-receiver.js
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-array.prototype.unshift
|
||||
description: >
|
||||
Array#unshift throws TypeError upon attempting to modify a string
|
||||
info: |
|
||||
Array.prototype.unshift ( ...items )
|
||||
...
|
||||
4. If argCount > 0, then
|
||||
...
|
||||
c. Repeat, while k > 0,
|
||||
...
|
||||
iv. If fromPresent is true, then
|
||||
...
|
||||
2. Perform ? Set(O, to, fromValue, true).
|
||||
...
|
||||
...
|
||||
f. Repeat, while items is not empty
|
||||
...
|
||||
Perform ? Set(O, ! ToString(j), E, true).
|
||||
...
|
||||
5. Perform ? Set(O, "length", len + argCount, true).
|
||||
|
||||
Set ( O, P, V, Throw )
|
||||
...
|
||||
4. Let success be ? O.[[Set]](P, V, O).
|
||||
5. If success is false and Throw is true, throw a TypeError exception.
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.unshift.call('');
|
||||
}, "Array.prototype.unshift.call('')");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.unshift.call('', 1);
|
||||
}, "Array.prototype.unshift.call('', 1)");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.unshift.call('abc');
|
||||
}, "Array.prototype.unshift.call('abc')");
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
Array.prototype.unshift.call('abc', 1);
|
||||
}, "Array.prototype.unshift.call('abc', 1)");
|
Loading…
x
Reference in New Issue
Block a user