fix delete test, add error tests, fix lint (#2453)

This commit is contained in:
Gus Caplan 2019-12-21 15:57:41 -06:00 committed by Leo Balter
parent 19fd4bea79
commit 502cc20010
8 changed files with 123 additions and 6 deletions

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

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

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

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

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

View File

@ -5,7 +5,7 @@ es6id: 26.1.10
description: >
Throws a TypeError if target is not an Object.
info: |
26.1.10 Reflect.isExtensible (target)
26.1.11 Reflect.preventExtensions ( target )
1. If Type(target) is not Object, throw a TypeError exception.
...
@ -13,17 +13,17 @@ features: [Reflect]
---*/
assert.throws(TypeError, function() {
Reflect.isExtensible(1);
Reflect.preventExtensions(1);
});
assert.throws(TypeError, function() {
Reflect.isExtensible(null);
Reflect.preventExtensions(null);
});
assert.throws(TypeError, function() {
Reflect.isExtensible(undefined);
Reflect.preventExtensions(undefined);
});
assert.throws(TypeError, function() {
Reflect.isExtensible('');
Reflect.preventExtensions('');
});

View File

@ -15,6 +15,7 @@ var caught;
class C extends Object {
constructor() {
super();
try {
delete super.x;
} catch (err) {

View File

@ -9,7 +9,6 @@ info: |
MemberExpression OptionalChain
NewTarget OptionalChain
features: [optional-chaining]
includes: [fnGlobalObject.js]
---*/
const newTargetContext = (function() { return this; })();