Skip to content

Commit 1eaac5c

Browse files
committed
1 parent e174dfa commit 1eaac5c

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

test/unit/dictionary.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
(function () {
55

66
var Dictionary = mx.Dictionary,
7-
Comparer = mx.Comparer,
87
KeyValuePair = mx.KeyValuePair,
9-
NumericComparer = Comparer.create(function (a, b) {
10-
return a - b;
11-
});
8+
EqualityComparer = mx.EqualityComparer;
129

1310

1411
function CreateDictionary() {
@@ -28,20 +25,24 @@
2825

2926
QUnit.test("constructor", function (assert) {
3027

31-
var d1 = new Dictionary(),
32-
d2 = new Dictionary(CreateDictionary()),
33-
d3 = new Dictionary(NumericComparer),
34-
d4 = new Dictionary(5),
35-
d5 = new Dictionary(5, NumericComparer),
36-
d6 = new Dictionary(CreateDictionary(), NumericComparer);
37-
38-
39-
assert.ok(d1.count() === 0, "initialize a Dictionary!");
40-
assert.ok(d2.count() === 5, "initialize a Dictionary using specified dictionary!");
41-
assert.ok(d3.count() === 0, "initialize a Dictionary using specified comparer!");
42-
assert.ok(d4.count() === 0, "initialize a Dictionary using initial capacity!");
43-
assert.ok(d5.count() === 0, "initialize a Dictionary using using initial capacity and comparer!");
44-
assert.ok(d6.count() === 5, "initialize a Dictionary using specified dictionary and comparer!");
28+
var _comparer = EqualityComparer.create(
29+
function (o) { return mx.hash(o); },
30+
function (a, b) { return a === b; }
31+
),
32+
_d1 = new Dictionary(),
33+
_d2 = new Dictionary(CreateDictionary()),
34+
_d3 = new Dictionary(_comparer),
35+
_d4 = new Dictionary(5),
36+
_d5 = new Dictionary(5, _comparer),
37+
_d6 = new Dictionary(CreateDictionary(), _comparer);
38+
39+
40+
assert.ok(_d1.count() === 0, "initialize a Dictionary!");
41+
assert.ok(_d2.count() === 5, "initialize a Dictionary using specified dictionary!");
42+
assert.ok(_d3.count() === 0, "initialize a Dictionary using specified comparer!");
43+
assert.ok(_d4.count() === 0, "initialize a Dictionary using initial capacity!");
44+
assert.ok(_d5.count() === 0, "initialize a Dictionary using using initial capacity and comparer!");
45+
assert.ok(_d6.count() === 5, "initialize a Dictionary using specified dictionary and comparer!");
4546
});
4647

4748

@@ -78,7 +79,7 @@
7879
var _dic = CreateDictionary();
7980

8081
assert.ok(_dic.containsValue("A") === true, "dictionary contains value!");
81-
assert.ok(_dic.containsKey("Z") === false, "dictionary does not contain value!");
82+
assert.ok(_dic.containsValue("Z") === false, "dictionary does not contain value!");
8283
});
8384

8485

0 commit comments

Comments
 (0)