mirror of https://github.com/tc39/test262.git
tests: Realm.prototype.importValue semantics
This commit is contained in:
parent
8b7c610232
commit
843b1baf7b
25
test/built-ins/Realm/prototype/importValue/can-import-specified-bindings-by-name.js
vendored
Normal file
25
test/built-ins/Realm/prototype/importValue/can-import-specified-bindings-by-name.js
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-realm.prototype.importvalue
|
||||
description: >
|
||||
Realm.prototype.importValue is not a constructor.
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.importValue,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.importValue is not a function'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
isConstructor(Realm.prototype.importValue),
|
||||
false,
|
||||
'isConstructor(Realm.prototype.importValue) must return false'
|
||||
);
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Realm.prototype.importValue("");
|
||||
}, '`let value = new Realm.prototype.importValue("")` throws TypeError');
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-realm.prototype.importvalue
|
||||
description: >
|
||||
Realm.prototype.importValue coerces exportName to string.
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.importValue,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.importValue is not a function'
|
||||
);
|
||||
|
||||
const r = new Realm();
|
||||
let count = 0;
|
||||
|
||||
const exportName = {
|
||||
toString() {
|
||||
count += 1;
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, () => {
|
||||
r.importValue('', exportName);
|
||||
});
|
||||
|
||||
assert.sameValue(count, 1);
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-realm.prototype.importvalue
|
||||
description: >
|
||||
Realm.prototype.importValue can import a value.
|
||||
flags: [async, module]
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.importValue,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.importValue is not a function'
|
||||
);
|
||||
|
||||
const r = new Realm();
|
||||
|
||||
r.importValue('./import-value_FIXTURE.js', 'x').then(x => {
|
||||
|
||||
assert.sameValue(x, 1);
|
||||
|
||||
}).then($DONE, $DONE);
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
export var x = 1;
|
|
@ -9,8 +9,7 @@ info: |
|
|||
has the Function prototype object, which is the initial value of the expression
|
||||
Function.prototype, as the value of its [[Prototype]] internal slot.
|
||||
|
||||
includes: [hidden-constructors.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Realm.prototype.importValue), AsyncFunction.prototype);
|
||||
assert.sameValue(Object.getPrototypeOf(Realm.prototype.importValue), Function.prototype);
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-realm.prototype.importvalue
|
||||
description: >
|
||||
Realm.prototype.importValue coerces specifier to string.
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.importValue,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.importValue is not a function'
|
||||
);
|
||||
|
||||
const r = new Realm();
|
||||
let count = 0;
|
||||
|
||||
const specifier = {
|
||||
toString() {
|
||||
count += 1;
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, () => {
|
||||
r.importValue(specifier);
|
||||
});
|
||||
|
||||
assert.sameValue(count, 1);
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-realm.prototype.importvalue
|
||||
description: >
|
||||
Realm.prototype.importValue validates realm object.
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.importValue,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.importValue is not a function'
|
||||
);
|
||||
|
||||
const r = new Realm();
|
||||
const bogus = {};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
r.importValue.call(bogus);
|
||||
}, 'throws a TypeError if this is not a Realm object');
|
Loading…
Reference in New Issue