Skip to content

Commit 5f00ade

Browse files
committed
Revise test iotjs promise
2021-02-05T14:59:40.0078677Z ==3560== Command: /root/work_space/iotjs/build/x86_64-linux/debug/bin/iotjs /root/work_space/iotjs/test/run_pass/test_iotjs_promise.js 2021-02-05T14:59:40.0080006Z ==3560== 2021-02-05T14:59:40.0080983Z AssertionError: {"expected":"Resolved","operator":"=="}
1 parent 3eb1725 commit 5f00ade

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

test/run_pass/test_iotjs_promise.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,27 @@ p.then(function (msg) {
2525
fulfill_ret = msg;
2626
});
2727

28+
var timeoutTimer = setTimeout(function() {
29+
resetTimers()
30+
}, 10000)
31+
2832
// If Promise's fulfill worked well, assertion must be valid.
29-
setTimeout(function() { assert.equal(fulfill_ret, "Resolved"); }, 1000);
33+
var intervalTimer = setInterval(function() {
34+
if (fulfill_ret) {
35+
assert.equal(fulfill_ret, "Resolved");
36+
resetTimers();
37+
} else {
38+
assert.equal(fulfill_ret, undefined);
39+
}
40+
}, 100);
41+
42+
function resetTimers() {
43+
if (intervalTimer) {
44+
clearInterval(intervalTimer)
45+
intervalTimer = undefined
46+
}
47+
if (timeoutTimer) {
48+
clearTimeout(timeoutTimer)
49+
timeoutTimer = undefined
50+
}
51+
}

0 commit comments

Comments
 (0)