0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/mjsunit/test-fs-stat.js
Ryan Dahl 7a2e784ad7 Module refactor - almost CommonJS compatible now
API change summary:

  * require("/sys.js") becomes require("sys")

  * require("circle.js") becomes require("./circle")

  * process.path.join() becomes require("path").join()
2009-10-31 19:10:30 +01:00

55 lines
1.2 KiB
JavaScript

process.mixin(require("./common"));
var got_error = false;
var success_count = 0;
var stats;
var promise = posix.stat(".");
promise.addCallback(function (_stats) {
stats = _stats;
p(stats);
success_count++;
});
promise.addErrback(function () {
got_error = true;
});
puts("stating: " + __filename);
posix.stat(__filename).addCallback(function (s) {
p(s);
success_count++;
puts("isDirectory: " + JSON.stringify( s.isDirectory() ) );
assertFalse(s.isDirectory());
puts("isFile: " + JSON.stringify( s.isFile() ) );
assertTrue(s.isFile());
puts("isSocket: " + JSON.stringify( s.isSocket() ) );
assertFalse(s.isSocket());
puts("isBlockDevice: " + JSON.stringify( s.isBlockDevice() ) );
assertFalse(s.isBlockDevice());
puts("isCharacterDevice: " + JSON.stringify( s.isCharacterDevice() ) );
assertFalse(s.isCharacterDevice());
puts("isFIFO: " + JSON.stringify( s.isFIFO() ) );
assertFalse(s.isFIFO());
puts("isSymbolicLink: " + JSON.stringify( s.isSymbolicLink() ) );
assertFalse(s.isSymbolicLink());
}).addErrback(function () {
got_error = true;
});
process.addListener("exit", function () {
assertEquals(2, success_count);
assertFalse(got_error);
assertTrue(stats.mtime instanceof Date);
});