Skip to content

Commit 38f14b4

Browse files
committed
"use strict"
1 parent 27ec60d commit 38f14b4

File tree

13 files changed

+52
-37
lines changed

13 files changed

+52
-37
lines changed

test/unit/collection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var Collection = mx.Collection;
78

test/unit/dictionary.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var Dictionary = mx.Dictionary,
78
KeyValuePair = mx.KeyValuePair,
@@ -191,9 +192,13 @@
191192

192193
assert.ok(_pair1.key === 1 && _pair1.value === "A", "KeyValuePair get key/value!");
193194

194-
_pair1.key = 2;
195-
_pair1.value = "B";
196-
assert.ok(_pair1.key === 1 && _pair1.value === "A", "KeyValuePair key/value immutable!");
195+
assert.throws(function () {
196+
_pair1.key = 2;
197+
}, "throws an error trysing to set KeyValuePair key!");
198+
199+
assert.throws(function () {
200+
_pair1.value = "B";
201+
}, "throws an error trysing to set KeyValuePair value!");
197202

198203
assert.ok(mx.hash(_pair1) === mx.hash(_pair2), "KeyValuePair get hash code!");
199204
assert.ok(mx.equals(_pair1, _pair2), "KeyValuePair equality check!");

test/unit/hashset.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var HashSet = mx.HashSet,
78
EqualityComparer = mx.EqualityComparer;
@@ -17,7 +18,7 @@
1718

1819

1920
function CreateObjectHashSet() {
20-
var _items = [{ name: "A", val: 1 }, { name: "A", val: 2 }, { name: "B", val: 3 }, { name: "B", val: 4 }],
21+
var _items = [{ name: "A", value: 1 }, { name: "A", value: 2 }, { name: "B", value: 3 }, { name: "B", value: 4 }],
2122
_comparer = {
2223
hash: function (o) { return mx.hash(o.name); },
2324
equals: function (a, b) { return a.name === b.name; }
@@ -50,8 +51,8 @@
5051

5152
assert.ok(_hash1.add(6) === true, "add item to a HashSet of numbers!");
5253
assert.ok(_hash1.add(1) === false, "add existing item to a HashSet of numbers!");
53-
assert.ok(_hash2.add({ name: "C", val: 5 }) === true, "add item to a HashSet of objects!");
54-
assert.ok(_hash2.add({ name: "A", val: 5 }) === false, "add an existing item to a HashSet of objects!");
54+
assert.ok(_hash2.add({ name: "C", value: 5 }) === true, "add item to a HashSet of objects!");
55+
assert.ok(_hash2.add({ name: "A", value: 5 }) === false, "add an existing item to a HashSet of objects!");
5556
});
5657

5758

@@ -71,8 +72,8 @@
7172

7273
assert.ok(_hash1.contains(1) === true, "HashSet of numbers contains an item!");
7374
assert.ok(_hash1.contains(6) === false, "HashSet of numbers does not contain an item!");
74-
assert.ok(_hash2.contains({ name: "A", val: 5 }) === true, "HashSet of objects contains an item!");
75-
assert.ok(_hash2.contains({ name: "C", val: 5 }) === false, "HashSet of objects does not contain an item!");
75+
assert.ok(_hash2.contains({ name: "A", value: 5 }) === true, "HashSet of objects contains an item!");
76+
assert.ok(_hash2.contains({ name: "C", value: 5 }) === false, "HashSet of objects does not contain an item!");
7677
});
7778

7879

@@ -96,7 +97,7 @@
9697
_hash2 = CreateObjectHashSet();
9798

9899
assert.ok(_hash1.comparer() === EqualityComparer.defaultComparer, "HashSet default comparer!");
99-
assert.ok(_hash2.comparer().equals({ name: "A", val: 1 }, { name: "A", val: 2 }), "HashSet custom comparer!");
100+
assert.ok(_hash2.comparer().equals({ name: "A", value: 1 }, { name: "A", value: 2 }), "HashSet custom comparer!");
100101
});
101102

102103

@@ -107,8 +108,8 @@
107108

108109
assert.ok(_hash1.remove(1) === true, "HashSet of numbers remove an item!");
109110
assert.ok(_hash1.remove(1) === false, "HashSet of numbers remove non existing item!");
110-
assert.ok(_hash2.remove({ name: "A", val: 1 }) === true, "HashSet of objects remove an item!");
111-
assert.ok(_hash2.remove({ name: "A", val: 1 }) === false, "HashSet of objects remove non existing item!");
111+
assert.ok(_hash2.remove({ name: "A", value: 1 }) === true, "HashSet of objects remove an item!");
112+
assert.ok(_hash2.remove({ name: "A", value: 1 }) === false, "HashSet of objects remove non existing item!");
112113
});
113114

114115

@@ -121,8 +122,8 @@
121122
assert.ok(_hash1.removeWhere("t => t < 3") === 0, "HashSet of numbers remove with invalid predicate, get number of items removed!");
122123
assert.ok(_hash1.count() === 3, "HashSet of numbers remove with predicate, get count!");
123124

124-
assert.ok(_hash2.removeWhere("t => t.val < 3") === 1, "HashSet of objects remove with predicate, get number of items removed!");
125-
assert.ok(_hash2.removeWhere("t => t.val < 3") === 0, "HashSet of objects remove with invalid predicate, get number of items removed!");
125+
assert.ok(_hash2.removeWhere("t => t.value < 3") === 1, "HashSet of objects remove with predicate, get number of items removed!");
126+
assert.ok(_hash2.removeWhere("t => t.value < 3") === 0, "HashSet of objects remove with invalid predicate, get number of items removed!");
126127
assert.ok(_hash2.count() === 1, "HashSet of objects remove with predicate, get count!");
127128
});
128129

@@ -134,11 +135,11 @@
134135
_hash3 = CreateNumericHashSet();
135136

136137
_hash1.exceptWith([1, 2, 3]);
137-
_hash2.exceptWith([{ name: "A", val: 0 }]);
138+
_hash2.exceptWith([{ name: "A", value: 0 }]);
138139
_hash3.exceptWith(CreateNumericHashSet());
139140

140141
assert.ok(_hash1.count() === 2 && _hash1.contains(1) === false, "HashSet of numbers except a collection, get count!");
141-
assert.ok(_hash2.count() === 1 && _hash2.contains({ name: "A", val: 0 }) === false, "HashSet of objects except a collection, get count!");
142+
assert.ok(_hash2.count() === 1 && _hash2.contains({ name: "A", value: 0 }) === false, "HashSet of objects except a collection, get count!");
142143
assert.ok(_hash3.count() === 0, "HashSet of numbers except an equal set, get count!");
143144
});
144145

@@ -150,11 +151,11 @@
150151
_hash3 = CreateNumericHashSet();
151152

152153
_hash1.intersectWith([1, 2, 3]);
153-
_hash2.intersectWith([{ name: "A", val: 0 }]);
154+
_hash2.intersectWith([{ name: "A", value: 0 }]);
154155
_hash3.intersectWith(CreateNumericHashSet());
155156

156157
assert.ok(_hash1.count() === 3 && _hash1.contains(1) === true, "HashSet of numbers intersect with a collection, get count!");
157-
assert.ok(_hash2.count() === 1 && _hash2.contains({ name: "A", val: 0 }) === true, "HashSet of objects intersect with a collection, get count!");
158+
assert.ok(_hash2.count() === 1 && _hash2.contains({ name: "A", value: 0 }) === true, "HashSet of objects intersect with a collection, get count!");
158159
assert.ok(_hash3.count() === 5, "HashSet of numbers intersect with an equal set, get count!");
159160
});
160161

@@ -213,7 +214,7 @@
213214
_hash2 = CreateObjectHashSet();
214215

215216
assert.ok(_hash1.overlaps([1, 2, 3]) === true, "HashSet of numbers overlaps with another collection!");
216-
assert.ok(_hash2.overlaps([{ name: "A", val: 0 }]) === true, "HashSet of objects overlaps with another collection!");
217+
assert.ok(_hash2.overlaps([{ name: "A", value: 0 }]) === true, "HashSet of objects overlaps with another collection!");
217218
assert.ok(new HashSet().overlaps([1, 2, 3]) === false, "an empty HashSet does not overlap with another collection!");
218219
});
219220

@@ -237,13 +238,13 @@
237238
_hash3 = CreateNumericHashSet();
238239

239240
_hash1.symmetricExceptWith([2, 3, 4]);
240-
_hash2.symmetricExceptWith([{ name: "A", val: 0 }]);
241+
_hash2.symmetricExceptWith([{ name: "A", value: 0 }]);
241242
_hash3.exceptWith(CreateNumericHashSet());
242243

243244
assert.ok(_hash1.count() === 2, "HashSet of numbers symmetric except another collection, get count!");
244245
assert.ok(_hash1.contains(1) === true && _hash1.contains(5) === true, "HashSet of numbers symmetric except another collection, check contains!");
245246
assert.ok(_hash2.count() === 1, "HashSet of objects symmetric except another collection, get count!");
246-
assert.ok(_hash2.contains({ name: "A", val: 0 }) === false && _hash2.contains({ name: "B", val: 0 }) === true, "HashSet of objects symmetric except another collection, check contains!");
247+
assert.ok(_hash2.contains({ name: "A", value: 0 }) === false && _hash2.contains({ name: "B", value: 0 }) === true, "HashSet of objects symmetric except another collection, check contains!");
247248
assert.ok(_hash3.count() === 0, "HashSet of numbers symmetric except an equal set, get count!");
248249
});
249250

@@ -255,13 +256,13 @@
255256
_hash3 = CreateNumericHashSet();
256257

257258
_hash1.unionWith([5, 6, 7, 8]);
258-
_hash2.unionWith([{ name: "A", val: 5 }, { name: "B", val: 6 }, { name: "C", val: 7 }, { name: "D", val: 8 }]);
259+
_hash2.unionWith([{ name: "A", value: 5 }, { name: "B", value: 6 }, { name: "C", value: 7 }, { name: "D", value: 8 }]);
259260
_hash3.unionWith(CreateNumericHashSet());
260261

261262
assert.ok(_hash1.count() === 8, "HashSet of numbers union with another collection, get count!");
262263
assert.ok(_hash1.contains(1) === true && _hash1.contains(8) === true, "HashSet of numbers union with another collection, check contains!");
263264
assert.ok(_hash2.count() === 4, "HashSet of objects union with another collection, get count!");
264-
assert.ok(_hash2.contains({ name: "A", val: 0 }) === true && _hash2.contains({ name: "D", val: 0 }) === true, "HashSet of objects union with another collection, check contains!");
265+
assert.ok(_hash2.contains({ name: "A", value: 0 }) === true && _hash2.contains({ name: "D", value: 0 }) === true, "HashSet of objects union with another collection, check contains!");
265266
assert.ok(_hash3.count() === 5, "HashSet of numbers union with an equal set, get count!");
266267
});
267268

@@ -272,7 +273,7 @@
272273
_hash2 = CreateObjectHashSet();
273274

274275
assert.deepEqual(_hash1.select("t => t * 2").where("t => t > 5").toArray(), [6, 8, 10], "select-where-toArray over a HashSet of numbers!");
275-
assert.deepEqual(_hash2.select("t => t.val * 2").where("t => t > 5").toArray(), [6], "select-where-toArray over a HashSet of objects!");
276+
assert.deepEqual(_hash2.select("t => t.value * 2").where("t => t > 5").toArray(), [6], "select-where-toArray over a HashSet of objects!");
276277
});
277278

278279

test/unit/linkedlist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var LinkedList = mx.LinkedList,
78
LinkedListNode = mx.LinkedListNode;

test/unit/linq.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
(function () {
5-
5+
"use strict";
66

77
/* Classes
88
---------------------------------------------------------------------- */
@@ -33,9 +33,6 @@
3333
/* Factory methods
3434
---------------------------------------------------------------------- */
3535

36-
var _time = new Date().getTime();
37-
38-
3936
function CreateObjectLiteralArray() {
4037
return mx.range(0, 10).select(function () {
4138
return {};
@@ -91,7 +88,7 @@
9188

9289
function CreateDateArray() {
9390
return mx.range(0, 10).select(function (t) {
94-
return new Date(_time + t);
91+
return new Date(new Date().getTime() + t);
9592
}).toArray();
9693
}
9794

test/unit/list.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var List = mx.List;
78

@@ -66,9 +67,6 @@
6667

6768
assert.ok(_rlist.count() === 10, "readOnlyCollection count!");
6869
assert.ok(_rlist[0] === 0, "readOnlyCollection get!");
69-
70-
_rlist[0] = 100;
71-
assert.ok(_rlist[0] === 0, "readOnlyCollection set!");
7270
});
7371

7472

test/unit/lookup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
(function () {
5-
5+
"use strict";
66

77
/* Factory methods
88
---------------------------------------------------------------------- */

test/unit/mx.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var Enumerator = mx.Enumerator;
78

test/unit/queue.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var Queue = mx.Queue;
78

test/unit/readonlycollection.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
(function () {
5+
"use strict";
56

67
var List = mx.List,
78
ReadOnlyCollection = mx.ReadOnlyCollection;
@@ -42,11 +43,17 @@
4243

4344
assert.ok(_col[0] === 1, "indexer get!");
4445

45-
_col[0] = 0;
46-
assert.ok(_col[0] === 1, "indexer set!");
47-
48-
_col[10] = 0;
49-
assert.ok(_col[10] === undefined, "out of range indexer set!");
46+
assert.ok(function () {
47+
try { _col[0] = 0; }
48+
catch (e) { }
49+
return _col[0] === 1;
50+
}, "indexer set!");
51+
52+
assert.ok(function () {
53+
try { _col[10] = 0; }
54+
catch (e) { }
55+
return _col[10] === undefined;
56+
}, "out of range indexer set!");
5057
});
5158

5259

0 commit comments

Comments
 (0)