More tests

This commit is contained in:
Leo Balter 2019-06-03 16:59:39 -04:00 committed by Rick Waldron
parent e3d87d6690
commit 62477ea0c9
29 changed files with 729 additions and 17 deletions

View File

@ -10,5 +10,5 @@ description: >
assert.sameValue(
typeof FinalizationGroup, 'function',
'typeof FinalizationGroup is "function"'
'typeof FinalizationGroup is function'
);

View File

@ -0,0 +1,30 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: Instances of FinalizationGroup are extensible
info: |
FinalizationGroup ( cleanupCallback )
...
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »).
...
9. Return finalizationGroup.
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: [FinalizationGroup, Reflect]
---*/
var fg = new FinalizationGroup(function() {});
assert.sameValue(Object.isExtensible(fg), true);

View File

@ -24,7 +24,7 @@ includes: [propertyHelper.js]
features: [FinalizationGroup]
---*/
verifyProperty(FinalizationGroup, "length", {
verifyProperty(FinalizationGroup, 'length', {
value: 1,
writable: false,
enumerable: false,

View File

@ -23,8 +23,8 @@ includes: [propertyHelper.js]
features: [FinalizationGroup]
---*/
verifyProperty(FinalizationGroup, "name", {
value: "FinalizationGroup",
verifyProperty(FinalizationGroup, 'name', {
value: 'FinalizationGroup',
writable: false,
enumerable: false,
configurable: true

View File

@ -0,0 +1,58 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: >
[[Prototype]] defaults to %FinalizationGroupPrototype% if NewTarget.prototype is not an object.
info: |
FinalizationGroup ( cleanupCallback )
...
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »).
...
9. Return finalizationGroup.
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: [FinalizationGroup, Reflect.construct, Symbol]
---*/
var fg;
function newTarget() {}
function fn() {}
newTarget.prototype = undefined;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is undefined');
newTarget.prototype = null;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is null');
newTarget.prototype = true;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a Boolean');
newTarget.prototype = '';
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a String');
newTarget.prototype = Symbol();
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a Symbol');
newTarget.prototype = 1;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype, 'newTarget.prototype is a Number');

View File

@ -15,7 +15,7 @@ includes: [propertyHelper.js]
features: [FinalizationGroup]
---*/
verifyProperty(this, "FinalizationGroup", {
verifyProperty(this, 'FinalizationGroup', {
enumerable: false,
writable: true,
configurable: true

View File

@ -0,0 +1,59 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: Default [[Prototype]] value derived from realm of the newTarget
info: |
FinalizationGroup ( cleanupCallback )
...
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »).
...
9. Return finalizationGroup.
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: [FinalizationGroup, cross-realm, Reflect]
---*/
var other = $262.createRealm().global;
var newTarget = new other.Function();
function fn() {}
var fg;
newTarget.prototype = undefined;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is undefined');
newTarget.prototype = null;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is null');
newTarget.prototype = true;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Boolean');
newTarget.prototype = '';
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a String');
newTarget.prototype = Symbol();
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Symbol');
newTarget.prototype = 1;
fg = Reflect.construct(FinalizationGroup, [fn], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), other.FinalizationGroup.prototype, 'newTarget.prototype is a Number');

View File

@ -0,0 +1,41 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: >
Return abrupt from getting the NewTarget prototype
info: |
FinalizationGroup ( cleanupCallback )
...
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »).
...
9. Return finalizationGroup.
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: [FinalizationGroup, 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(FinalizationGroup, [{}], newTarget);
});
assert.sameValue(calls, 1);

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: >
The [[Prototype]] internal slot is computed from NewTarget.
info: |
FinalizationGroup ( cleanupCallback )
...
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »).
...
9. Return finalizationGroup.
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: [FinalizationGroup, Reflect.construct]
---*/
var fg;
fg = Reflect.construct(FinalizationGroup, [function() {}], Object);
assert.sameValue(Object.getPrototypeOf(fg), Object.prototype, 'NewTarget is built-in Object constructor');
var newTarget = function() {}.bind(null);
Object.defineProperty(newTarget, 'prototype', {
get: function() {
return Array.prototype;
}
});
fg = Reflect.construct(FinalizationGroup, [function() {}], newTarget);
assert.sameValue(Object.getPrototypeOf(fg), Array.prototype, 'NewTarget is BoundFunction with accessor');

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: >
The [[Prototype]] internal slot is computed from NewTarget.
info: |
FinalizationGroup ( cleanupCallback )
...
3. Let finalizationGroup be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationGroupPrototype%", « [[Realm]], [[CleanupCallback]], [[Cells]], [[IsFinalizationGroupCleanupJobActive]] »).
...
9. Return finalizationGroup.
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: [FinalizationGroup]
---*/
var fg = new FinalizationGroup(function() {});
assert.sameValue(Object.getPrototypeOf(fg), FinalizationGroup.prototype);

View File

@ -7,7 +7,7 @@ description: >
`Symbol.toStringTag` property descriptor
info: |
The initial value of the @@toStringTag property is the String value
"FinalizationGroup".
'FinalizationGroup'.
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: true }.
@ -16,7 +16,7 @@ features: [FinalizationGroup, Symbol, Symbol.toStringTag]
---*/
verifyProperty(FinalizationGroup.prototype, Symbol.toStringTag, {
value: "FinalizationGroup",
value: 'FinalizationGroup',
writable: false,
enumerable: false,
configurable: true

View File

@ -15,7 +15,7 @@ includes: [propertyHelper.js]
features: [FinalizationGroup]
---*/
verifyProperty(FinalizationGroup.prototype, "constructor", {
verifyProperty(FinalizationGroup.prototype, 'constructor', {
value: FinalizationGroup,
writable: true,
enumerable: false,

View File

@ -11,7 +11,7 @@ features: [FinalizationGroup]
includes: [propertyHelper.js]
---*/
verifyProperty(FinalizationGroup, "prototype", {
verifyProperty(FinalizationGroup, 'prototype', {
writable: false,
enumerable: false,
configurable: false

View File

@ -0,0 +1,69 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: >
Throws a TypeError if target is not callable
info: |
FinalizationGroup ( cleanupCallback )
1. If NewTarget is undefined, throw a TypeError exception.
2. If IsCallable(cleanupCallback) is false, throw a TypeError exception.
...
features: [FinalizationGroup]
---*/
assert.sameValue(
typeof FinalizationGroup, 'function',
'typeof FinalizationGroup is function'
);
assert.throws(TypeError, function() {
new FinalizationGroup({});
}, 'ordinary object');
assert.throws(TypeError, function() {
new FinalizationGroup(WeakRef.prototype);
}, 'WeakRef.prototype');
assert.throws(TypeError, function() {
new FinalizationGroup(FinalizationGroup.prototype);
}, 'FinalizationGroup.prototype');
assert.throws(TypeError, function() {
new FinalizationGroup([]);
}, 'Array');
assert.throws(TypeError, function() {
new FinalizationGroup();
}, 'implicit undefined');
assert.throws(TypeError, function() {
new FinalizationGroup(undefined);
}, 'explicit undefined');
assert.throws(TypeError, function() {
new FinalizationGroup(null);
}, 'null');
assert.throws(TypeError, function() {
new FinalizationGroup(1);
}, 'number');
assert.throws(TypeError, function() {
new FinalizationGroup('Object');
}, 'string');
var s = Symbol();
assert.throws(TypeError, function() {
new FinalizationGroup(s);
}, 'symbol');
assert.throws(TypeError, function() {
new FinalizationGroup(true);
}, 'Boolean, true');
assert.throws(TypeError, function() {
new FinalizationGroup(false);
}, 'Boolean, false');

View File

@ -0,0 +1,28 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-finalization-group-target
description: >
Throws a TypeError if NewTarget is undefined.
info: |
FinalizationGroup ( cleanupCallback )
1. If NewTarget is undefined, throw a TypeError exception.
2. If IsCallable(cleanupCallback) is false, throw a TypeError exception.
...
features: [FinalizationGroup]
---*/
assert.sameValue(
typeof FinalizationGroup, 'function',
'typeof FinalizationGroup is function'
);
assert.throws(TypeError, function() {
FinalizationGroup();
});
assert.throws(TypeError, function() {
FinalizationGroup(function() {});
});

View File

@ -10,5 +10,5 @@ description: >
assert.sameValue(
typeof WeakRef, 'function',
'typeof WeakRef is "function"'
'typeof WeakRef is function'
);

View File

@ -0,0 +1,31 @@
// 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);

View File

@ -24,7 +24,7 @@ includes: [propertyHelper.js]
features: [WeakRef]
---*/
verifyProperty(WeakRef, "length", {
verifyProperty(WeakRef, 'length', {
value: 1,
writable: false,
enumerable: false,

View File

@ -23,8 +23,8 @@ includes: [propertyHelper.js]
features: [WeakRef]
---*/
verifyProperty(WeakRef, "name", {
value: "WeakRef",
verifyProperty(WeakRef, 'name', {
value: 'WeakRef',
writable: false,
enumerable: false,
configurable: true

View File

@ -0,0 +1,58 @@
// 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');

View File

@ -15,7 +15,7 @@ includes: [propertyHelper.js]
features: [WeakRef]
---*/
verifyProperty(this, "WeakRef", {
verifyProperty(this, 'WeakRef', {
enumerable: false,
writable: true,
configurable: true

View File

@ -0,0 +1,59 @@
// 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]
---*/
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');

View File

@ -0,0 +1,42 @@
// 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);

View File

@ -0,0 +1,45 @@
// 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');

View File

@ -0,0 +1,34 @@
// 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);

View File

@ -7,7 +7,7 @@ description: >
`Symbol.toStringTag` property descriptor
info: |
The initial value of the @@toStringTag property is the String value
"WeakRef".
'WeakRef'.
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: true }.
@ -16,7 +16,7 @@ features: [WeakRef, Symbol, Symbol.toStringTag]
---*/
verifyProperty(WeakRef.prototype, Symbol.toStringTag, {
value: "WeakRef",
value: 'WeakRef',
writable: false,
enumerable: false,
configurable: true

View File

@ -11,7 +11,7 @@ features: [WeakRef]
includes: [propertyHelper.js]
---*/
verifyProperty(WeakRef, "prototype", {
verifyProperty(WeakRef, 'prototype', {
writable: false,
enumerable: false,
configurable: false

View File

@ -0,0 +1,53 @@
// 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');

View File

@ -0,0 +1,28 @@
// 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({});
});