summaryrefslogtreecommitdiff
path: root/test/simple
diff options
context:
space:
mode:
authorHerbert Vojčík <herby@mailbox.sk>2010-08-17 17:21:43 +0200
committerRyan Dahl <ry@tinyclouds.org>2010-08-17 08:41:05 -0700
commitcf2b206a8e410e677c890e941fa0bd1d7419b1a0 (patch)
tree57f20019b74a6e75f492cfe097124b5f5b467e31 /test/simple
parent1872719b8cad36dd8ea3add973ea58f638fc340c (diff)
downloadnode-new-cf2b206a8e410e677c890e941fa0bd1d7419b1a0.tar.gz
More changes to tests so they really work under context module loader.
Plus, getting rid of test/common.js defining things in global.
Diffstat (limited to 'test/simple')
-rw-r--r--test/simple/test-assert.js2
-rw-r--r--test/simple/test-buffer.js2
-rw-r--r--test/simple/test-c-ares.js6
-rw-r--r--test/simple/test-child-process-buffering.js2
-rw-r--r--test/simple/test-child-process-exec-env.js3
-rw-r--r--test/simple/test-exec.js4
-rw-r--r--test/simple/test-fs-realpath.js3
-rw-r--r--test/simple/test-fs-stat.js10
-rw-r--r--test/simple/test-http.js2
-rw-r--r--test/simple/test-module-loading.js18
-rw-r--r--test/simple/test-net-binary.js2
-rw-r--r--test/simple/test-readdir.js4
-rw-r--r--test/simple/test-stdout-to-file.js2
-rw-r--r--test/simple/test-string-decoder.js4
14 files changed, 33 insertions, 31 deletions
diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js
index 0985faafa8..ea270cbcea 100644
--- a/test/simple/test-assert.js
+++ b/test/simple/test-assert.js
@@ -10,7 +10,7 @@ function makeBlock (f) {
};
}
-assert.ok(a.AssertionError instanceof Error,
+assert.ok(common.indirectInstanceOf(a.AssertionError.prototype, Error),
"a.AssertionError instanceof Error");
assert.throws(makeBlock(a.ok, false),
diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js
index 2386d10fa4..c6e6cc5ec6 100644
--- a/test/simple/test-buffer.js
+++ b/test/simple/test-buffer.js
@@ -25,7 +25,7 @@ var copied = b.copy(c, 0, 0, 512);
console.log("copied " + copied + " bytes from b into c");
assert.strictEqual(512, copied);
for (var i = 0; i < c.length; i++) {
- print('.');
+ common.print('.');
assert.equal(i % 256, c[i]);
}
console.log("");
diff --git a/test/simple/test-c-ares.js b/test/simple/test-c-ares.js
index f46ef24c96..8f93e89b8e 100644
--- a/test/simple/test-c-ares.js
+++ b/test/simple/test-c-ares.js
@@ -7,12 +7,12 @@ var dns = require("dns");
// Try resolution without callback
dns.getHostByName('localhost', function (error, result) {
- p(result);
+ common.p(result);
assert.deepEqual(['127.0.0.1'], result);
});
dns.getHostByName('127.0.0.1', function (error, result) {
- p(result);
+ common.p(result);
assert.deepEqual(['127.0.0.1'], result);
});
@@ -33,7 +33,7 @@ dns.lookup('::1', function (error, result, addressType) {
dns.lookup('ipv6.google.com', function (error, result, addressType) {
if (error) throw error;
- p(arguments);
+ common.p(arguments);
//assert.equal('string', typeof result);
assert.equal(6, addressType);
});
diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js
index bff45dc7b7..c34e434dcf 100644
--- a/test/simple/test-child-process-buffering.js
+++ b/test/simple/test-child-process-buffering.js
@@ -25,7 +25,7 @@ function pwd (callback) {
pwd(function (result) {
- p(result);
+ common.p(result);
assert.equal(true, result.length > 1);
assert.equal("\n", result[result.length-1]);
});
diff --git a/test/simple/test-child-process-exec-env.js b/test/simple/test-child-process-exec-env.js
index d4cd989a31..cc8d2f9873 100644
--- a/test/simple/test-child-process-exec-env.js
+++ b/test/simple/test-child-process-exec-env.js
@@ -1,4 +1,5 @@
-require('../common');
+common = require('../common');
+assert = common.assert;
var exec = require('child_process').exec,
sys = require('sys');
success_count = 0;
diff --git a/test/simple/test-exec.js b/test/simple/test-exec.js
index 727fd1fae6..c37d0ddcd9 100644
--- a/test/simple/test-exec.js
+++ b/test/simple/test-exec.js
@@ -13,7 +13,7 @@ exec("ls /", function (err, stdout, stderr) {
assert.equal(false, err.killed);
} else {
success_count++;
- p(stdout);
+ common.p(stdout);
}
});
@@ -30,7 +30,7 @@ exec("ls /DOES_NOT_EXIST", function (err, stdout, stderr) {
console.log("stderr: " + JSON.stringify(stderr));
} else {
success_count++;
- p(stdout);
+ common.p(stdout);
assert.equal(true, stdout != "");
}
});
diff --git a/test/simple/test-fs-realpath.js b/test/simple/test-fs-realpath.js
index e97e553f8a..7ff4ea5300 100644
--- a/test/simple/test-fs-realpath.js
+++ b/test/simple/test-fs-realpath.js
@@ -23,7 +23,8 @@ function asynctest(testBlock, args, callback, assertBlock) {
}
function bashRealpath(path, callback) {
- exec("cd '"+path.replace("'","\\'")+"' && pwd -P",function (err, o) {
+ common.exec("cd '"+path.replace("'","\\'")+"' && pwd -P",function
+ (err, o) {
callback(err, o.trim());
});
}
diff --git a/test/simple/test-fs-stat.js b/test/simple/test-fs-stat.js
index e626a973ec..7623a95f46 100644
--- a/test/simple/test-fs-stat.js
+++ b/test/simple/test-fs-stat.js
@@ -8,7 +8,7 @@ fs.stat(".", function (err, stats) {
if (err) {
got_error = true;
} else {
- p(stats);
+ common.p(stats);
assert.ok(stats.mtime instanceof Date);
success_count++;
}
@@ -18,7 +18,7 @@ fs.lstat(".", function (err, stats) {
if (err) {
got_error = true;
} else {
- p(stats);
+ common.p(stats);
assert.ok(stats.mtime instanceof Date);
success_count++;
}
@@ -33,7 +33,7 @@ fs.open(".", "r", undefined, function(err, fd) {
if (err) {
got_error = true;
} else {
- p(stats);
+ common.p(stats);
assert.ok(stats.mtime instanceof Date);
success_count++;
fs.close(fd);
@@ -50,7 +50,7 @@ fs.open(".", "r", undefined, function(err, fd) {
got_error = true;
}
if (stats) {
- p(stats);
+ common.p(stats);
assert.ok(stats.mtime instanceof Date);
success_count++;
}
@@ -62,7 +62,7 @@ fs.stat(__filename, function (err, s) {
if (err) {
got_error = true;
} else {
- p(s);
+ common.p(s);
success_count++;
console.log("isDirectory: " + JSON.stringify( s.isDirectory() ) );
diff --git a/test/simple/test-http.js b/test/simple/test-http.js
index 96a452ef29..05e6c7e8d2 100644
--- a/test/simple/test-http.js
+++ b/test/simple/test-http.js
@@ -17,7 +17,7 @@ var server = http.createServer(function (req, res) {
assert.equal("GET", req.method);
assert.equal("/hello", url.parse(req.url).pathname);
- p(req.headers);
+ common.p(req.headers);
assert.equal(true, "accept" in req.headers);
assert.equal("*/*", req.headers["accept"]);
diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js
index 9a53a2d3d7..e66a0d8412 100644
--- a/test/simple/test-module-loading.js
+++ b/test/simple/test-module-loading.js
@@ -15,25 +15,25 @@ var d4 = require("../fixtures/b/d");
assert.equal(false, false, "testing the test program.");
-assert.equal(true, a.A instanceof Function);
+assert.equal(true, common.indirectInstanceOf(a.A, Function));
assert.equal("A", a.A());
-assert.equal(true, a.C instanceof Function);
+assert.equal(true, common.indirectInstanceOf(a.C, Function));
assert.equal("C", a.C());
-assert.equal(true, a.D instanceof Function);
+assert.equal(true, common.indirectInstanceOf(a.D, Function));
assert.equal("D", a.D());
-assert.equal(true, d.D instanceof Function);
+assert.equal(true, common.indirectInstanceOf(d.D, Function));
assert.equal("D", d.D());
-assert.equal(true, d2.D instanceof Function);
+assert.equal(true, common.indirectInstanceOf(d2.D, Function));
assert.equal("D", d2.D());
-assert.equal(true, d3.D instanceof Function);
+assert.equal(true, common.indirectInstanceOf(d3.D, Function));
assert.equal("D", d3.D());
-assert.equal(true, d4.D instanceof Function);
+assert.equal(true, common.indirectInstanceOf(d4.D, Function));
assert.equal("D", d4.D());
assert.ok((new a.SomeClass) instanceof c.SomeClass);
@@ -52,7 +52,7 @@ assert.equal(root.sayHello(), root.hello);
common.debug("test name clashes");
// this one exists and should import the local module
var my_path = require("./path");
-assert.equal(true, my_path.path_func instanceof Function);
+assert.ok(common.indirectInstanceOf(my_path.path_func, Function));
// this one does not exist and should throw
assert.throws(function() { require("./utils")});
@@ -98,7 +98,7 @@ require.registerExtension('.test', function(content) {
});
assert.equal(require('../fixtures/registerExt2').custom, 'passed');
-debug("load modules by absolute id, then change require.paths, and load another module with the same absolute id.");
+common.debug("load modules by absolute id, then change require.paths, and load another module with the same absolute id.");
// this will throw if it fails.
var foo = require("../fixtures/require-path/p1/foo");
process.assert(foo.bar.expect === foo.bar.actual);
diff --git a/test/simple/test-net-binary.js b/test/simple/test-net-binary.js
index 572e6f77e7..233118c5c3 100644
--- a/test/simple/test-net-binary.js
+++ b/test/simple/test-net-binary.js
@@ -54,7 +54,7 @@ echoServer.addListener("listening", function() {
});
c.addListener("close", function () {
- p(recv);
+ common.p(recv);
echoServer.close();
});
});
diff --git a/test/simple/test-readdir.js b/test/simple/test-readdir.js
index 8d3f6fd508..e89f42a55b 100644
--- a/test/simple/test-readdir.js
+++ b/test/simple/test-readdir.js
@@ -19,7 +19,7 @@ var files = ['are'
console.log('readdirSync ' + readdirDir);
var f = fs.readdirSync(readdirDir);
-p(f);
+common.p(f);
assert.deepEqual(files, f.sort());
@@ -29,7 +29,7 @@ fs.readdir(readdirDir, function (err, f) {
console.log("error");
got_error = true;
} else {
- p(f);
+ common.p(f);
assert.deepEqual(files, f.sort());
}
});
diff --git a/test/simple/test-stdout-to-file.js b/test/simple/test-stdout-to-file.js
index 3db8183ecf..0cf7cb2650 100644
--- a/test/simple/test-stdout-to-file.js
+++ b/test/simple/test-stdout-to-file.js
@@ -21,7 +21,7 @@ function test (size, useBuffer, cb) {
fs.unlinkSync(tmpFile);
} catch (e) {}
- print(size + ' chars to ' + tmpFile + '...');
+ common.print(size + ' chars to ' + tmpFile + '...');
childProccess.exec(cmd, function(err) {
if (err) throw err;
diff --git a/test/simple/test-string-decoder.js b/test/simple/test-string-decoder.js
index d9b689cd85..cc59b070c3 100644
--- a/test/simple/test-string-decoder.js
+++ b/test/simple/test-string-decoder.js
@@ -43,7 +43,7 @@ charLengths = [0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5];
// 0 i j buffer.length
// Scan through every possible 3 segment combination
// and make sure that the string is always parsed.
-print('scanning ');
+common.print('scanning ');
for (var j = 2; j < buffer.length; j++) {
for (var i = 1; i < j; i++) {
var decoder = new StringDecoder('utf8');
@@ -57,7 +57,7 @@ for (var j = 2; j < buffer.length; j++) {
sum += decoder.write(buffer.slice(i, j));
sum += decoder.write(buffer.slice(j, buffer.length));
assert.equal(expected, sum);
- print(".");
+ common.print(".");
}
}
console.log(" crayon!");