diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakRef')
34 files changed, 1097 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakRef/browser.js b/js/src/tests/test262/built-ins/WeakRef/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/browser.js diff --git a/js/src/tests/test262/built-ins/WeakRef/constructor.js b/js/src/tests/test262/built-ins/WeakRef/constructor.js new file mode 100644 index 0000000000..babc1ba744 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/constructor.js @@ -0,0 +1,18 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-constructor +description: > + The WeakRef constructor is the %WeakRef% intrinsic object and the initial + value of the WeakRef property of the global object. +features: [WeakRef] +---*/ + +assert.sameValue( + typeof WeakRef, 'function', + 'typeof WeakRef is function' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/instance-extensible.js b/js/src/tests/test262/built-ins/WeakRef/instance-extensible.js new file mode 100644 index 0000000000..52f56028ab --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/instance-extensible.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: Instances of WeakRef are extensible +info: | + WeakRef( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakRefPrototype%", « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + ObjectCreate ( proto [ , internalSlotsList ] ) + + 4. Set obj.[[Prototype]] to proto. + 5. Set obj.[[Extensible]] to true. + 6. Return obj. +features: [WeakRef, Reflect] +---*/ + +var wr = new WeakRef({}); +assert.sameValue(Object.isExtensible(wr), true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/is-a-constructor.js b/js/src/tests/test262/built-ins/WeakRef/is-a-constructor.js new file mode 100644 index 0000000000..192aab4bb8 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/is-a-constructor.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2020 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 WeakRef constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, WeakRef] +---*/ + +assert.sameValue(isConstructor(WeakRef), true, 'isConstructor(WeakRef) must return true'); +new WeakRef({}) + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/length.js b/js/src/tests/test262/built-ins/WeakRef/length.js new file mode 100644 index 0000000000..0be63c7506 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/length.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: WeakRef.length property descriptor +info: | + WeakRef ( target ) + + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument 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: [WeakRef] +---*/ + +verifyProperty(WeakRef, 'length', { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/name.js b/js/src/tests/test262/built-ins/WeakRef/name.js new file mode 100644 index 0000000000..d757c83ae2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/name.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: WeakRef.name property descriptor +info: | + WeakRef ( value ) + + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, that is not + identified as an anonymous function 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. For functions that + are specified as properties of objects, the name value is the + property name string used to access the function. [...] + + Unless otherwise specified, the name property of a built-in function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [WeakRef] +---*/ + +verifyProperty(WeakRef, 'name', { + value: 'WeakRef', + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/newtarget-prototype-is-not-object.js b/js/src/tests/test262/built-ins/WeakRef/newtarget-prototype-is-not-object.js new file mode 100644 index 0000000000..54674132b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/newtarget-prototype-is-not-object.js @@ -0,0 +1,61 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + [[Prototype]] defaults to %WeakRefPrototype% if NewTarget.prototype is not an object. +info: | + WeakRef( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakRefPrototype%", « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [WeakRef, Reflect.construct, Symbol] +---*/ + +var wr; +function newTarget() {} + +newTarget.prototype = undefined; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 1; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prop-desc.js b/js/src/tests/test262/built-ins/WeakRef/prop-desc.js new file mode 100644 index 0000000000..c3288aacc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prop-desc.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-constructor +description: > + Property descriptor of WeakRef +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [WeakRef] +---*/ + +verifyProperty(this, 'WeakRef', { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/WeakRef/proto-from-ctor-realm.js new file mode 100644 index 0000000000..9cbe7202d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/proto-from-ctor-realm.js @@ -0,0 +1,62 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + WeakRef( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, '%WeakRefPrototype%', « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [WeakRef, cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var wr; + +newTarget.prototype = undefined; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), other.WeakRef.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), other.WeakRef.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), other.WeakRef.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), other.WeakRef.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), other.WeakRef.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = 1; +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), other.WeakRef.prototype, 'newTarget.prototype is a Number'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/proto.js b/js/src/tests/test262/built-ins/WeakRef/proto.js new file mode 100644 index 0000000000..53861ad98d --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/proto.js @@ -0,0 +1,21 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-weak-ref-constructor +description: > + The prototype of WeakRef is Object.prototype +info: | + The value of the [[Prototype]] internal slot of the WeakRef object is the + intrinsic object %FunctionPrototype%. +features: [WeakRef] +---*/ + +assert.sameValue( + Object.getPrototypeOf(WeakRef), + Function.prototype, + 'Object.getPrototypeOf(WeakRef) returns the value of `Function.prototype`' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget-abrupt.js b/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget-abrupt.js new file mode 100644 index 0000000000..e63ed92ed3 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget-abrupt.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + Return abrupt from getting the NewTarget prototype +info: | + WeakRef ( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakRefPrototype%", « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + 3. Let proto be ? Get(constructor, 'prototype'). +features: [WeakRef, Reflect.construct] +---*/ + +var calls = 0; +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, 'prototype', { + get: function() { + calls += 1; + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Reflect.construct(WeakRef, [{}], newTarget); +}); + +assert.sameValue(calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget-custom.js b/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget-custom.js new file mode 100644 index 0000000000..6b8a6361f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget-custom.js @@ -0,0 +1,48 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + The [[Prototype]] internal slot is computed from NewTarget. +info: | + WeakRef ( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakRefPrototype%", « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [WeakRef, Reflect.construct] +---*/ + +var wr; + +wr = Reflect.construct(WeakRef, [{}], Object); +assert.sameValue(Object.getPrototypeOf(wr), Object.prototype, 'NewTarget is built-in Object constructor'); + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, 'prototype', { + get: function() { + return Array.prototype; + } +}); +wr = Reflect.construct(WeakRef, [{}], newTarget); +assert.sameValue(Object.getPrototypeOf(wr), Array.prototype, 'NewTarget is BoundFunction with accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget.js b/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget.js new file mode 100644 index 0000000000..695d020129 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype-from-newtarget.js @@ -0,0 +1,37 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + The [[Prototype]] internal slot is computed from NewTarget. +info: | + WeakRef ( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakRefPrototype%", « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [WeakRef] +---*/ + +var wr = new WeakRef({}); +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..2dea339c1a --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/Symbol.toStringTag.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + 'WeakRef'. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [WeakRef, Symbol, Symbol.toStringTag] +---*/ + +verifyProperty(WeakRef.prototype, Symbol.toStringTag, { + value: 'WeakRef', + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/browser.js b/js/src/tests/test262/built-ins/WeakRef/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js b/js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js new file mode 100644 index 0000000000..dd98eb40d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/constructor.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-properties-of-the-weak-ref-prototype-object +description: WeakRef.prototype.constructor +info: | + WeakRef.prototype.constructor + + Normative Optional + + The initial value of WeakRef.prototype.constructor is the intrinsic object %WeakRef%. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. + + This section is to be treated identically to the "Annex B" of ECMA-262, but to be written in-line with the main specification. +includes: [propertyHelper.js] +features: [WeakRef] +---*/ + +var actual = WeakRef.prototype.hasOwnProperty('constructor'); + +// If implemented, it should conform to the spec text +if (actual) { + verifyProperty(WeakRef.prototype, 'constructor', { + value: WeakRef, + writable: true, + enumerable: false, + configurable: true + }); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/browser.js diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js new file mode 100644 index 0000000000..923f153740 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/custom-this.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: Return target if weakRef.[[Target]] is not empty (applying custom this) +info: | + WeakRef.prototype.deref () + + 1. Let weakRef be the this value. + ... + 4. Let target be the value of weakRef.[[Target]]. + 5. If target is not empty, + a. Perform ! KeepDuringJob(target). + b. Return target. + 6. Return undefined. +features: [WeakRef] +---*/ + +var target = {}; +var deref = WeakRef.prototype.deref; +var wref = new WeakRef(target); + +assert.sameValue(deref.call(wref), target, 'returns target'); +assert.sameValue(deref.call(wref), target, '[[Target]] is not emptied #1'); +assert.sameValue(deref.call(wref), target, '[[Target]] is not emptied #2'); +assert.sameValue(deref.call(wref), target, '[[Target]] is not emptied #3'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js new file mode 100644 index 0000000000..f4bb7dfb3f --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/gc-cleanup-not-prevented-with-wr-deref.js @@ -0,0 +1,38 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) async -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: WeakRef deref should not prevent a GC event +info: | + WeakRef.prototype.deref ( ) + + ... + 4. Let target be the value of weakRef.[[Target]]. + 5. If target is not empty, + a. Perform ! KeepDuringJob(target). + b. Return target. + 6. Return undefined. +features: [FinalizationRegistry.prototype.cleanupSome, cleanupSome, WeakRef, host-gc-required] +includes: [async-gc.js] +flags: [async, non-deterministic] +---*/ + +var deref = false; +var wr; + +function emptyCells() { + var target = {}; + wr = new WeakRef(target); + + var prom = asyncGC(target); + target = null; + + return prom; +} + +emptyCells().then(function() { + deref = wr.deref(); + assert.sameValue(deref, undefined); +}).then($DONE, resolveAsyncGC); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js new file mode 100644 index 0000000000..33c9d3c46d --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/length.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: WeakRef.prototype.deref.length property descriptor +info: | + WeakRef.prototype.deref () + + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument 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: [WeakRef] +---*/ + +verifyProperty(WeakRef.prototype.deref, 'length', { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js new file mode 100644 index 0000000000..04d100b0fc --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/name.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: WeakRef.prototype.deref.name property descriptor +info: | + WeakRef.prototype.deref.name value and property descriptor + + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, that is not + identified as an anonymous function 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. For functions that + are specified as properties of objects, the name value is the + property name string used to access the function. [...] + + Unless otherwise specified, the name property of a built-in function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [WeakRef] +---*/ + +verifyProperty(WeakRef.prototype.deref, 'name', { + value: 'deref', + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js new file mode 100644 index 0000000000..9a97911843 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js @@ -0,0 +1,36 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2020 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: > + WeakRef.prototype.deref does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, WeakRef, arrow-function] +---*/ + +assert.sameValue( + isConstructor(WeakRef.prototype.deref), + false, + 'isConstructor(WeakRef.prototype.deref) must return false' +); + +assert.throws(TypeError, () => { + let wr = new WeakRef({}); new wr.deref(); +}, '`let wr = new WeakRef({}); new wr.deref()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js new file mode 100644 index 0000000000..6702c2ba71 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/prop-desc.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: > + Property descriptor of WeakRef.prototype.deref +info: | + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [WeakRef] +---*/ + +assert.sameValue(typeof WeakRef.prototype.deref, 'function'); + +verifyProperty(WeakRef.prototype, 'deref', { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-target.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-target.js new file mode 100644 index 0000000000..db8bb8c95a --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/return-target.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: Return target if weakRef.[[Target]] is not empty +info: | + WeakRef.prototype.deref () + + ... + 4. Let target be the value of weakRef.[[Target]]. + 5. If target is not empty, + a. Perform ! KeepDuringJob(target). + b. Return target. + 6. Return undefined. +features: [WeakRef] +---*/ + +var target = {}; +var wref = new WeakRef(target); + +assert.sameValue(wref.deref(), target, 'returns target'); +assert.sameValue(wref.deref(), target, '[[Target]] is not emptied #1'); +assert.sameValue(wref.deref(), target, '[[Target]] is not emptied #2'); +assert.sameValue(wref.deref(), target, '[[Target]] is not emptied #3'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js new file mode 100644 index 0000000000..e48630f9c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/shell.js @@ -0,0 +1,58 @@ +// GENERATED, DO NOT EDIT +// file: async-gc.js +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Collection of functions used to capture references cleanup from garbage collectors +features: [cleanupSome, FinalizationRegistry, Symbol, async-functions] +flags: [non-deterministic] +defines: [asyncGC, asyncGCDeref, resolveAsyncGC] +---*/ + +function asyncGC(...targets) { + var finalizationRegistry = new FinalizationRegistry(() => {}); + var length = targets.length; + + for (let target of targets) { + finalizationRegistry.register(target, 'target'); + target = null; + } + + targets = null; + + return Promise.resolve('tick').then(() => asyncGCDeref()).then(() => { + var names = []; + + // consume iterator to capture names + finalizationRegistry.cleanupSome(name => { names.push(name); }); + + if (!names || names.length != length) { + throw asyncGC.notCollected; + } + }); +} + +asyncGC.notCollected = Symbol('Object was not collected'); + +async function asyncGCDeref() { + var trigger; + + // TODO: Remove this when $262.clearKeptObject becomes documented and required + if ($262.clearKeptObjects) { + trigger = $262.clearKeptObjects(); + } + + await $262.gc(); + + return Promise.resolve(trigger); +} + +function resolveAsyncGC(err) { + if (err === asyncGC.notCollected) { + // Do not fail as GC can't provide necessary resources. + $DONE(); + } + + $DONE(err); +} diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js new file mode 100644 index 0000000000..a5529c5386 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-does-not-have-internal-target-throws.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')||!this.hasOwnProperty('FinalizationRegistry')) -- WeakRef,FinalizationRegistry is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: Throws a TypeError if this does not have a [[Target]] internal slot +info: | + WeakRef.prototype.deref () + + 1. Let weakRef be the this value. + 2. If Type(weakRef) is not Object, throw a TypeError exception. + 3. If weakRef does not have a [[Target]] internal slot, throw a TypeError exception. + 4. Let target be the value of weakRef.[[Target]]. + 5. If target is not empty, + a. Perform ! KeepDuringJob(target). + b. Return target. + 6. Return undefined. +features: [WeakSet, WeakMap, WeakRef, FinalizationRegistry] +---*/ + +assert.sameValue(typeof WeakRef.prototype.deref, 'function'); + +var deref = WeakRef.prototype.deref; + +assert.throws(TypeError, function() { + deref.call({ ['[[Target]]']: {} }); +}, 'Ordinary object without [[Target]]'); + +assert.throws(TypeError, function() { + deref.call(WeakRef.prototype); +}, 'WeakRef.prototype does not have a [[Target]] internal slot'); + +assert.throws(TypeError, function() { + deref.call(WeakRef); +}, 'WeakRef does not have a [[Target]] internal slot'); + +var finalizationRegistry = new FinalizationRegistry(function() {}); +assert.throws(TypeError, function() { + deref.call(finalizationRegistry); +}, 'FinalizationRegistry instance'); + +var wm = new WeakMap(); +assert.throws(TypeError, function() { + deref.call(wm); +}, 'WeakMap instance'); + +var ws = new WeakSet(); +assert.throws(TypeError, function() { + deref.call(ws); +}, 'WeakSet instance'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js new file mode 100644 index 0000000000..7580671b5e --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/this-not-object-throws.js @@ -0,0 +1,55 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref.prototype.deref +description: Throws a TypeError if this is not an Object +info: | + WeakRef.prototype.deref () + + 1. Let weakRef be the this value. + 2. If Type(weakRef) is not Object, throw a TypeError exception. + 3. If weakRef does not have a [[Target]] internal slot, throw a TypeError exception. + 4. Let target be the value of weakRef.[[Target]]. + 5. If target is not empty, + a. Perform ! KeepDuringJob(target). + b. Return target. + 6. Return undefined. +features: [WeakRef] +---*/ + +assert.sameValue(typeof WeakRef.prototype.deref, 'function'); + +var deref = WeakRef.prototype.deref; + +assert.throws(TypeError, function() { + deref.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + deref.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + deref.call(true); +}, 'true'); + +assert.throws(TypeError, function() { + deref.call(false); +}, 'false'); + +assert.throws(TypeError, function() { + deref.call(1); +}, 'number'); + +assert.throws(TypeError, function() { + deref.call('object'); +}, 'string'); + +var s = Symbol(); +assert.throws(TypeError, function() { + deref.call(s); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js b/js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js new file mode 100644 index 0000000000..53def27b83 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/prop-desc.js @@ -0,0 +1,21 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The property descriptor WeakRef.prototype +esid: sec-weak-ref.prototype +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +features: [WeakRef] +includes: [propertyHelper.js] +---*/ + +verifyProperty(WeakRef, 'prototype', { + writable: false, + enumerable: false, + configurable: false +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/proto.js b/js/src/tests/test262/built-ins/WeakRef/prototype/proto.js new file mode 100644 index 0000000000..e41d5245e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/proto.js @@ -0,0 +1,17 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The prototype of WeakRef.prototype is Object.prototype +esid: sec-properties-of-the-weak-ref-prototype-object +info: | + The value of the [[Prototype]] internal slot of the WeakRef prototype object + is the intrinsic object %ObjectPrototype%. +features: [WeakRef] +---*/ + +var proto = Object.getPrototypeOf(WeakRef.prototype); +assert.sameValue(proto, Object.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/shell.js b/js/src/tests/test262/built-ins/WeakRef/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/WeakRef/returns-new-object-from-constructor.js b/js/src/tests/test262/built-ins/WeakRef/returns-new-object-from-constructor.js new file mode 100644 index 0000000000..2ae3719dd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/returns-new-object-from-constructor.js @@ -0,0 +1,52 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + Returns a new ordinary object from the WeakRef constructor +info: | + WeakRef ( target ) + + ... + 3. Let weakRef be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakRefPrototype%", « [[Target]] »). + 4. Perfom ! KeepDuringJob(target). + 5. Set weakRef.[[Target]] to target. + 6. Return weakRef. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [WeakRef] +---*/ + +var target = {}; +var wr = new WeakRef(target); + +assert.notSameValue(wr, target, 'does not return the same object'); +assert.sameValue(wr instanceof WeakRef, true, 'instanceof'); + +for (let key of Object.getOwnPropertyNames(wr)) { + assert(false, `should not set any own named properties: ${key}`); +} + +for (let key of Object.getOwnPropertySymbols(wr)) { + assert(false, `should not set any own symbol properties: ${String(key)}`); +} + +assert.sameValue(Object.getPrototypeOf(wr), WeakRef.prototype); + + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/shell.js b/js/src/tests/test262/built-ins/WeakRef/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/WeakRef/target-not-object-throws.js b/js/src/tests/test262/built-ins/WeakRef/target-not-object-throws.js new file mode 100644 index 0000000000..0287ec3a2f --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/target-not-object-throws.js @@ -0,0 +1,56 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + Throws a TypeError if target is not Object +info: | + WeakRef ( target ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. If Type(target) is not Object, throw a TypeError exception. + ... +features: [WeakRef] +---*/ + +assert.sameValue( + typeof WeakRef, 'function', + 'typeof WeakRef is function' +); + +assert.throws(TypeError, function() { + new WeakRef(); +}, 'implicit undefined'); + +assert.throws(TypeError, function() { + new WeakRef(undefined); +}, 'explicit undefined'); + +assert.throws(TypeError, function() { + new WeakRef(null); +}, 'null'); + +assert.throws(TypeError, function() { + new WeakRef(1); +}, 'number'); + +assert.throws(TypeError, function() { + new WeakRef('Object'); +}, 'string'); + +var s = Symbol(); +assert.throws(TypeError, function() { + new WeakRef(s); +}, 'symbol'); + +assert.throws(TypeError, function() { + new WeakRef(true); +}, 'Boolean, true'); + +assert.throws(TypeError, function() { + new WeakRef(false); +}, 'Boolean, false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/undefined-newtarget-throws.js b/js/src/tests/test262/built-ins/WeakRef/undefined-newtarget-throws.js new file mode 100644 index 0000000000..7b2d366587 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/undefined-newtarget-throws.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + Throws a TypeError if NewTarget is undefined. +info: | + WeakRef ( target ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. If Type(target) is not Object, throw a TypeError exception. + ... +features: [WeakRef] +---*/ + +assert.sameValue( + typeof WeakRef, 'function', + 'typeof WeakRef is function' +); + +assert.throws(TypeError, function() { + WeakRef(); +}); + +assert.throws(TypeError, function() { + WeakRef({}); +}); + +reportCompare(0, 0); |