mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Cleanup some tests for FinalizationGroup
This commit is contained in:
parent
9dfb9e14e0
commit
6242304cd0
48
test/built-ins/FinalizationGroup/prototype/cleanupSome/cleanup-prevented-with-reference.js
vendored
Normal file
48
test/built-ins/FinalizationGroup/prototype/cleanupSome/cleanup-prevented-with-reference.js
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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.prototype.cleanupSome
|
||||||
|
description: Cleanup might be prevented with a reference usage;
|
||||||
|
info: |
|
||||||
|
FinalizationGroup.prototype.cleanupSome ( [ callback ] )
|
||||||
|
|
||||||
|
1. Let finalizationGroup be the this value.
|
||||||
|
2. If Type(finalizationGroup) is not Object, throw a TypeError exception.
|
||||||
|
3. If finalizationGroup 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 ? CleanupFinalizationGroup(finalizationGroup, callback).
|
||||||
|
6. Return undefined.
|
||||||
|
features: [FinalizationGroup, arrow-function, async-functions, async-iteration, class, host-gc-required]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var holdingsList;
|
||||||
|
function cb(iterator) {
|
||||||
|
holdingsList = [...iterator];
|
||||||
|
};
|
||||||
|
var fg = new FinalizationGroup(function() {});
|
||||||
|
|
||||||
|
function emptyCells() {
|
||||||
|
var x;
|
||||||
|
(function() {
|
||||||
|
var a = {};
|
||||||
|
b = {};
|
||||||
|
x = {};
|
||||||
|
var y = {};
|
||||||
|
fg.register(x, 'x');
|
||||||
|
fg.register(a, 'a');
|
||||||
|
fg.register(y, y);
|
||||||
|
fg.register(b, 'b');
|
||||||
|
var b;
|
||||||
|
})();
|
||||||
|
$262.gc();
|
||||||
|
x; // This is an intentional reference to x, please leave it here, after the GC
|
||||||
|
}
|
||||||
|
|
||||||
|
emptyCells();
|
||||||
|
fg.cleanupSome(cb);
|
||||||
|
|
||||||
|
// The order is per implementation so we can't use compareArray without sorting
|
||||||
|
assert.sameValue(holdingsList.length, 2);
|
||||||
|
assert(holdingsList.includes('a'));
|
||||||
|
assert(holdingsList.includes('b'));
|
@ -30,8 +30,6 @@ assert.sameValue(fg.register(target, false), undefined, 'false');
|
|||||||
assert.sameValue(fg.register(target, true), undefined, 'true');
|
assert.sameValue(fg.register(target, true), undefined, 'true');
|
||||||
assert.sameValue(fg.register(target, Symbol()), undefined, 'symbol');
|
assert.sameValue(fg.register(target, Symbol()), undefined, 'symbol');
|
||||||
assert.sameValue(fg.register(target, {}), undefined, 'object');
|
assert.sameValue(fg.register(target, {}), undefined, 'object');
|
||||||
assert.sameValue(fg.register(target, target), undefined, 'same as target');
|
|
||||||
assert.sameValue(fg.register(target, fg), undefined, 'same as fg instance');
|
assert.sameValue(fg.register(target, fg), undefined, 'same as fg instance');
|
||||||
assert.sameValue(fg.register(target, target, target), undefined, 'target, and same as unregisterToken');
|
|
||||||
assert.sameValue(fg.register(target, 1), undefined, 'number');
|
assert.sameValue(fg.register(target, 1), undefined, 'number');
|
||||||
assert.sameValue(fg.register(target, 'holdings'), undefined, 'string');
|
assert.sameValue(fg.register(target, 'holdings'), undefined, 'string');
|
||||||
|
26
test/built-ins/FinalizationGroup/prototype/register/holdings-same-as-target.js
vendored
Normal file
26
test/built-ins/FinalizationGroup/prototype/register/holdings-same-as-target.js
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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.prototype.register
|
||||||
|
description: holdings may be the same as target
|
||||||
|
info: |
|
||||||
|
FinalizationGroup.prototype.register ( target , holdings [, unregisterToken ] )
|
||||||
|
|
||||||
|
1. Let finalizationGroup be the this value.
|
||||||
|
2. If Type(finalizationGroup) is not Object, throw a TypeError exception.
|
||||||
|
3. If Type(target) is not Object, throw a TypeError exception.
|
||||||
|
4. If finalizationGroup does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||||
|
5. If Type(unregisterToken) is not Object,
|
||||||
|
a. If unregisterToken is not undefined, throw a TypeError exception.
|
||||||
|
b. Set unregisterToken to empty.
|
||||||
|
6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
|
||||||
|
7. Append cell to finalizationGroup.[[Cells]].
|
||||||
|
8. Return undefined.
|
||||||
|
features: [FinalizationGroup]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fg = new FinalizationGroup(function() {});
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
assert.sameValue(fg.register(target, target), undefined);
|
@ -0,0 +1,26 @@
|
|||||||
|
// 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.prototype.register
|
||||||
|
description: unregisterToken may be the same as holdings and target
|
||||||
|
info: |
|
||||||
|
FinalizationGroup.prototype.register ( target , holdings [, unregisterToken ] )
|
||||||
|
|
||||||
|
1. Let finalizationGroup be the this value.
|
||||||
|
2. If Type(finalizationGroup) is not Object, throw a TypeError exception.
|
||||||
|
3. If Type(target) is not Object, throw a TypeError exception.
|
||||||
|
4. If finalizationGroup does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||||
|
5. If Type(unregisterToken) is not Object,
|
||||||
|
a. If unregisterToken is not undefined, throw a TypeError exception.
|
||||||
|
b. Set unregisterToken to empty.
|
||||||
|
6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
|
||||||
|
7. Append cell to finalizationGroup.[[Cells]].
|
||||||
|
8. Return undefined.
|
||||||
|
features: [FinalizationGroup]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fg = new FinalizationGroup(function() {});
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
assert.sameValue(fg.register(target, target, target), undefined);
|
27
test/built-ins/FinalizationGroup/prototype/register/unregisterToken-same-as-holdings.js
vendored
Normal file
27
test/built-ins/FinalizationGroup/prototype/register/unregisterToken-same-as-holdings.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// 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.prototype.register
|
||||||
|
description: unregisterToken may be the same as holdings
|
||||||
|
info: |
|
||||||
|
FinalizationGroup.prototype.register ( target , holdings [, unregisterToken ] )
|
||||||
|
|
||||||
|
1. Let finalizationGroup be the this value.
|
||||||
|
2. If Type(finalizationGroup) is not Object, throw a TypeError exception.
|
||||||
|
3. If Type(target) is not Object, throw a TypeError exception.
|
||||||
|
4. If finalizationGroup does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||||
|
5. If Type(unregisterToken) is not Object,
|
||||||
|
a. If unregisterToken is not undefined, throw a TypeError exception.
|
||||||
|
b. Set unregisterToken to empty.
|
||||||
|
6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
|
||||||
|
7. Append cell to finalizationGroup.[[Cells]].
|
||||||
|
8. Return undefined.
|
||||||
|
features: [FinalizationGroup]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fg = new FinalizationGroup(function() {});
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
var holdings = {};
|
||||||
|
assert.sameValue(fg.register(target, holdings, holdings), undefined);
|
26
test/built-ins/FinalizationGroup/prototype/register/unregisterToken-same-as-target.js
vendored
Normal file
26
test/built-ins/FinalizationGroup/prototype/register/unregisterToken-same-as-target.js
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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.prototype.register
|
||||||
|
description: unregisterToken may be the same as target
|
||||||
|
info: |
|
||||||
|
FinalizationGroup.prototype.register ( target , holdings [, unregisterToken ] )
|
||||||
|
|
||||||
|
1. Let finalizationGroup be the this value.
|
||||||
|
2. If Type(finalizationGroup) is not Object, throw a TypeError exception.
|
||||||
|
3. If Type(target) is not Object, throw a TypeError exception.
|
||||||
|
4. If finalizationGroup does not have a [[Cells]] internal slot, throw a TypeError exception.
|
||||||
|
5. If Type(unregisterToken) is not Object,
|
||||||
|
a. If unregisterToken is not undefined, throw a TypeError exception.
|
||||||
|
b. Set unregisterToken to empty.
|
||||||
|
6. Let cell be the Record { [[Target]] : target, [[Holdings]]: holdings, [[UnregisterToken]]: unregisterToken }.
|
||||||
|
7. Append cell to finalizationGroup.[[Cells]].
|
||||||
|
8. Return undefined.
|
||||||
|
features: [FinalizationGroup]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fg = new FinalizationGroup(function() {});
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
assert.sameValue(fg.register(target, '1', target), undefined);
|
Loading…
x
Reference in New Issue
Block a user