Skip to content

Commit d07e5cf

Browse files
committed
More test.
1 parent 35fb3c7 commit d07e5cf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/unit/async.html

+23
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
var called2 = 0;
8686
var called3 = 0;
8787
var called4 = 0;
88+
var called5 = 0;
8889
var callback1 = function() {
8990
called1++;
9091
};
@@ -94,11 +95,15 @@
9495
};
9596
var callback3 = function() {
9697
called3++;
98+
Async.run(callback5);
9799
throw new Error('intentional error 2');
98100
};
99101
var callback4 = function() {
100102
called4++;
101103
};
104+
var callback5 = function() {
105+
called5++;
106+
};
102107
Async.run(callback1);
103108
Async.run(callback2);
104109
Async.run(callback3);
@@ -107,14 +112,32 @@
107112
assert.throws(function() {
108113
Async._atEndOfMicrotask();
109114
});
115+
// Have been called
110116
assert.equal(called1, 1);
111117
assert.equal(called2, 1);
118+
// Not yet called, due to exception
119+
assert.equal(called3, 0);
120+
assert.equal(called4, 0);
121+
assert.equal(called5, 0);
122+
// Force next synchronous microtask
112123
assert.throws(function() {
113124
Async._atEndOfMicrotask();
114125
});
126+
// Have been called
127+
assert.equal(called1, 1);
128+
assert.equal(called2, 1);
115129
assert.equal(called3, 1);
130+
// Not yet called, due to exception
131+
assert.equal(called4, 0);
132+
assert.equal(called5, 0);
133+
// Wait for actual microtask, and verify remaining queue was flushed
116134
setTimeout(function() {
135+
// Have been called
136+
assert.equal(called1, 1);
137+
assert.equal(called2, 1);
138+
assert.equal(called3, 1);
117139
assert.equal(called4, 1);
140+
assert.equal(called5, 1);
118141
done();
119142
});
120143
});

0 commit comments

Comments
 (0)