mirror of https://github.com/tc39/test262.git
fix: Realm.prototype.evaluate semantics
This commit is contained in:
parent
b2f34c0894
commit
4c98d138b9
|
@ -1,25 +0,0 @@
|
|||
// 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.evaluate
|
||||
description: >
|
||||
Realm.prototype.evaluate coerces the argument to a string.
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.evaluate,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.evaluate is not a function'
|
||||
);
|
||||
|
||||
const r = new Realm();
|
||||
|
||||
assert.sameValue(r.evaluate(['1+1']), 2);
|
||||
assert.sameValue(r.evaluate({ [Symbol.toPrimitive]() { return '1+1'; }}), 2);
|
||||
assert.sameValue(r.evaluate(1), 1);
|
||||
assert.sameValue(r.evaluate(null), null);
|
||||
assert.sameValue(r.evaluate(undefined), undefined);
|
||||
assert.sameValue(r.evaluate(true), true);
|
||||
assert.sameValue(r.evaluate(false), false);
|
25
test/built-ins/Realm/prototype/evaluate/throws-when-argument-is-not-a-string.js
vendored
Normal file
25
test/built-ins/Realm/prototype/evaluate/throws-when-argument-is-not-a-string.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.evaluate
|
||||
description: >
|
||||
Realm.prototype.evaluate throws when argument is not a string.
|
||||
includes: [isConstructor.js]
|
||||
features: [callable-boundary-realms]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Realm.prototype.evaluate,
|
||||
'function',
|
||||
'This test must fail if Realm.prototype.evaluate is not a function'
|
||||
);
|
||||
|
||||
const r = new Realm();
|
||||
|
||||
assert.throws(TypeError, () => r.evaluate(['1+1']));
|
||||
assert.throws(TypeError, () => r.evaluate({ [Symbol.toPrimitive]() { return '1+1'; }}));
|
||||
assert.throws(TypeError, () => r.evaluate(1));
|
||||
assert.throws(TypeError, () => r.evaluate(null));
|
||||
assert.throws(TypeError, () => r.evaluate(undefined));
|
||||
assert.throws(TypeError, () => r.evaluate(true));
|
||||
assert.throws(TypeError, () => r.evaluate(false));
|
Loading…
Reference in New Issue