|
4 | 4 | (function () {
|
5 | 5 |
|
6 | 6 | var Dictionary = mx.Dictionary,
|
7 |
| - Comparer = mx.Comparer, |
8 | 7 | KeyValuePair = mx.KeyValuePair,
|
9 |
| - NumericComparer = Comparer.create(function (a, b) { |
10 |
| - return a - b; |
11 |
| - }); |
| 8 | + EqualityComparer = mx.EqualityComparer; |
12 | 9 |
|
13 | 10 |
|
14 | 11 | function CreateDictionary() {
|
|
28 | 25 |
|
29 | 26 | QUnit.test("constructor", function (assert) {
|
30 | 27 |
|
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!"); |
45 | 46 | });
|
46 | 47 |
|
47 | 48 |
|
|
78 | 79 | var _dic = CreateDictionary();
|
79 | 80 |
|
80 | 81 | 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!"); |
82 | 83 | });
|
83 | 84 |
|
84 | 85 |
|
|
0 commit comments