mirror of https://github.com/tc39/test262.git
Remove tests for FinalizationRegistry.prototype.cleanupSome
This proposal was split off from FinalizationRegistry at stage 2, and then withdrawn. Given that status, it should not be part of the test suite.
This commit is contained in:
parent
957ab22773
commit
3bed2c446f
|
@ -15,10 +15,6 @@
|
|||
# https://github.com/tc39/proposal-intl-locale-info
|
||||
Intl.Locale-info
|
||||
|
||||
# FinalizationRegistry#cleanupSome
|
||||
# https://github.com/tc39/proposal-cleanup-some
|
||||
FinalizationRegistry.prototype.cleanupSome
|
||||
|
||||
# Intl.NumberFormat V3
|
||||
# https://github.com/tc39/proposal-intl-numberformat-v3
|
||||
Intl.NumberFormat-v3
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Throws a TypeError if callback is not callable
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
...
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof FinalizationRegistry.prototype.cleanupSome, 'function');
|
||||
|
||||
var finalizationRegistry = new FinalizationRegistry(function() {});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome(null);
|
||||
}, 'null');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome(true);
|
||||
}, 'true');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome(false);
|
||||
}, 'false');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome(1);
|
||||
}, 'number');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome('object');
|
||||
}, 'string');
|
||||
|
||||
var s = Symbol();
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome(s);
|
||||
}, 'symbol');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome({});
|
||||
}, 'object');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
finalizationRegistry.cleanupSome(FinalizationRegistry.prototype);
|
||||
}, 'FinalizationRegistry.prototype');
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Cleanup might be prevented with a reference usage;
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
5. Perform ? CleanupFinalizationRegistry(finalizationRegistry, callback).
|
||||
6. Return undefined.
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, host-gc-required]
|
||||
includes: [async-gc.js]
|
||||
flags: [async, non-deterministic]
|
||||
---*/
|
||||
|
||||
var holdingsList = [];
|
||||
function cb(holding) {
|
||||
holdingsList.push(holding);
|
||||
};
|
||||
var finalizationRegistry = new FinalizationRegistry(function() {});
|
||||
|
||||
var referenced = {};
|
||||
|
||||
function emptyCells() {
|
||||
var target = {};
|
||||
finalizationRegistry.register(target, 'target!');
|
||||
finalizationRegistry.register(referenced, 'referenced');
|
||||
|
||||
var prom = asyncGC(target);
|
||||
target = null;
|
||||
|
||||
return prom;
|
||||
}
|
||||
|
||||
emptyCells().then(function() {
|
||||
finalizationRegistry.cleanupSome(cb);
|
||||
|
||||
assert.sameValue(holdingsList.length, 1);
|
||||
assert.sameValue(holdingsList[0], 'target!');
|
||||
|
||||
assert.sameValue(typeof referenced, 'object', 'referenced preserved');
|
||||
}).then($DONE, resolveAsyncGC);
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Cleanup might be prevented with an unregister usage
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
5. Perform ? CleanupFinalizationRegistry(finalizationRegistry, callback).
|
||||
6. Return undefined.
|
||||
|
||||
FinalizationRegistry.prototype.unregister ( unregisterToken )
|
||||
|
||||
1. Let removed be false.
|
||||
2. For each Record { [[Target]], [[Holdings]], [[UnregisterToken]] } cell that is an element of finalizationRegistry.[[Cells]], do
|
||||
a. If SameValue(cell.[[UnregisterToken]], unregisterToken) is true, then
|
||||
i. Remove cell from finalizationRegistry.[[Cells]].
|
||||
ii. Set removed to true.
|
||||
3. Return removed.
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, host-gc-required]
|
||||
includes: [async-gc.js]
|
||||
flags: [async, non-deterministic]
|
||||
---*/
|
||||
|
||||
var token = {};
|
||||
var finalizationRegistry = new FinalizationRegistry(function() {});
|
||||
|
||||
function emptyCells() {
|
||||
var target = {};
|
||||
finalizationRegistry.register(target, 'target!', token);
|
||||
|
||||
var prom = asyncGC(target);
|
||||
target = null;
|
||||
|
||||
return prom;
|
||||
}
|
||||
|
||||
emptyCells().then(function() {
|
||||
var called = 0;
|
||||
|
||||
var res = finalizationRegistry.unregister(token);
|
||||
assert.sameValue(res, true, 'unregister target before iterating over it in cleanup');
|
||||
|
||||
finalizationRegistry.cleanupSome(function cb(holding) {
|
||||
called += 1;
|
||||
});
|
||||
|
||||
assert.sameValue(called, 0, 'callback was not called');
|
||||
}).then($DONE, resolveAsyncGC);
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Return values applying custom this
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
5. Perform ! CleanupFinalizationRegistry(finalizationRegistry, callback).
|
||||
6. Return undefined.
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry]
|
||||
---*/
|
||||
|
||||
var fn = function() {};
|
||||
var cleanupSome = FinalizationRegistry.prototype.cleanupSome;
|
||||
var finalizationRegistry = new FinalizationRegistry(fn);
|
||||
|
||||
var cb = function() {};
|
||||
|
||||
assert.sameValue(cleanupSome.call(finalizationRegistry, cb), undefined);
|
||||
assert.sameValue(cleanupSome.call(finalizationRegistry, fn), undefined), 'reuse the same cleanup callback fn';
|
|
@ -1,69 +0,0 @@
|
|||
// 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-finalization-registry-constructor
|
||||
description: >
|
||||
Iterates over different type values in holdings
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
...
|
||||
5. Perform ! CleanupFinalizationRegistry(finalizationRegistry, callback).
|
||||
...
|
||||
|
||||
CleanupFinalizationRegistry ( finalizationRegistry [ , callback ] )
|
||||
|
||||
...
|
||||
3. While finalizationRegistry.[[Cells]] contains a Record cell such that cell.[[WeakRefTarget]] is ~empty~, then an implementation may perform the following steps,
|
||||
a. Choose any such cell.
|
||||
b. Remove cell from finalizationRegistry.[[Cells]].
|
||||
c. Perform ? Call(callback, undefined, << cell.[[HeldValue]] >>).
|
||||
...
|
||||
|
||||
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, Symbol, host-gc-required]
|
||||
includes: [async-gc.js]
|
||||
flags: [async, non-deterministic]
|
||||
---*/
|
||||
|
||||
function check(value, expectedName) {
|
||||
var holdings = [];
|
||||
var called = 0;
|
||||
var finalizationRegistry = new FinalizationRegistry(function() {});
|
||||
|
||||
function callback(holding) {
|
||||
called += 1;
|
||||
holdings.push(holding);
|
||||
}
|
||||
|
||||
// This is internal to avoid conflicts
|
||||
function emptyCells(value) {
|
||||
var target = {};
|
||||
finalizationRegistry.register(target, value);
|
||||
|
||||
var prom = asyncGC(target);
|
||||
target = null;
|
||||
|
||||
return prom;
|
||||
}
|
||||
|
||||
return emptyCells(value).then(function() {
|
||||
finalizationRegistry.cleanupSome(callback);
|
||||
assert.sameValue(called, 1, expectedName);
|
||||
assert.sameValue(holdings.length, 1, expectedName);
|
||||
assert.sameValue(holdings[0], value, expectedName);
|
||||
});
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
check(undefined, 'undefined'),
|
||||
check(null, 'null'),
|
||||
check('', 'the empty string'),
|
||||
check({}, 'object'),
|
||||
check(42, 'number'),
|
||||
check(true, 'true'),
|
||||
check(false, 'false'),
|
||||
check(Symbol(1), 'symbol'),
|
||||
]).then(() => $DONE(), resolveAsyncGC);
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: FinalizationRegistry.prototype.cleanupSome.length property descriptor
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
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: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry]
|
||||
---*/
|
||||
|
||||
verifyProperty(FinalizationRegistry.prototype.cleanupSome, 'length', {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: FinalizationRegistry.prototype.cleanupSome.name property descriptor
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome.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: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry]
|
||||
---*/
|
||||
|
||||
verifyProperty(FinalizationRegistry.prototype.cleanupSome, 'name', {
|
||||
value: 'cleanupSome',
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -1,33 +0,0 @@
|
|||
// 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: >
|
||||
FinalizationRegistry.prototype.cleanupSome 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, FinalizationRegistry, FinalizationRegistry.prototype.cleanupSome, arrow-function]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
isConstructor(FinalizationRegistry.prototype.cleanupSome),
|
||||
false,
|
||||
'isConstructor(FinalizationRegistry.prototype.cleanupSome) must return false'
|
||||
);
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
let fr = new FinalizationRegistry(() => {}); new fr.cleanupSome(() => {});
|
||||
});
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: >
|
||||
Property descriptor of FinalizationRegistry.prototype.cleanupSome
|
||||
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: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof FinalizationRegistry.prototype.cleanupSome, 'function');
|
||||
|
||||
verifyProperty(FinalizationRegistry.prototype, 'cleanupSome', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -1,51 +0,0 @@
|
|||
// 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-finalization-registry-constructor
|
||||
description: >
|
||||
The cleanupSome() method can be reentered
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, host-gc-required]
|
||||
includes: [async-gc.js]
|
||||
flags: [async, non-deterministic]
|
||||
---*/
|
||||
|
||||
var called = 0;
|
||||
var endOfCall = 0;
|
||||
var finalizationRegistry = new FinalizationRegistry(function() {});
|
||||
|
||||
function callback(holding) {
|
||||
called += 1;
|
||||
|
||||
if (called === 1) {
|
||||
// Atempt to re-enter the callback.
|
||||
var nestedCallbackRan = false;
|
||||
finalizationRegistry.cleanupSome(() => { nestedCallbackRan = true });
|
||||
assert.sameValue(nestedCallbackRan, true);
|
||||
}
|
||||
|
||||
endOfCall += 1;
|
||||
}
|
||||
|
||||
function emptyCells() {
|
||||
var o1 = {};
|
||||
var o2 = {};
|
||||
// Register more than one objects to test reentrancy.
|
||||
finalizationRegistry.register(o1, 'holdings 1');
|
||||
finalizationRegistry.register(o2, 'holdings 2');
|
||||
|
||||
var prom = asyncGC(o1);
|
||||
o1 = null;
|
||||
|
||||
return prom;
|
||||
}
|
||||
|
||||
emptyCells().then(function() {
|
||||
finalizationRegistry.cleanupSome(callback);
|
||||
|
||||
assert.sameValue(called, 1, 'callback was called');
|
||||
assert.sameValue(endOfCall, 1, 'callback finished');
|
||||
}).then($DONE, resolveAsyncGC);
|
|
@ -1,66 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Return undefined regardless the result of CleanupFinalizationRegistry
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
5. Perform ? CleanupFinalizationRegistry(finalizationRegistry, callback).
|
||||
6. Return undefined.
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, arrow-function, async-functions, async-iteration, class, host-gc-required]
|
||||
includes: [async-gc.js]
|
||||
flags: [async, non-deterministic]
|
||||
---*/
|
||||
|
||||
var called;
|
||||
var fn = function() {
|
||||
called += 1;
|
||||
return 39;
|
||||
};
|
||||
var cb = function() {
|
||||
called += 1;
|
||||
return 42;
|
||||
};
|
||||
var finalizationRegistry = new FinalizationRegistry(fn);
|
||||
|
||||
function emptyCells() {
|
||||
var target = {};
|
||||
finalizationRegistry.register(target);
|
||||
|
||||
var prom = asyncGC(target);
|
||||
target = null;
|
||||
|
||||
return prom;
|
||||
}
|
||||
|
||||
emptyCells().then(function() {
|
||||
called = 0;
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(cb), undefined, 'regular callback');
|
||||
assert.sameValue(called, 1);
|
||||
}).then(emptyCells).then(function() {
|
||||
called = 0;
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(fn), undefined, 'regular callback, same FG cleanup function');
|
||||
assert.sameValue(called, 1);
|
||||
}).then(emptyCells).then(function() {
|
||||
called = 0;
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(), undefined, 'undefined (implicit) callback, defer to FB callback');
|
||||
assert.sameValue(called, 1);
|
||||
}).then(emptyCells).then(function() {
|
||||
called = 0;
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(undefined), undefined, 'undefined (explicit) callback, defer to FB callback');
|
||||
assert.sameValue(called, 1);
|
||||
}).then(emptyCells).then(function() {
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(() => 1), undefined, 'arrow function');
|
||||
}).then(emptyCells).then(function() {
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(async function() {}), undefined, 'async function');
|
||||
}).then(emptyCells).then(function() {
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(function *() {}), undefined, 'generator');
|
||||
}).then(emptyCells).then(function() {
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(async function *() {}), undefined, 'async generator');
|
||||
}).then($DONE, resolveAsyncGC);
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Return undefined regardless the result of CleanupFinalizationRegistry
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
5. Perform ? CleanupFinalizationRegistry(finalizationRegistry, callback).
|
||||
6. Return undefined.
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, arrow-function, async-functions, async-iteration, class]
|
||||
---*/
|
||||
|
||||
var fn = function() {};
|
||||
var cb = function() {};
|
||||
var poisoned = function() { throw new Test262Error(); };
|
||||
var finalizationRegistry = new FinalizationRegistry(fn);
|
||||
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(cb), undefined, 'regular callback');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(fn), undefined, 'regular callback, same FG cleanup function');
|
||||
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(() => {}), undefined, 'arrow function');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(finalizationRegistry.cleanupSome), undefined, 'cleanupSome itself');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(poisoned), undefined, 'poisoned');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(class {}), undefined, 'class expression');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(async function() {}), undefined, 'async function');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(function *() {}), undefined, 'generator');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(async function *() {}), undefined, 'async generator');
|
||||
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(), undefined, 'undefined, implicit');
|
||||
assert.sameValue(finalizationRegistry.cleanupSome(undefined), undefined, 'undefined, explicit');
|
||||
|
||||
var poisonedFg = new FinalizationRegistry(poisoned);
|
||||
|
||||
assert.sameValue(poisonedFg.cleanupSome(cb), undefined, 'regular callback on poisoned FG cleanup callback');
|
||||
assert.sameValue(poisonedFg.cleanupSome(poisoned), undefined, 'poisoned callback on poisoned FG cleanup callback');
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Throws a TypeError if this does not have a [[Cells]] internal slot
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
...
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, WeakSet, WeakMap, FinalizationRegistry, WeakRef]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof FinalizationRegistry.prototype.cleanupSome, 'function');
|
||||
|
||||
var cleanupSome = FinalizationRegistry.prototype.cleanupSome;
|
||||
var cb = function() {};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call({ ['[[Cells]]']: {} }, cb);
|
||||
}, 'Ordinary object without [[Cells]]');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(WeakRef.prototype, cb);
|
||||
}, 'WeakRef.prototype does not have a [[Cells]] internal slot');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(WeakRef, cb);
|
||||
}, 'WeakRef does not have a [[Cells]] internal slot');
|
||||
|
||||
var wr = new WeakRef({});
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(wr, cb);
|
||||
}, 'WeakRef instance');
|
||||
|
||||
var wm = new WeakMap();
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(wm, cb);
|
||||
}, 'WeakMap instance');
|
||||
|
||||
var ws = new WeakSet();
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(ws, cb);
|
||||
}, 'WeakSet instance');
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-finalization-registry.prototype.cleanupSome
|
||||
description: Throws a TypeError if this is not an Object
|
||||
info: |
|
||||
FinalizationRegistry.prototype.cleanupSome ( [ callback ] )
|
||||
|
||||
1. Let finalizationRegistry be the this value.
|
||||
2. If Type(finalizationRegistry) is not Object, throw a TypeError exception.
|
||||
3. If finalizationRegistry does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||
4. If callback is not undefined and IsCallable(callback) is false, throw a TypeError exception.
|
||||
...
|
||||
features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof FinalizationRegistry.prototype.cleanupSome, 'function');
|
||||
|
||||
var cleanupSome = FinalizationRegistry.prototype.cleanupSome;
|
||||
var cb = function() {};
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(undefined, cb);
|
||||
}, 'undefined');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(null, cb);
|
||||
}, 'null');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(true, cb);
|
||||
}, 'true');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(false, cb);
|
||||
}, 'false');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(1, cb);
|
||||
}, 'number');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call('object', cb);
|
||||
}, 'string');
|
||||
|
||||
var s = Symbol();
|
||||
assert.throws(TypeError, function() {
|
||||
cleanupSome.call(s, cb);
|
||||
}, 'symbol');
|
Loading…
Reference in New Issue