-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #486 from canjs/i468-multiple-entries-support
weak-reference-set does mutiple entries support
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require("./map-deep-merge-test"); | ||
require("./weak-reference-set-test"); | ||
|
||
var idMerge = require("./id-merge"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var QUnit = require('steal-qunit'); | ||
var WeakReferenceSet = require('./weak-reference-set'); | ||
|
||
QUnit.module("weak-reference-set"); | ||
|
||
QUnit.test("Multiple entries support #468", function(assert) { | ||
var set = new WeakReferenceSet(); | ||
|
||
var item1 = {}; | ||
var item2 = {}; | ||
var item3 = {}; | ||
|
||
var items = [item1, item2, item3]; | ||
|
||
for (var index = 0; index < items.length; index++) { | ||
set.addReference(items[index]); | ||
} | ||
|
||
assert.equal(set.get(item1), item1, "Got the first item"); | ||
assert.equal(set.get(item2), item2, "Got the second item"); | ||
assert.equal(set.get(item3), item3, "Got the third item"); | ||
}); | ||
|
||
QUnit.test("Multiple entries support with multiple reference #468", function(assert) { | ||
var set = new WeakReferenceSet(); | ||
|
||
var obj = {}; | ||
var obj2 = {}; | ||
|
||
for (var index = 0; index < 3; index++) { | ||
set.addReference(obj); | ||
} | ||
|
||
set.addReference(obj2); | ||
|
||
assert.equal(set.referenceCount(obj), 3, "Got the correct reference count"); | ||
assert.equal(set.referenceCount(obj2), 1, "Got correct reference count for multiple entries"); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters