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

55 lines
1.2 KiB
JavaScript
Raw Normal View History

process.mixin(require("common.js"));
2009-06-29 14:11:26 +02:00
var got_error = false;
var success_count = 0;
2009-06-29 14:11:26 +02:00
var stats;
var promise = posix.stat(".");
2009-06-29 14:11:26 +02:00
promise.addCallback(function (_stats) {
stats = _stats;
p(stats);
success_count++;
2009-06-29 14:11:26 +02:00
});
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);
2009-06-29 14:11:26 +02:00
assertFalse(got_error);
assertTrue(stats.mtime instanceof Date);
});
2009-06-29 14:11:26 +02:00