|
18 | 18 |
|
19 | 19 | QUnit.test("constructor", function (assert) { |
20 | 20 |
|
21 | | - var _comparer = EqualityComparer.create( |
22 | | - function (o) { return mx.hash(o); }, |
23 | | - function (a, b) { return a === b; } |
24 | | - ), |
| 21 | + var _comparer = EqualityComparer.create(o => mx.hash(o), (a, b) => a === b), |
25 | 22 | _d1 = new Dictionary<number, string>(), |
26 | 23 | _d2 = new Dictionary<number, string>(CreateDictionary()), |
27 | 24 | _d3 = new Dictionary<number, string>(_comparer), |
|
44 | 41 | _dic.add(1, "A"); |
45 | 42 |
|
46 | 43 | assert.ok(_dic.count() === 1, "ditionary add"); |
47 | | - assert.throws(function () { |
48 | | - _dic.add(1, "B"); |
49 | | - }, "throws an error adding duplicate key"); |
| 44 | + assert.throws(() => _dic.add(1, "B"), "throws an error adding duplicate key"); |
50 | 45 | }); |
51 | 46 |
|
52 | 47 |
|
|
82 | 77 | _arr = new Array(_dic.count()); |
83 | 78 |
|
84 | 79 | _dic.copyTo(_arr, 0); |
85 | | - |
86 | 80 | assert.deepEqual(_arr, [1, 2, 3, 4, 5], "dictionary copy to an array!"); |
87 | | - assert.throws(function () { |
88 | | - _dic.copyTo([], 0); |
89 | | - }, "throws an error when the number of elements is greater than the number of elements that the destination array can contain!"); |
| 81 | + assert.throws(() => _dic.copyTo([], 0), "throws an error when the number of elements is greater than the number of elements that the destination array can contain!"); |
90 | 82 | }); |
91 | 83 |
|
92 | 84 |
|
|
113 | 105 | var _dic = CreateDictionary(); |
114 | 106 |
|
115 | 107 | assert.ok(_dic.get(1) === "A", "dictionary get value!"); |
116 | | - assert.throws(function () { |
117 | | - _dic.get(10); |
118 | | - }, "throws an error getting non existing key!"); |
| 108 | + assert.throws(() => _dic.get(10), "throws an error getting non existing key!"); |
119 | 109 | }); |
120 | 110 |
|
121 | 111 |
|
122 | 112 | QUnit.test("set", function (assert) { |
123 | 113 |
|
124 | 114 | var _dic = CreateDictionary(); |
| 115 | + |
125 | 116 | _dic.set(1, "AA"); |
126 | | - |
127 | 117 | assert.ok(_dic.get(1) === "AA", "dictionary set value!"); |
128 | 118 |
|
129 | 119 | _dic.set(6, "F"); |
|
137 | 127 |
|
138 | 128 | assert.ok(function () { |
139 | 129 | var value: string; |
140 | | - |
141 | | - var res = _dic.tryGetValue(1, function (val) { |
142 | | - value = val; |
143 | | - }); |
| 130 | + var res = _dic.tryGetValue(1, val => value = val); |
144 | 131 |
|
145 | 132 | return res && value === "A"; |
146 | 133 |
|
|
149 | 136 |
|
150 | 137 | assert.ok(function () { |
151 | 138 | var value: string; |
152 | | - |
153 | | - var res = _dic.tryGetValue(10, function (val) { |
154 | | - value = val; |
155 | | - }); |
| 139 | + var res = _dic.tryGetValue(10, val => value = val); |
156 | 140 |
|
157 | 141 | return res === false; |
158 | 142 |
|
|
0 commit comments