mirror of
https://github.com/tc39/test262.git
synced 2025-05-30 19:50:28 +02:00
fix delete test, add error tests, fix lint (#2453)
This commit is contained in:
parent
19fd4bea79
commit
502cc20010
18
test/built-ins/Error/prototype/toString/invalid-receiver.js
vendored
Normal file
18
test/built-ins/Error/prototype/toString/invalid-receiver.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2019 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-error.prototype.tostring
|
||||||
|
description: >
|
||||||
|
Error.prototype.toString throws if its receiver is not an object.
|
||||||
|
info: |
|
||||||
|
Error.prototype.toString ( )
|
||||||
|
1. Let O be this value.
|
||||||
|
2. If Type(O) is not Object, throw a TypeError exception.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
[undefined, null, 1, true, 'string', Symbol()].forEach((v) => {
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Error.prototype.toString.call(v);
|
||||||
|
}, `Error.prototype.toString.call(${String(v)})`);
|
||||||
|
});
|
20
test/built-ins/Error/prototype/toString/undefined-props.js
vendored
Normal file
20
test/built-ins/Error/prototype/toString/undefined-props.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (C) 2019 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-error.prototype.tostring
|
||||||
|
description: >
|
||||||
|
Error.prototype.toString handles this.name and this.message being undefined.
|
||||||
|
info: |
|
||||||
|
Error.prototype.toString ( )
|
||||||
|
...
|
||||||
|
3. Let name be ? Get(O, "name").
|
||||||
|
4. If name is undefined, set name to "Error"; otherwise set name to ? ToString(name).
|
||||||
|
5. Let msg be ? Get(O, "message").
|
||||||
|
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(Error.prototype.toString.call({}), 'Error');
|
||||||
|
assert.sameValue(Error.prototype.toString.call({ message: '42' }), 'Error: 42');
|
||||||
|
assert.sameValue(Error.prototype.toString.call({ name: '24' }), '24');
|
||||||
|
assert.sameValue(Error.prototype.toString.call({ name: '24', message: '42' }), '24: 42');
|
28
test/built-ins/Object/freeze/throws-when-false.js
Normal file
28
test/built-ins/Object/freeze/throws-when-false.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2019 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-object.freeze
|
||||||
|
description: >
|
||||||
|
Object.freeze throws if SetIntegrityLevel(O, frozen) returns false.
|
||||||
|
info: |
|
||||||
|
Object.freeze ( O )
|
||||||
|
...
|
||||||
|
2. Let status be ? SetIntegrityLevel(O, frozen).
|
||||||
|
3. If status is false, throw a TypeError exception.
|
||||||
|
|
||||||
|
SetIntegrityLevel ( O, level )
|
||||||
|
...
|
||||||
|
3. Let status be ? O.[[PreventExtensions]]().
|
||||||
|
4. If status is false, return false.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const p = new Proxy({}, {
|
||||||
|
preventExtensions() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Object.freeze(p);
|
||||||
|
});
|
23
test/built-ins/Object/preventExtensions/throws-when-false.js
Normal file
23
test/built-ins/Object/preventExtensions/throws-when-false.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2019 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-object.preventextensions
|
||||||
|
description: >
|
||||||
|
Object.preventExtensions throws if O.[[PreventExtensions]]() returns false.
|
||||||
|
info: |
|
||||||
|
Object.preventExtensions ( O )
|
||||||
|
...
|
||||||
|
2. Let status be ? O.[[PreventExtensions]]().
|
||||||
|
3. If status is false, throw a TypeError exception.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const p = new Proxy({}, {
|
||||||
|
preventExtensions() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Object.preventExtensions(p);
|
||||||
|
});
|
28
test/built-ins/Object/seal/throws-when-false.js
Normal file
28
test/built-ins/Object/seal/throws-when-false.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2019 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-object.seal
|
||||||
|
description: >
|
||||||
|
Object.seal throws if SetIntegrityLevel(O, sealed) returns false.
|
||||||
|
info: |
|
||||||
|
Object.seal ( O )
|
||||||
|
...
|
||||||
|
2. Let status be ? SetIntegrityLevel(O, sealed).
|
||||||
|
3. If status is false, throw a TypeError exception.
|
||||||
|
|
||||||
|
SetIntegrityLevel ( O, level )
|
||||||
|
...
|
||||||
|
3. Let status be ? O.[[PreventExtensions]]().
|
||||||
|
4. If status is false, return false.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const p = new Proxy({}, {
|
||||||
|
preventExtensions() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Object.seal(p);
|
||||||
|
});
|
@ -5,7 +5,7 @@ es6id: 26.1.10
|
|||||||
description: >
|
description: >
|
||||||
Throws a TypeError if target is not an Object.
|
Throws a TypeError if target is not an Object.
|
||||||
info: |
|
info: |
|
||||||
26.1.10 Reflect.isExtensible (target)
|
26.1.11 Reflect.preventExtensions ( target )
|
||||||
|
|
||||||
1. If Type(target) is not Object, throw a TypeError exception.
|
1. If Type(target) is not Object, throw a TypeError exception.
|
||||||
...
|
...
|
||||||
@ -13,17 +13,17 @@ features: [Reflect]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Reflect.isExtensible(1);
|
Reflect.preventExtensions(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Reflect.isExtensible(null);
|
Reflect.preventExtensions(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Reflect.isExtensible(undefined);
|
Reflect.preventExtensions(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Reflect.isExtensible('');
|
Reflect.preventExtensions('');
|
||||||
});
|
});
|
||||||
|
@ -15,6 +15,7 @@ var caught;
|
|||||||
|
|
||||||
class C extends Object {
|
class C extends Object {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
super();
|
||||||
try {
|
try {
|
||||||
delete super.x;
|
delete super.x;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -9,7 +9,6 @@ info: |
|
|||||||
MemberExpression OptionalChain
|
MemberExpression OptionalChain
|
||||||
NewTarget OptionalChain
|
NewTarget OptionalChain
|
||||||
features: [optional-chaining]
|
features: [optional-chaining]
|
||||||
includes: [fnGlobalObject.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const newTargetContext = (function() { return this; })();
|
const newTargetContext = (function() { return this; })();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user