mirror of https://github.com/tc39/test262.git
Add a few tweaks
This commit is contained in:
parent
b4ff2c76bc
commit
d19534c3ce
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2021 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-realm-constructor
|
||||
description: >
|
||||
The Realm constructor is extensible
|
||||
info: |
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
Unless specified otherwise, the [[Extensible]] internal slot of a built-in
|
||||
object initially has the value true.
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(Realm), true);
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) 2021 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-realm
|
||||
description: >
|
||||
The new instance is extensible
|
||||
info: |
|
||||
Realm ( )
|
||||
|
||||
...
|
||||
2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Realm.prototype%",
|
||||
« [[Realm]], [[ExecutionContext]] »).
|
||||
...
|
||||
13. Return O.
|
||||
|
||||
OrdinaryCreateFromConstructor creates a new ordinary objects including the
|
||||
internal slots [[Prototype]] and [[Extensible]]. The latter will have its
|
||||
value set to true.
|
||||
includes: [propertyHelper.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
const realm = new Realm();
|
||||
|
||||
assert(Object.isExtensible(realm));
|
||||
|
||||
Object.defineProperty(realm, 'foo', {});
|
||||
assert(realm.hasOwnProperty('foo'), 'confirms extensibility adding a new property');
|
||||
|
||||
Object.defineProperty(realm, 'foo', {
|
||||
value: 'bar',
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
});
|
||||
|
||||
verifyProperty(realm, 'foo', {
|
||||
value: 'bar',
|
||||
writable: true,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
});
|
|
@ -4,6 +4,14 @@
|
|||
esid: sec-realm-constructor
|
||||
description: >
|
||||
new Realm() returns a realm instance
|
||||
info: |
|
||||
Realm ( )
|
||||
|
||||
...
|
||||
2. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Realm.prototype%",
|
||||
« [[Realm]], [[ExecutionContext]] »).
|
||||
...
|
||||
13. Return O.
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
assert.sameValue(
|
||||
|
@ -12,4 +20,11 @@ assert.sameValue(
|
|||
'This test must fail if Realm is not a function'
|
||||
);
|
||||
|
||||
assert(new Realm() instanceof Realm);
|
||||
var realm = new Realm();
|
||||
|
||||
assert(realm instanceof Realm);
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(realm),
|
||||
Realm.prototype,
|
||||
'[[Prototype]] is set to %Realm.prototype%'
|
||||
);
|
||||
|
|
|
@ -24,3 +24,11 @@ assert.throws(TypeError, () => {
|
|||
new Realm.prototype.evaluate("");
|
||||
}, '`new Realm.prototype.evaluate("")` throws TypeError');
|
||||
|
||||
const r = new Realm();
|
||||
r.evaluate('globalThis.x = 0');
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new r.evaluate("globalThis.x += 1;");
|
||||
}, '`new r.evaluate("...")` throws TypeError');
|
||||
|
||||
assert.sameValue(r.evaluate('globalThis.x'), 0, 'No code evaluated in the new expression');
|
||||
|
|
|
@ -22,6 +22,7 @@ assert.sameValue(r.evaluate('undefined'), undefined);
|
|||
assert.sameValue(r.evaluate('true'), true);
|
||||
assert.sameValue(r.evaluate('false'), false);
|
||||
assert.sameValue(r.evaluate('function fn() {}'), undefined, 'fn declaration has empty completion');
|
||||
assert.sameValue(r.evaluate('-0'), -0);
|
||||
assert.sameValue(r.evaluate('{}'), undefined, 'Block has empty completion');
|
||||
assert.sameValue(r.evaluate('-0'), -0);
|
||||
assert.sameValue(r.evaluate('"str"'), 'str');
|
||||
assert(Number.isNaN(r.evaluate('NaN')));
|
||||
|
|
|
@ -22,3 +22,4 @@ assert.throws(TypeError, () => r.evaluate(null));
|
|||
assert.throws(TypeError, () => r.evaluate(undefined));
|
||||
assert.throws(TypeError, () => r.evaluate(true));
|
||||
assert.throws(TypeError, () => r.evaluate(false));
|
||||
assert.throws(TypeError, () => r.evaluate(new String('nope')));
|
||||
|
|
|
@ -17,5 +17,5 @@ const r = new Realm();
|
|||
const bogus = {};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
r.evaluate.call(bogus);
|
||||
r.evaluate.call(bogus, '');
|
||||
}, 'throws a TypeError if this is not a Realm object');
|
||||
|
|
|
@ -16,9 +16,9 @@ assert.sameValue(
|
|||
const r = new Realm();
|
||||
|
||||
r.evaluate(`
|
||||
function fn() {
|
||||
0, function fn() {
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
`);
|
||||
|
||||
const wrapped = r.evaluate('fn');
|
||||
|
|
|
@ -21,5 +21,11 @@ assert.sameValue(
|
|||
);
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Realm.prototype.importValue("");
|
||||
new Realm.prototype.importValue("", "name");
|
||||
}, '`new Realm.prototype.importValue("")` throws TypeError');
|
||||
|
||||
const r = new Realm();
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new r.imporValue("./import-value_FIXTURE.js", "x");
|
||||
}, '`new r.imporValue("...")` throws TypeError');
|
||||
|
|
|
@ -17,5 +17,5 @@ const r = new Realm();
|
|||
const bogus = {};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
r.importValue.call(bogus);
|
||||
r.importValue.call(bogus, "specifier", "name");
|
||||
}, 'throws a TypeError if this is not a Realm object');
|
||||
|
|
Loading…
Reference in New Issue