Skip to content

Commit e1fe54d

Browse files
committed
typescript es6 compliance
1 parent 16dcd41 commit e1fe54d

File tree

15 files changed

+923
-984
lines changed

15 files changed

+923
-984
lines changed

build/multiplex.d.ts

Lines changed: 417 additions & 458 deletions
Large diffs are not rendered by default.

src/typescript/multiplex.d.ts

Lines changed: 417 additions & 458 deletions
Large diffs are not rendered by default.

test/typescript/collection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module MxTests {
2+
"use strict";
23

34
import Collection = mx.Collection;
4-
5+
var Collection = mx.Collection;
56

67

78
/* Factory methods

test/typescript/dictionary.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module MxTests {
2+
"use strict";
23

34
import Dictionary = mx.Dictionary;
4-
import KeyValuePair = mx.KeyValuePair;
5-
import EqualityComparer = mx.EqualityComparer;
5+
6+
var Dictionary = mx.Dictionary,
7+
KeyValuePair = mx.KeyValuePair,
8+
EqualityComparer = mx.EqualityComparer;
69

710

811

@@ -124,7 +127,7 @@
124127
QUnit.test("set", function (assert) {
125128

126129
var _dic = CreateDictionary();
127-
130+
128131
_dic.set(1, "AA");
129132
assert.ok(_dic.get(1) === "AA", "dictionary set value!");
130133

@@ -171,11 +174,8 @@
171174
_pair2 = new KeyValuePair(1, "A");
172175

173176
assert.ok(_pair1.key === 1 && _pair1.value === "A", "KeyValuePair get key/value!");
174-
175-
_pair1.key = 2;
176-
_pair1.value = "B";
177-
assert.ok(_pair1.key === 1 && _pair1.value === "A", "KeyValuePair key/value immutable!");
178-
177+
assert.throws(() => _pair1.key = 2, "throws an error trysing to set KeyValuePair key!");
178+
assert.throws(() => _pair1.value = "B", "throws an error trysing to set KeyValuePair value!");
179179
assert.ok(mx.hash(_pair1) === mx.hash(_pair2), "KeyValuePair get hash code!");
180180
assert.ok(mx.equals(_pair1, _pair2), "KeyValuePair equality check!");
181181
});

test/typescript/hashset.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
module MxTests {
2+
"use strict";
23

34
import HashSet = mx.HashSet;
4-
import EqualityComparer = mx.EqualityComparer;
55

6+
var HashSet = mx.HashSet,
7+
EqualityComparer = mx.EqualityComparer;
68

79

810
/* Factory methods
911
---------------------------------------------------------------------- */
1012

1113
interface SimpleObject {
1214
name: string;
13-
val: number;
15+
value: number;
1416
}
1517

1618

@@ -21,12 +23,12 @@
2123

2224
function CreateObjectHashSet(): HashSet<SimpleObject> {
2325

24-
var _items: SimpleObject[] = [{ name: "A", val: 1 }, { name: "A", val: 2 }, { name: "B", val: 3 }, { name: "B", val: 4 }],
26+
var _items: SimpleObject[] = [{ name: "A", value: 1 }, { name: "A", value: 2 }, { name: "B", value: 3 }, { name: "B", value: 4 }],
2527
_comparer = EqualityComparer.create<SimpleObject>(obj => mx.hash(obj.name), (a, b) => a.name === b.name);
2628

2729
return new HashSet<SimpleObject>(_items, _comparer);
2830
}
29-
31+
3032

3133

3234
/* Tests
@@ -51,8 +53,8 @@
5153

5254
assert.ok(_hash1.add(6) === true, "add item to a HashSet of numbers!");
5355
assert.ok(_hash1.add(1) === false, "add existing item to a HashSet of numbers!");
54-
assert.ok(_hash2.add({ name: "C", val: 5 }) === true, "add item to a HashSet of objects!");
55-
assert.ok(_hash2.add({ name: "A", val: 5 }) === false, "add an existing item to a HashSet of objects!");
56+
assert.ok(_hash2.add({ name: "C", value: 5 }) === true, "add item to a HashSet of objects!");
57+
assert.ok(_hash2.add({ name: "A", value: 5 }) === false, "add an existing item to a HashSet of objects!");
5658
});
5759

5860

@@ -72,8 +74,8 @@
7274

7375
assert.ok(_hash1.contains(1) === true, "HashSet of numbers contains an item!");
7476
assert.ok(_hash1.contains(6) === false, "HashSet of numbers does not contain an item!");
75-
assert.ok(_hash2.contains({ name: "A", val: 5 }) === true, "HashSet of objects contains an item!");
76-
assert.ok(_hash2.contains({ name: "C", val: 5 }) === false, "HashSet of objects does not contain an item!");
77+
assert.ok(_hash2.contains({ name: "A", value: 5 }) === true, "HashSet of objects contains an item!");
78+
assert.ok(_hash2.contains({ name: "C", value: 5 }) === false, "HashSet of objects does not contain an item!");
7779
});
7880

7981

@@ -95,7 +97,7 @@
9597
_hash2 = CreateObjectHashSet();
9698

9799
assert.ok(_hash1.comparer() === mx.EqualityComparer.defaultComparer, "HashSet default comparer!");
98-
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!");
99101
});
100102

101103

@@ -106,8 +108,8 @@
106108

107109
assert.ok(_hash1.remove(1) === true, "HashSet of numbers remove an item!");
108110
assert.ok(_hash1.remove(1) === false, "HashSet of numbers remove non existing item!");
109-
assert.ok(_hash2.remove({ name: "A", val: 1 }) === true, "HashSet of objects remove an item!");
110-
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!");
111113
});
112114

113115

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

123-
assert.ok(_hash2.removeWhere(t => t.val < 3) === 1, "HashSet of objects remove with predicate, get number of items removed!");
124-
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!");
125127
assert.ok(_hash2.count() === 1, "HashSet of objects remove with predicate, get count!");
126128
});
127129

@@ -133,11 +135,11 @@
133135
_hash3 = CreateNumericHashSet();
134136

135137
_hash1.exceptWith([1, 2, 3]);
136-
_hash2.exceptWith([{ name: "A", val: 0 }]);
138+
_hash2.exceptWith([{ name: "A", value: 0 }]);
137139
_hash3.exceptWith(CreateNumericHashSet());
138140

139141
assert.ok(_hash1.count() === 2 && _hash1.contains(1) === false, "HashSet of numbers except a collection, get count!");
140-
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!");
141143
assert.ok(_hash3.count() === 0, "HashSet of numbers except an equal set, get count!");
142144
});
143145

@@ -149,11 +151,11 @@
149151
_hash3 = CreateNumericHashSet();
150152

151153
_hash1.intersectWith([1, 2, 3]);
152-
_hash2.intersectWith([{ name: "A", val: 0 }]);
154+
_hash2.intersectWith([{ name: "A", value: 0 }]);
153155
_hash3.intersectWith(CreateNumericHashSet());
154156

155157
assert.ok(_hash1.count() === 3 && _hash1.contains(1) === true, "HashSet of numbers intersect with a collection, get count!");
156-
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!");
157159
assert.ok(_hash3.count() === 5, "HashSet of numbers intersect with an equal set, get count!");
158160
});
159161

@@ -212,7 +214,7 @@
212214
_hash2 = CreateObjectHashSet();
213215

214216
assert.ok(_hash1.overlaps([1, 2, 3]) === true, "HashSet of numbers overlaps with another collection!");
215-
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!");
216218
assert.ok(new HashSet().overlaps([1, 2, 3]) === false, "an empty HashSet does not overlap with another collection!");
217219
});
218220

@@ -236,13 +238,13 @@
236238
_hash3 = CreateNumericHashSet();
237239

238240
_hash1.symmetricExceptWith([2, 3, 4]);
239-
_hash2.symmetricExceptWith([{ name: "A", val: 0 }]);
241+
_hash2.symmetricExceptWith([{ name: "A", value: 0 }]);
240242
_hash3.exceptWith(CreateNumericHashSet());
241243

242244
assert.ok(_hash1.count() === 2, "HashSet of numbers symmetric except another collection, get count!");
243245
assert.ok(_hash1.contains(1) === true && _hash1.contains(5) === true, "HashSet of numbers symmetric except another collection, check contains!");
244246
assert.ok(_hash2.count() === 1, "HashSet of objects symmetric except another collection, get count!");
245-
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!");
246248
assert.ok(_hash3.count() === 0, "HashSet of numbers symmetric except an equal set, get count!");
247249
});
248250

@@ -254,13 +256,13 @@
254256
_hash3 = CreateNumericHashSet();
255257

256258
_hash1.unionWith([5, 6, 7, 8]);
257-
_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 }]);
258260
_hash3.unionWith(CreateNumericHashSet());
259261

260262
assert.ok(_hash1.count() === 8, "HashSet of numbers union with another collection, get count!");
261263
assert.ok(_hash1.contains(1) === true && _hash1.contains(8) === true, "HashSet of numbers union with another collection, check contains!");
262264
assert.ok(_hash2.count() === 4, "HashSet of objects union with another collection, get count!");
263-
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!");
264266
assert.ok(_hash3.count() === 5, "HashSet of numbers union with an equal set, get count!");
265267
});
266268

@@ -271,6 +273,6 @@
271273
_hash2 = CreateObjectHashSet();
272274

273275
assert.deepEqual(_hash1.select(t => t * 2).where(t => t > 5).toArray(), [6, 8, 10], "select-where-toArray over a HashSet of numbers!");
274-
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!");
275277
});
276278
}

test/typescript/linkedlist.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module MxTests {
2+
"use strict";
23

3-
import LinkedListNode = mx.LinkedListNode;
44
import LinkedList = mx.LinkedList;
55

6+
var LinkedList = mx.LinkedList,
7+
LinkedListNode = mx.LinkedListNode;
8+
69

710

811
/* Factory methods

test/typescript/linq.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module MxTests {
2+
"use strict";
23

34

45
/* Classes
@@ -10,15 +11,15 @@
1011

1112

1213
// class overriding '__hash__' and '__equals__' methods.
13-
class SimpleClassWithComparer {
14+
class SimpleClassWithComparer implements mx.RuntimeComparer {
1415

1516
constructor(val: number) {
1617
this.value = val;
1718
this.name = val.toString();
1819
}
1920

20-
public value: number;
2121
public name: string;
22+
public value: number;
2223

2324
__hash__(): number {
2425
return mx.hash(this.value, this.name);
@@ -34,9 +35,6 @@
3435
/* Factory methods
3536
---------------------------------------------------------------------- */
3637

37-
var _time = new Date().getTime();
38-
39-
4038
function CreateObjectLiteralArray(): Object[] {
4139
return mx.range(0, 10).select(t => ({})).toArray();
4240
}
@@ -79,7 +77,7 @@
7977

8078

8179
function CreateDateArray(): Date[] {
82-
return mx.range(0, 10).select(t => new Date(_time + t)).toArray();
80+
return mx.range(0, 10).select(t => new Date(new Date().getTime() + t)).toArray();
8381
}
8482

8583

test/typescript/list.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module MxTests {
2-
3-
import List = mx.List;
2+
"use strict";
43

4+
import List = mx.List;
5+
var List = mx.List;
56

67

78
/* Factory methods
@@ -63,9 +64,6 @@
6364

6465
assert.ok(_rlist.count() === 10, "readOnlyCollection count!");
6566
assert.ok(_rlist[0] === 0, "readOnlyCollection get!");
66-
67-
_rlist[0] = 100;
68-
assert.ok(_rlist[0] === 0, "readOnlyCollection set!");
6967
});
7068

7169

test/typescript/lookup.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
module MxTests {
2+
"use strict";
3+
4+
import Lookup = mx.Lookup;
25

36

47
/* Factory methods
58
---------------------------------------------------------------------- */
69

7-
function CreateLookup(): mx.Lookup<number, number> {
10+
function CreateLookup(): Lookup<number, number> {
811
return mx([1, 1, 2, 3, 3, 4, 4, 4]).toLookup(t => t);
912
}
1013

test/typescript/mx.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module MxTests {
2+
"use strict";
23

34
import Enumerator = mx.Enumerator;
45
import Enumerable = mx.Enumerable;
56

7+
var Enumerator = mx.Enumerator,
8+
Enumerable = mx.Enumerable;
69

710

811
/* Factory methods

test/typescript/queue.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module MxTests {
2+
"use strict";
23

34
import Queue = mx.Queue;
4-
5+
var Queue = mx.Queue;
56

67

78
/* Factory methods

0 commit comments

Comments
 (0)