From 935d08814e984227d566d6eaac791955a13539e7 Mon Sep 17 00:00:00 2001 From: rwaldron Date: Fri, 16 Jul 2021 12:00:56 -0400 Subject: [PATCH] tests: Realm.prototype.evaluate, Realm.prototype.importValue --- test/built-ins/Realm/constructor.js | 18 +++++++++++++ test/built-ins/Realm/descriptor.js | 13 +++++++++ test/built-ins/Realm/instance.js | 15 +++++++++++ test/built-ins/Realm/length.js | 27 +++++++++++++++++++ test/built-ins/Realm/name.js | 24 +++++++++++++++++ test/built-ins/Realm/proto.js | 15 +++++++++++ .../Realm/prototype/evaluate/descriptor.js | 13 +++++++++ .../Realm/prototype/evaluate/length.js | 27 +++++++++++++++++++ .../Realm/prototype/evaluate/name.js | 24 +++++++++++++++++ .../prototype/evaluate/not-constructor.js | 26 ++++++++++++++++++ .../Realm/prototype/evaluate/proto.js | 15 +++++++++++ .../Realm/prototype/importValue/descriptor.js | 13 +++++++++ .../Realm/prototype/importValue/length.js | 25 +++++++++++++++++ .../Realm/prototype/importValue/name.js | 26 ++++++++++++++++++ .../prototype/importValue/not-constructor.js | 25 +++++++++++++++++ .../Realm/prototype/importValue/proto.js | 16 +++++++++++ test/built-ins/Realm/prototype/proto.js | 15 +++++++++++ 17 files changed, 337 insertions(+) create mode 100644 test/built-ins/Realm/constructor.js create mode 100644 test/built-ins/Realm/descriptor.js create mode 100644 test/built-ins/Realm/instance.js create mode 100644 test/built-ins/Realm/length.js create mode 100644 test/built-ins/Realm/name.js create mode 100644 test/built-ins/Realm/proto.js create mode 100644 test/built-ins/Realm/prototype/evaluate/descriptor.js create mode 100644 test/built-ins/Realm/prototype/evaluate/length.js create mode 100644 test/built-ins/Realm/prototype/evaluate/name.js create mode 100644 test/built-ins/Realm/prototype/evaluate/not-constructor.js create mode 100644 test/built-ins/Realm/prototype/evaluate/proto.js create mode 100644 test/built-ins/Realm/prototype/importValue/descriptor.js create mode 100644 test/built-ins/Realm/prototype/importValue/length.js create mode 100644 test/built-ins/Realm/prototype/importValue/name.js create mode 100644 test/built-ins/Realm/prototype/importValue/not-constructor.js create mode 100644 test/built-ins/Realm/prototype/importValue/proto.js create mode 100644 test/built-ins/Realm/prototype/proto.js diff --git a/test/built-ins/Realm/constructor.js b/test/built-ins/Realm/constructor.js new file mode 100644 index 0000000000..4a22fb4f43 --- /dev/null +++ b/test/built-ins/Realm/constructor.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-realm-constructor +description: > + Realm is a constructor and has [[Construct]] internal method. +includes: [isConstructor.js] +features: [callable-boundary-realms] +---*/ +assert.sameValue( + typeof Realm, + 'function', + 'This test must fail if Realm is not a function' +); + +assert(isConstructor(Realm)); +assert.sameValue(Object.getPrototypeOf(Realm), Function.prototype); +new Realm(); diff --git a/test/built-ins/Realm/descriptor.js b/test/built-ins/Realm/descriptor.js new file mode 100644 index 0000000000..e1cec5fdde --- /dev/null +++ b/test/built-ins/Realm/descriptor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Rick Waldron. 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 the initial value of the "Realm" property of the global object. +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +verifyNotEnumerable(this, "Realm"); +verifyWritable(this, "Realm"); +verifyConfigurable(this, "Realm"); diff --git a/test/built-ins/Realm/instance.js b/test/built-ins/Realm/instance.js new file mode 100644 index 0000000000..aa964872d2 --- /dev/null +++ b/test/built-ins/Realm/instance.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-realm-constructor +description: > + new Realm() returns a realm instance +features: [callable-boundary-realms] +---*/ +assert.sameValue( + typeof Realm, + 'function', + 'This test must fail if Realm is not a function' +); + +assert(new Realm() instanceof Realm); diff --git a/test/built-ins/Realm/length.js b/test/built-ins/Realm/length.js new file mode 100644 index 0000000000..dde6a6175a --- /dev/null +++ b/test/built-ins/Realm/length.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Rick waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-realm-constructor +description: > + The value of Realm.length is 0 +info: | + Realm ( ) + + Every built-in function object, including constructors, has a "length" property + whose value is a non-negative integral Number. Unless otherwise specified, this value + is equal to the number of required parameters shown in the subclause heading for the + function description. Optional parameters and rest parameters are not included in + the parameter count. + + Unless otherwise specified, the "length" property of a built-in function object has + the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Realm.length, 0, "The value of `Realm.length` is `0`"); + +verifyNotEnumerable(Realm, "length"); +verifyNotWritable(Realm, "length"); +verifyConfigurable(Realm, "length"); diff --git a/test/built-ins/Realm/name.js b/test/built-ins/Realm/name.js new file mode 100644 index 0000000000..436a199386 --- /dev/null +++ b/test/built-ins/Realm/name.js @@ -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-ecmascript-standard-built-in-objects +description: > + The value of Realm.name is 'Realm' +info: | + Every built-in function object, including constructors, has a "name" property + whose value is a String. Unless otherwise specified, this value is the name + that is given to the function in this specification. + + Unless otherwise specified, the "name" property of a built-in function + object has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Realm.name, "Realm", "The value of `Realm.name` is `'Realm'`"); + +verifyNotEnumerable(Realm, "name"); +verifyNotWritable(Realm, "name"); +verifyConfigurable(Realm, "name"); diff --git a/test/built-ins/Realm/proto.js b/test/built-ins/Realm/proto.js new file mode 100644 index 0000000000..d6031eb808 --- /dev/null +++ b/test/built-ins/Realm/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-the-realm-constructor +description: > + The [[Prototype]] of Realm is Function.Prototype. +info: | + Unless otherwise specified every built-in function and every built-in constructor + has the Function prototype object, which is the initial value of the expression + Function.prototype, as the value of its [[Prototype]] internal slot. + +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Object.getPrototypeOf(Realm), Function.prototype); diff --git a/test/built-ins/Realm/prototype/evaluate/descriptor.js b/test/built-ins/Realm/prototype/evaluate/descriptor.js new file mode 100644 index 0000000000..3a98287b3b --- /dev/null +++ b/test/built-ins/Realm/prototype/evaluate/descriptor.js @@ -0,0 +1,13 @@ +// 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 is an ECMAScript Standard built-in object function. +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +verifyNotEnumerable(Realm.prototype, "evaluate"); +verifyWritable(Realm.prototype, "evaluate"); +verifyConfigurable(Realm.prototype, "evaluate"); diff --git a/test/built-ins/Realm/prototype/evaluate/length.js b/test/built-ins/Realm/prototype/evaluate/length.js new file mode 100644 index 0000000000..9ce473675a --- /dev/null +++ b/test/built-ins/Realm/prototype/evaluate/length.js @@ -0,0 +1,27 @@ +// 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: > + The value of Realm.prototype.evaluate.length is 1 +info: | + Realm.prototype.evaluate ( sourceText ) + + Every built-in function object, including constructors, has a "length" property + whose value is a non-negative integral Number. Unless otherwise specified, this value + is equal to the number of required parameters shown in the subclause heading for the + function description. Optional parameters and rest parameters are not included in + the parameter count. + + Unless otherwise specified, the "length" property of a built-in function object has + the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Realm.prototype.evaluate.length, 1, "The value of `Realm.prototype.evaluate.length` is `1`"); + +verifyNotEnumerable(Realm.prototype.evaluate, "length"); +verifyNotWritable(Realm.prototype.evaluate, "length"); +verifyConfigurable(Realm.prototype.evaluate, "length"); diff --git a/test/built-ins/Realm/prototype/evaluate/name.js b/test/built-ins/Realm/prototype/evaluate/name.js new file mode 100644 index 0000000000..66d1da4522 --- /dev/null +++ b/test/built-ins/Realm/prototype/evaluate/name.js @@ -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.evaluate +description: > + The value of Realm.prototype.evaluate.name is 'evaluate' +info: | + Every built-in function object, including constructors, has a "name" property + whose value is a String. Unless otherwise specified, this value is the name + that is given to the function in this specification. + + Unless otherwise specified, the "name" property of a built-in function + object has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Realm.prototype.evaluate.name, "evaluate", "The value of `Realm.prototype.evaluate.name` is `'evaluate'`"); + +verifyNotEnumerable(Realm.prototype.evaluate, "name"); +verifyNotWritable(Realm.prototype.evaluate, "name"); +verifyConfigurable(Realm.prototype.evaluate, "name"); diff --git a/test/built-ins/Realm/prototype/evaluate/not-constructor.js b/test/built-ins/Realm/prototype/evaluate/not-constructor.js new file mode 100644 index 0000000000..e0f2fbc1f6 --- /dev/null +++ b/test/built-ins/Realm/prototype/evaluate/not-constructor.js @@ -0,0 +1,26 @@ +// 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 is not a constructor. +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' +); + +assert.sameValue( + isConstructor(Realm.prototype.evaluate), + false, + 'isConstructor(Realm.prototype.evaluate) must return false' +); + +assert.throws(TypeError, () => { + new Realm.prototype.evaluate(""); +}, '`let value = new Realm.prototype.evaluate("")` throws TypeError'); + diff --git a/test/built-ins/Realm/prototype/evaluate/proto.js b/test/built-ins/Realm/prototype/evaluate/proto.js new file mode 100644 index 0000000000..49567c9b94 --- /dev/null +++ b/test/built-ins/Realm/prototype/evaluate/proto.js @@ -0,0 +1,15 @@ +// 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: > + The [[Prototype]] of Realm.prototype.evaluate is Function.Prototype. + + Unless otherwise specified every built-in function and every built-in constructor + has the Function prototype object, which is the initial value of the expression + Function.prototype, as the value of its [[Prototype]] internal slot. + +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Object.getPrototypeOf(Realm.prototype.evaluate), Function.prototype); diff --git a/test/built-ins/Realm/prototype/importValue/descriptor.js b/test/built-ins/Realm/prototype/importValue/descriptor.js new file mode 100644 index 0000000000..1124a46e06 --- /dev/null +++ b/test/built-ins/Realm/prototype/importValue/descriptor.js @@ -0,0 +1,13 @@ +// 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 an ECMAScript Standard built-in object function. +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +verifyNotEnumerable(Realm.prototype, "importValue"); +verifyWritable(Realm.prototype, "importValue"); +verifyConfigurable(Realm.prototype, "importValue"); diff --git a/test/built-ins/Realm/prototype/importValue/length.js b/test/built-ins/Realm/prototype/importValue/length.js new file mode 100644 index 0000000000..fba55364c7 --- /dev/null +++ b/test/built-ins/Realm/prototype/importValue/length.js @@ -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: > + The value of Realm.prototype.importValue.length is 2 +info: | + Every built-in function object, including constructors, has a "length" property + whose value is a non-negative integral Number. Unless otherwise specified, this value + is equal to the number of required parameters shown in the subclause heading for the + function description. Optional parameters and rest parameters are not included in + the parameter count. + + Unless otherwise specified, the "length" property of a built-in function object has + the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Realm.prototype.importValue.length, 2, "The value of `Realm.prototype.importValue.length` is `2`"); + +verifyNotEnumerable(Realm.prototype.importValue, "length"); +verifyNotWritable(Realm.prototype.importValue, "length"); +verifyConfigurable(Realm.prototype.importValue, "length"); diff --git a/test/built-ins/Realm/prototype/importValue/name.js b/test/built-ins/Realm/prototype/importValue/name.js new file mode 100644 index 0000000000..d5c3e6d609 --- /dev/null +++ b/test/built-ins/Realm/prototype/importValue/name.js @@ -0,0 +1,26 @@ +// 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: > + The value of Realm.prototype.importValue.name is 'importValue' +info: | + Realm.prototype.importValue + + Every built-in function object, including constructors, has a "name" property + whose value is a String. Unless otherwise specified, this value is the name + that is given to the function in this specification. + + Unless otherwise specified, the "name" property of a built-in function + object has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + +includes: [propertyHelper.js] +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Realm.prototype.importValue.name, "importValue", "The value of `Realm.prototype.importValue.name` is `'importValue'`"); + +verifyNotEnumerable(Realm.prototype.importValue, "name"); +verifyNotWritable(Realm.prototype.importValue, "name"); +verifyConfigurable(Realm.prototype.importValue, "name"); diff --git a/test/built-ins/Realm/prototype/importValue/not-constructor.js b/test/built-ins/Realm/prototype/importValue/not-constructor.js new file mode 100644 index 0000000000..b1dbdd1b11 --- /dev/null +++ b/test/built-ins/Realm/prototype/importValue/not-constructor.js @@ -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'); diff --git a/test/built-ins/Realm/prototype/importValue/proto.js b/test/built-ins/Realm/prototype/importValue/proto.js new file mode 100644 index 0000000000..2e24437bc6 --- /dev/null +++ b/test/built-ins/Realm/prototype/importValue/proto.js @@ -0,0 +1,16 @@ +// 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: > + The [[Prototype]] of Realm.prototype.importValue is AsyncFunction.Prototype. +info: | + Unless otherwise specified every built-in function and every built-in constructor + 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); diff --git a/test/built-ins/Realm/prototype/proto.js b/test/built-ins/Realm/prototype/proto.js new file mode 100644 index 0000000000..59702105b4 --- /dev/null +++ b/test/built-ins/Realm/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-the-realm-prototype-object +description: > + The [[Prototype]] of Realm.prototype is Object.Prototype. +info: | + Unless otherwise specified every built-in prototype object has the Object prototype + object, which is the initial value of the expression Object.prototype, as the value + of its [[Prototype]] internal slot, except the Object prototype object itself. + +features: [callable-boundary-realms] +---*/ + +assert.sameValue(Object.getPrototypeOf(Realm.prototype), Object.prototype);