forked from jxcore/jxcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ktrzeciaknubisa
committed
Apr 1, 2015
1 parent
eb50db4
commit 4883b1b
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright & License details are available under JXCORE_LICENSE file | ||
|
||
var fs = require('fs'); | ||
var assert = require('assert'); | ||
|
||
var str_typeof = "typeof stat is not 'object'"; | ||
var str_instanceof = "stat is not instance of fs.Stats"; | ||
var engine = process.versions.v8 ? "V8" : "SM"; | ||
var errors = []; | ||
|
||
var strictEqual = function (actual, expected, func_name, err) { | ||
if (actual !== expected) | ||
errors.push(engine + " - failed for fs." + func_name + "(): " + err); | ||
}; | ||
|
||
var checkToString = function (stat, func_name) { | ||
try { | ||
var x = stat.toString(); | ||
} catch (ex) { | ||
errors.push(engine + " - failed for fs." + func_name + "(): " + ": " + ex); | ||
} | ||
}; | ||
|
||
process.on('exit', function () { | ||
if (errors.length) { | ||
console.error(errors.join("\n")); | ||
throw new Error("There are errors."); | ||
} | ||
}); | ||
|
||
|
||
// stat | ||
fs.stat(__filename, function (err, stat) { | ||
strictEqual(typeof stat, "object", "stat", str_typeof); | ||
strictEqual(stat instanceof fs.Stats, true, "stat", str_instanceof); | ||
checkToString(stat, "stat"); | ||
}); | ||
|
||
// statSync | ||
var stat = fs.statSync(__filename); | ||
strictEqual(typeof stat, "object", "statSync", str_typeof); | ||
strictEqual(stat instanceof fs.Stats, true, "statSync", str_instanceof); | ||
checkToString(stat, "statSync"); | ||
|
||
|
||
// lstat | ||
fs.lstat(__filename, function (err, stat) { | ||
strictEqual(typeof stat, "object", "lstat", str_typeof); | ||
strictEqual(stat instanceof fs.Stats, true, "lstat", str_instanceof); | ||
checkToString(stat, "lstat"); | ||
}); | ||
|
||
// lstatSync | ||
var stat = fs.lstatSync(__filename); | ||
strictEqual(typeof stat, "object", "lstatSync", str_typeof); | ||
strictEqual(stat instanceof fs.Stats, true, "lstatSync", str_instanceof); | ||
checkToString(stat, "lstatSync"); | ||
|
||
|
||
var fd = fs.openSync(__filename, "r"); | ||
|
||
// fstat | ||
fs.fstat(fd, function (err, stat) { | ||
strictEqual(typeof stat, "object", "fstat", str_typeof); | ||
strictEqual(stat instanceof fs.Stats, true, "fstat", str_instanceof); | ||
checkToString(stat, "fstat"); | ||
}); | ||
|
||
// fstatSync | ||
var stat = fs.fstatSync(fd); | ||
strictEqual(typeof stat, "object", "fstatSync", str_typeof); | ||
strictEqual(stat instanceof fs.Stats, true, "fstatSync", str_instanceof); | ||
checkToString(stat, "fstatSync"); |