mirror of https://github.com/lukechilds/node.git
Browse Source
No need to rely on stdout output now. onExit callbacks should print stack trace from onExit failurev0.7.4-release
Ryan
16 years ago
12 changed files with 109 additions and 95 deletions
@ -1,11 +1,13 @@ |
|||
include("mjsunit.js"); |
|||
var status = null; |
|||
|
|||
function onLoad () { |
|||
var dirname = node.path.dirname(__filename); |
|||
var fixtures = node.path.join(dirname, "fixtures"); |
|||
var filename = node.path.join(fixtures, "does_not_exist.txt"); |
|||
node.fs.cat(filename, "raw", function (s) { status = s }); |
|||
} |
|||
|
|||
node.fs.cat(filename, "raw", function (status, data) { |
|||
assertTrue(status != 0); |
|||
}); |
|||
}; |
|||
function onExit () { |
|||
assertTrue(status != 0); |
|||
} |
@ -1,31 +0,0 @@ |
|||
include("mjsunit.js"); |
|||
|
|||
function onLoad () { |
|||
assertInstanceof(setTimeout, Function); |
|||
var starttime = new Date; |
|||
|
|||
setTimeout(function () { |
|||
var endtime = new Date; |
|||
var diff = endtime - starttime; |
|||
if (diff < 0) diff = -diff; |
|||
assertTrue(900 < diff || diff < 1100); |
|||
}, 1000); |
|||
|
|||
// this timer shouldn't execute
|
|||
var id = setTimeout(function () { assertTrue(false); }, 500); |
|||
clearTimeout(id); |
|||
|
|||
var count = 0; |
|||
setInterval(function () { |
|||
count += 1; |
|||
var endtime = new Date; |
|||
var diff = endtime - starttime; |
|||
if (diff < 0) diff = -diff; |
|||
puts(diff); |
|||
var t = count * 1000; |
|||
assertTrue(t - 100 < diff || diff < t + 100); |
|||
assertTrue(count <= 3); |
|||
if (count == 3) |
|||
clearInterval(this); |
|||
}, 1000); |
|||
} |
@ -0,0 +1,43 @@ |
|||
include("mjsunit.js"); |
|||
|
|||
var WINDOW = 800; // why is does this need to be so big?
|
|||
|
|||
var interval_count = 0; |
|||
var setTimeout_called = false; |
|||
|
|||
function onLoad () { |
|||
assertInstanceof(setTimeout, Function); |
|||
var starttime = new Date; |
|||
|
|||
setTimeout(function () { |
|||
var endtime = new Date; |
|||
var diff = endtime - starttime; |
|||
if (diff < 0) diff = -diff; |
|||
assertTrue(1000 - WINDOW < diff && diff < 1000 + WINDOW); |
|||
setTimeout_called = true; |
|||
}, 1000); |
|||
|
|||
// this timer shouldn't execute
|
|||
var id = setTimeout(function () { assertTrue(false); }, 500); |
|||
clearTimeout(id); |
|||
|
|||
setInterval(function () { |
|||
interval_count += 1; |
|||
var endtime = new Date; |
|||
var diff = endtime - starttime; |
|||
if (diff < 0) diff = -diff; |
|||
|
|||
var t = interval_count * 1000; |
|||
|
|||
assertTrue(t - WINDOW < diff && diff < t + WINDOW); |
|||
|
|||
assertTrue(interval_count <= 3); |
|||
if (interval_count == 3) |
|||
clearInterval(this); |
|||
}, 1000); |
|||
} |
|||
|
|||
function onExit () { |
|||
assertTrue(setTimeout_called); |
|||
assertEquals(3, interval_count); |
|||
} |
Loading…
Reference in new issue