node/test/simple/test-readdir.js

41 lines
805 B
JavaScript
Raw Normal View History

2010-02-25 14:36:17 +08:00
process.mixin(require("../common"));
2009-09-04 03:29:20 +08:00
var got_error = false;
2010-02-22 15:02:36 +08:00
var files = ['a.js'
, 'b'
, 'cycles'
, 'echo.js'
, 'multipart.js'
, 'nested-index'
, 'print-chars.js'
, 'test_ca.pem'
, 'test_cert.pem'
, 'test_key.pem'
, 'throws_error.js'
, 'x.txt'
];
puts('readdirSync ' + fixturesDir);
var f = fs.readdirSync(fixturesDir);
p(f);
assert.deepEqual(files, f.sort());
puts("readdir " + fixturesDir);
fs.readdir(fixturesDir, function (err, f) {
2010-02-20 08:02:30 +08:00
if (err) {
puts("error");
got_error = true;
} else {
2010-02-22 15:02:36 +08:00
p(f);
assert.deepEqual(files, f.sort());
2010-02-20 08:02:30 +08:00
}
2009-09-04 03:29:20 +08:00
});
process.addListener("exit", function () {
assert.equal(false, got_error);
2009-09-04 03:29:20 +08:00
puts("exit");
});