Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 01114cd

Browse files
Fixing tests
1 parent 5b2aa35 commit 01114cd

13 files changed

+2771
-2067
lines changed

tests/concurrency/historicalscheduler.js

+32-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
(function () {
2+
/* jshint undef: true, unused: true */
3+
/* globals QUnit, test, Rx, equal, ok */
4+
25
QUnit.module('HistoricalScheduler');
36

47
var HistoricalScheduler = Rx.HistoricalScheduler;
@@ -47,13 +50,13 @@
4750

4851
var list = [];
4952

50-
s.scheduleAbsolute(time(0), function () { list.push(new Timestamped(1, s.now())); });
51-
s.scheduleAbsolute(time(1), function () { list.push(new Timestamped(2, s.now())); });
52-
s.scheduleAbsolute(time(2), function () { s.stop(); });
53-
s.scheduleAbsolute(time(3), function () { list.push(new Timestamped(3, s.now())); });
54-
s.scheduleAbsolute(time(4), function () { s.stop(); });
55-
s.scheduleAbsolute(time(5), function () { s.start(); });
56-
s.scheduleAbsolute(time(6), function () { list.push(new Timestamped(4, s.now())); });
53+
s.scheduleAbsolute(null, time(0), function () { list.push(new Timestamped(1, s.now())); });
54+
s.scheduleAbsolute(null, time(1), function () { list.push(new Timestamped(2, s.now())); });
55+
s.scheduleAbsolute(null, time(2), function () { s.stop(); });
56+
s.scheduleAbsolute(null, time(3), function () { list.push(new Timestamped(3, s.now())); });
57+
s.scheduleAbsolute(null, time(4), function () { s.stop(); });
58+
s.scheduleAbsolute(null, time(5), function () { s.start(); });
59+
s.scheduleAbsolute(null, time(6), function () { list.push(new Timestamped(4, s.now())); });
5760

5861
s.start();
5962

@@ -88,12 +91,12 @@
8891

8992
var list = [];
9093

91-
s.scheduleAbsolute(time(2), function () { list.push(new Timestamped(2, s.now())); });
94+
s.scheduleAbsolute(null, time(2), function () { list.push(new Timestamped(2, s.now())); });
9295

93-
s.scheduleAbsolute(time(3), function () { list.push(new Timestamped(3, s.now())); });
96+
s.scheduleAbsolute(null, time(3), function () { list.push(new Timestamped(3, s.now())); });
9497

95-
s.scheduleAbsolute(time(1), function () { list.push(new Timestamped(0, s.now())); });
96-
s.scheduleAbsolute(time(1), function () { list.push(new Timestamped(1, s.now())); });
98+
s.scheduleAbsolute(null, time(1), function () { list.push(new Timestamped(0, s.now())); });
99+
s.scheduleAbsolute(null, time(1), function () { list.push(new Timestamped(1, s.now())); });
97100

98101
s.start();
99102

@@ -110,9 +113,9 @@
110113

111114
var list = [];
112115

113-
var d = s.scheduleAbsolute(time(2), function () { list.push(new Timestamped(2, s.now())); });
116+
var d = s.scheduleAbsolute(null, time(2), function () { list.push(new Timestamped(2, s.now())); });
114117

115-
s.scheduleAbsolute(time(1), function () {
118+
s.scheduleAbsolute(null, time(1), function () {
116119
list.push(new Timestamped(0, s.now()));
117120
d.dispose();
118121
});
@@ -129,11 +132,11 @@
129132

130133
var list = [];
131134

132-
s.scheduleAbsolute(time(0), function () { list.push(new Timestamped(0, s.now())); });
133-
s.scheduleAbsolute(time(1), function () { list.push(new Timestamped(1, s.now())); });
134-
s.scheduleAbsolute(time(2), function () { list.push(new Timestamped(2, s.now())); });
135-
s.scheduleAbsolute(time(10), function () { list.push(new Timestamped(10, s.now())); });
136-
s.scheduleAbsolute(time(11), function () { list.push(new Timestamped(11, s.now())); });
135+
s.scheduleAbsolute(null, time(0), function () { list.push(new Timestamped(0, s.now())); });
136+
s.scheduleAbsolute(null, time(1), function () { list.push(new Timestamped(1, s.now())); });
137+
s.scheduleAbsolute(null, time(2), function () { list.push(new Timestamped(2, s.now())); });
138+
s.scheduleAbsolute(null, time(10), function () { list.push(new Timestamped(10, s.now())); });
139+
s.scheduleAbsolute(null, time(11), function () { list.push(new Timestamped(11, s.now())); });
137140

138141
s.advanceTo(time(8));
139142

@@ -157,8 +160,8 @@
157160
new Timestamped(2, time(2))
158161
]);
159162

160-
s.scheduleAbsolute(time(7), function () { list.push(new Timestamped(7, s.now())); });
161-
s.scheduleAbsolute(time(8), function () { list.push(new Timestamped(8, s.now())); });
163+
s.scheduleAbsolute(null, time(7), function () { list.push(new Timestamped(7, s.now())); });
164+
s.scheduleAbsolute(null, time(8), function () { list.push(new Timestamped(8, s.now())); });
162165

163166
equal(time(8), s.now());
164167
equal(time(8), s.clock);
@@ -204,11 +207,11 @@
204207

205208
var list = [];
206209

207-
s.scheduleAbsolute(time(0), function () { list.push(new Timestamped(0, s.now())); });
208-
s.scheduleAbsolute(time(1), function () { list.push(new Timestamped(1, s.now())); });
209-
s.scheduleAbsolute(time(2), function () { list.push(new Timestamped(2, s.now())); });
210-
s.scheduleAbsolute(time(10), function () { list.push(new Timestamped(10, s.now())); });
211-
s.scheduleAbsolute(time(11), function () { list.push(new Timestamped(11, s.now())); });
210+
s.scheduleAbsolute(null, time(0), function () { list.push(new Timestamped(0, s.now())); });
211+
s.scheduleAbsolute(null, time(1), function () { list.push(new Timestamped(1, s.now())); });
212+
s.scheduleAbsolute(null, time(2), function () { list.push(new Timestamped(2, s.now())); });
213+
s.scheduleAbsolute(null, time(10), function () { list.push(new Timestamped(10, s.now())); });
214+
s.scheduleAbsolute(null, time(11), function () { list.push(new Timestamped(11, s.now())); });
212215

213216
s.advanceBy(time(8) - s.now());
214217

@@ -221,8 +224,8 @@
221224
new Timestamped(2, time(2))
222225
]);
223226

224-
s.scheduleAbsolute(time(7), function () { list.push(new Timestamped(7, s.now())); });
225-
s.scheduleAbsolute(time(8), function () { list.push(new Timestamped(8, s.now())); });
227+
s.scheduleAbsolute(null, time(7), function () { list.push(new Timestamped(7, s.now())); });
228+
s.scheduleAbsolute(null, time(8), function () { list.push(new Timestamped(8, s.now())); });
226229

227230
equal(time(8), s.now());
228231
equal(time(8), s.clock);
@@ -330,8 +333,8 @@
330333

331334
var res = [];
332335

333-
s.scheduleAbsolute(now - 1000, function () { res.push(1); });
334-
s.scheduleAbsolute(now - 2000, function () { res.push(2); });
336+
s.scheduleAbsolute(null, now - 1000, function () { res.push(1); });
337+
s.scheduleAbsolute(null, now - 2000, function () { res.push(2); });
335338

336339
s.start();
337340

+53-54
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,73 @@
1-
QUnit.module('VirtualTimeScheduler');
1+
(function () {
22

3-
var VirtualTimeScheduler = Rx.VirtualTimeScheduler;
3+
/* jshint undef: true, unused: true */
4+
/* globals QUnit, test, Rx, equal, ok */
45

5-
var VirtualSchedulerTestScheduler = (function () {
6+
QUnit.module('VirtualTimeScheduler');
67

7-
function comparer(a, b) {
8-
if (a > b) {
9-
return 1;
10-
}
11-
if (a < b) {
12-
return -1;
13-
}
14-
return 0;
15-
}
8+
var VirtualTimeScheduler = Rx.VirtualTimeScheduler;
9+
10+
var VirtualSchedulerTestScheduler = (function () {
11+
12+
function comparer(a, b) {
13+
return a > b ? 1 : a < b ? -1 : 0;
14+
}
1615

17-
function add(absolute, relative) {
18-
if (absolute === null) {
19-
absolute = '';
20-
}
16+
function add(absolute, relative) {
17+
absolute == null && (absolute = '');
2118
return absolute + relative;
22-
}
19+
}
2320

24-
function toDateTimeOffset(absolute) {
25-
if (absolute === null) {
26-
absolute = '';
27-
}
21+
function toAbsoluteTime(absolute) {
22+
absolute == null && (absolute = '');
2823
return new Date(absolute.length);
29-
}
24+
}
3025

31-
function toRelative(timespan) {
26+
function toRelative (timeSpan) {
3227
return String.fromCharCode(timeSpan % 65535);
33-
}
28+
}
3429

35-
return function () {
30+
return function () {
3631
var scheduler = new VirtualTimeScheduler(null, comparer);
37-
scheduler.add = add.bind(scheduler);
38-
scheduler.toDateTimeOffset = toDateTimeOffset.bind(scheduler);
39-
scheduler.toRelative = toRelative.bind(scheduler);
32+
scheduler.add = add;
33+
scheduler.toAbsoluteTime = toAbsoluteTime;
34+
scheduler.toRelative = toRelative;
4035
return scheduler;
41-
};
42-
}());
36+
};
37+
}());
4338

44-
test('Virtual_Now', function () {
45-
var res;
46-
res = new VirtualSchedulerTestScheduler().now() - new Date().getTime();
39+
test('Virtual Now', function () {
40+
var res = new VirtualSchedulerTestScheduler().now() - new Date().getTime();
4741
ok(res < 1000);
48-
});
49-
50-
test('Virtual_ScheduleAction', function () {
51-
var ran, scheduler;
52-
ran = false;
53-
scheduler = new VirtualSchedulerTestScheduler();
54-
scheduler.schedule(function () {
55-
ran = true;
56-
});
42+
});
43+
44+
test('Virtual Schedule Action', function () {
45+
var ran = false;
46+
47+
var scheduler = new VirtualSchedulerTestScheduler();
48+
49+
scheduler.schedule(function () { ran = true; });
50+
5751
scheduler.start();
52+
5853
ok(ran);
59-
});
54+
});
55+
56+
test('Virtual Schedule Action Error', function () {
57+
var error = new Error();
6058

61-
test('Virtual_ScheduleActionError', function () {
62-
var ex, scheduler;
63-
ex = 'ex';
6459
try {
65-
scheduler = new VirtualSchedulerTestScheduler();
66-
scheduler.schedule(function () {
67-
throw ex;
68-
});
69-
scheduler.start();
70-
ok(false);
60+
var scheduler = new VirtualSchedulerTestScheduler();
61+
62+
scheduler.schedule(function () {
63+
throw error;
64+
});
65+
66+
scheduler.start();
67+
ok(false);
7168
} catch (e) {
72-
equal(e, ex);
69+
equal(e, error);
7370
}
74-
});
71+
});
72+
73+
}());

tests/core/notification.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
(function () {
2-
QUnit.module('NotificationTest');
2+
/* jshint undef: true, unused: true */
3+
/* globals QUnit, test, Rx, equal, ok */
4+
5+
QUnit.module('Notification');
36

47
var createOnNext = Rx.Notification.createOnNext,
58
createOnError = Rx.Notification.createOnError,
@@ -79,7 +82,7 @@
7982
var n1 = createOnNext(42);
8083

8184
var results = n1.accept(new AcceptObserver(
82-
function (x) {
85+
function () {
8386
return 'OK';
8487
},
8588
function () {
@@ -118,7 +121,7 @@
118121
var n1 = createOnNext(42);
119122

120123
var results = n1.accept(
121-
function (x) {
124+
function () {
122125
return 'OK';
123126
},
124127
function () {
@@ -339,7 +342,7 @@
339342
test('toObservable empty', function () {
340343
var scheduler = new Rx.TestScheduler();
341344

342-
var results = scheduler.startWithCreate(function () {
345+
var results = scheduler.startScheduler(function () {
343346
return createOnCompleted().toObservable(scheduler);
344347
});
345348

@@ -351,8 +354,8 @@
351354
test('toObservable just', function () {
352355
var scheduler = new Rx.TestScheduler();
353356

354-
var results = scheduler.startWithCreate(function () {
355-
return createOnNext(42).toObservable(scheduler);
357+
var results = scheduler.startScheduler(function () {
358+
return createOnNext(42).toObservable(scheduler);
356359
});
357360

358361
results.messages.assertEqual(
@@ -366,7 +369,7 @@
366369

367370
var scheduler = new Rx.TestScheduler();
368371

369-
var results = scheduler.startWithCreate(function () {
372+
var results = scheduler.startScheduler(function () {
370373
return createOnError(error).toObservable(scheduler);
371374
});
372375

0 commit comments

Comments
 (0)