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
Herbert Vojčík cf2b206a8e More changes to tests so they really work under context module loader.
Plus, getting rid of test/common.js defining things in global.
2010-08-17 08:41:05 -07:00

41 lines
828 B
JavaScript

common = require("../common");
assert = common.assert
var path = require('path');
var fs = require('fs');
var got_error = false,
readdirDir = path.join(common.fixturesDir, "readdir")
var files = ['are'
, 'dir'
, 'empty'
, 'files'
, 'for'
, 'just'
, 'testing.js'
, 'these'
];
console.log('readdirSync ' + readdirDir);
var f = fs.readdirSync(readdirDir);
common.p(f);
assert.deepEqual(files, f.sort());
console.log("readdir " + readdirDir);
fs.readdir(readdirDir, function (err, f) {
if (err) {
console.log("error");
got_error = true;
} else {
common.p(f);
assert.deepEqual(files, f.sort());
}
});
process.addListener("exit", function () {
assert.equal(false, got_error);
console.log("exit");
});