0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/simple/test-readdir.js

40 lines
747 B
JavaScript
Raw Normal View History

require("../common");
var path = require('path');
var fs = require('fs');
2009-09-03 21:29:20 +02:00
2010-02-26 01:32:30 +01:00
var got_error = false,
readdirDir = path.join(fixturesDir, "readdir")
2009-09-03 21:29:20 +02:00
2010-02-26 01:32:30 +01:00
var files = ['are'
, 'dir'
, 'empty'
, 'files'
, 'for'
, 'just'
, 'testing.js'
, 'these'
2010-02-22 08:02:36 +01:00
];
2010-02-26 01:32:30 +01:00
puts('readdirSync ' + readdirDir);
var f = fs.readdirSync(readdirDir);
2010-02-22 08:02:36 +01:00
p(f);
assert.deepEqual(files, f.sort());
2010-02-26 01:32:30 +01:00
puts("readdir " + readdirDir);
fs.readdir(readdirDir, function (err, f) {
2010-02-20 01:02:30 +01:00
if (err) {
puts("error");
got_error = true;
} else {
2010-02-22 08:02:36 +01:00
p(f);
assert.deepEqual(files, f.sort());
2010-02-20 01:02:30 +01:00
}
2009-09-03 21:29:20 +02:00
});
process.addListener("exit", function () {
assert.equal(false, got_error);
2009-09-03 21:29:20 +02:00
puts("exit");
});