node/test/mjsunit/test-file-open.js

30 lines
604 B
JavaScript
Raw Normal View History

include("mjsunit.js");
var got_error = false;
var opened = false;
var closed = false;
2009-04-21 22:30:47 +08:00
function onLoad () {
var dirname = node.path.dirname(__filename);
var fixtures = node.path.join(dirname, "fixtures");
var x = node.path.join(fixtures, "x.txt");
2009-05-21 18:49:41 +08:00
file = new node.fs.File;
2009-07-01 06:49:56 +08:00
file.addListener("error", function () { got_error = true; });
2009-06-29 01:05:58 +08:00
file.open(x, "r").addCallback(function () {
2009-07-01 06:49:56 +08:00
opened = true;
2009-06-29 01:05:58 +08:00
file.close().addCallback(function () {
closed = true;
});
});
2009-06-29 01:05:58 +08:00
puts("hey!");
}
function onExit () {
assertFalse(got_error);
assertTrue(opened);
assertTrue(closed);
}