node/test/mjsunit/test-fs-write.js

22 lines
510 B
JavaScript
Raw Normal View History

process.mixin(require("./common"));
2009-09-17 06:28:31 +00:00
var fn = path.join(fixturesDir, "write.txt");
2009-09-17 06:28:31 +00:00
var expected = "hello";
var found;
fs.open(fn, 'w', 0644).addCallback(function (file) {
2010-02-12 09:04:14 +00:00
fs.write(file, expected, 0, "utf8").addCallback(function() {
fs.close(file).addCallback(function() {
fs.readFile(fn, process.UTF8).addCallback(function(contents) {
2009-09-17 06:28:31 +00:00
found = contents;
2010-02-18 05:28:31 +00:00
fs.unlinkSync(fn);
2009-09-17 06:28:31 +00:00
});
});
});
});
process.addListener("exit", function () {
assert.equal(expected, found);
2009-09-17 06:28:31 +00:00
});