Browse Source

Tests: fix jslint issues

v0.7.4-release
Andreas Madsen 13 years ago
committed by Bert Belder
parent
commit
4865063924
  1. 4
      test/internet/test-dns.js
  2. 2
      test/message/throw_custom_error.js
  3. 2
      test/message/throw_non_error.js
  4. 2
      test/simple/test-assert.js
  5. 6
      test/simple/test-child-process-fork2.js
  6. 14
      test/simple/test-cluster-kill-workers.js
  7. 9
      test/simple/test-crypto-ecb.js
  8. 4
      test/simple/test-eval.js
  9. 6
      test/simple/test-fs-long-path.js
  10. 10
      test/simple/test-fs-symlink.js
  11. 10
      test/simple/test-fs-utimes.js
  12. 9
      test/simple/test-http-response-no-headers.js
  13. 15
      test/simple/test-init.js
  14. 13
      test/simple/test-module-load-list.js
  15. 2
      test/simple/test-net-connect-buffer.js
  16. 8
      test/simple/test-net-pipe-connect-errors.js
  17. 10
      test/simple/test-path.js
  18. 3
      test/simple/test-punycode.js
  19. 2
      test/simple/test-readdir.js
  20. 6
      test/simple/test-regress-GH-1899.js
  21. 15
      test/simple/test-regress-GH-877.js
  22. 7
      test/simple/test-repl-.save.load.js
  23. 4
      test/simple/test-setproctitle.js
  24. 12
      test/simple/test-stdin-pause-resume.js
  25. 4
      test/simple/test-tls-session-cache.js
  26. 3
      test/simple/test-tls-set-ciphers.js
  27. 2
      test/simple/test-util-inspect.js
  28. 74
      test/simple/test-util.js
  29. 33
      test/simple/test-zlib-from-string.js
  30. 6
      test/simple/test-zlib-random-byte-pipes.js

4
test/internet/test-dns.js

@ -383,11 +383,11 @@ TEST(function test_lookup_localhost_ipv4(done) {
var getaddrinfoCallbackCalled = false;
console.log("looking up nodejs.org...");
console.log('looking up nodejs.org...');
var req = process.binding('cares_wrap').getaddrinfo('nodejs.org');
req.oncomplete = function(domains) {
console.log("nodejs.org = ", domains);
console.log('nodejs.org = ', domains);
assert.ok(Array.isArray(domains));
assert.ok(domains.length >= 1);
assert.ok(typeof domains[0] == 'string');

2
test/message/throw_custom_error.js

@ -28,6 +28,6 @@ var assert = require('assert');
common.error('before');
// custom error throwing
throw { name: 'MyCustomError', message: 'This is a custom message' }
throw { name: 'MyCustomError', message: 'This is a custom message' };
common.error('after');

2
test/message/throw_non_error.js

@ -28,6 +28,6 @@ var assert = require('assert');
common.error('before');
// custom error throwing
throw { foo: 'bar' }
throw { foo: 'bar' };
common.error('after');

2
test/simple/test-assert.js

@ -197,7 +197,7 @@ threw = false;
try {
assert.throws(
function() {
throw {}
throw {};
},
Array
);

6
test/simple/test-child-process-fork2.js

@ -47,12 +47,12 @@ server.listen(common.PORT, function() {
function makeConnections() {
for (var i = 0; i < N; i++) {
var socket = net.connect(common.PORT, function() {
console.log("CLIENT connected");
console.log('CLIENT connected');
});
socket.on("close", function() {
socket.on('close', function() {
socketCloses++;
console.log("CLIENT closed " + socketCloses);
console.log('CLIENT closed ' + socketCloses);
if (socketCloses == N) {
n.kill();
server.close();

14
test/simple/test-cluster-kill-workers.js

@ -32,17 +32,17 @@ var fork = require('child_process').fork;
var isTestRunner = process.argv[2] != 'child';
if (isTestRunner) {
console.log("starting master...");
console.log('starting master...');
var master = fork(__filename, ['child']);
console.log("master pid =", master.pid);
console.log('master pid =', master.pid);
var workerPID;
master.on("message", function(m) {
console.log("got message from master:", m);
master.on('message', function(m) {
console.log('got message from master:', m);
if (m.workerPID) {
console.log("worker pid =", m.workerPID);
console.log('worker pid =', m.workerPID);
workerPID = m.workerPID;
}
});
@ -58,11 +58,11 @@ if (isTestRunner) {
process.kill(workerPID, 0);
} catch (e) {
// workerPID is no longer running
console.log(e)
console.log(e);
assert(e.code == 'ESRCH');
gotKillException = true;
}
})
});
process.on('exit', function() {
assert(gotExit);

9
test/simple/test-crypto-ecb.js

@ -35,17 +35,16 @@ try {
// Testing whether EVP_CipherInit_ex is functioning correctly.
// Reference: bug#1997
(function()
{
(function() {
var encrypt = crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
var hex = encrypt.update('Hello World!', 'ascii', 'hex');
hex += encrypt.final('hex');
assert.equal(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71');
}());
(function()
{
var decrypt = crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
(function() {
var decrypt = crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR',
'');
var msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii');
msg += decrypt.final('ascii');
assert.equal(msg, 'Hello World!');

4
test/simple/test-eval.js

@ -30,8 +30,8 @@ var exec = require('child_process').exec;
var success_count = 0;
var error_count = 0;
var cmd = [process.execPath, '-e', '"console.error(process.argv)"', 'foo', 'bar']
.join(' ');
var cmd = [process.execPath, '-e', '"console.error(process.argv)"',
'foo', 'bar'].join(' ');
var expected = util.format([process.execPath, 'foo', 'bar']) + '\n';
var child = exec(cmd, function(err, stdout, stderr) {
if (err) {

6
test/simple/test-fs-long-path.js

@ -31,8 +31,10 @@ var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x'));
var fullPath = path.resolve(fileName);
console.log({ filenameLength: fileName.length,
fullPathLength: fullPath.length });
console.log({
filenameLength: fileName.length,
fullPathLength: fullPath.length
});
fs.writeFile(fullPath, 'ok', function(err) {
if (err) throw err;

10
test/simple/test-fs-symlink.js

@ -38,8 +38,7 @@ var runtest = function(skip_symlinks) {
// Delete previously created link
try {
fs.unlinkSync(linkPath);
} catch(e)
{}
} catch (e) {}
fs.symlink(linkData, linkPath, function(err) {
if (err) throw err;
@ -60,8 +59,7 @@ var runtest = function(skip_symlinks) {
// Delete previously created link
try {
fs.unlinkSync(dstPath);
} catch(e)
{}
} catch (e) {}
fs.link(srcPath, dstPath, function(err) {
if (err) throw err;
@ -71,12 +69,12 @@ var runtest = function(skip_symlinks) {
assert.equal(srcContent, dstContent);
completed++;
});
}
};
if (is_windows) {
// On Windows, creating symlinks requires admin privileges.
// We'll only try to run symlink test if we have enough privileges.
exec("whoami /priv", function(err, o) {
exec('whoami /priv', function(err, o) {
if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) {
expected_tests = 1;
runtest(true);

10
test/simple/test-fs-utimes.js

@ -68,7 +68,7 @@ function expect_ok(syscall, resource, err, atime, mtime) {
// the tests assume that __filename belongs to the user running the tests
// this should be a fairly safe assumption; testing against a temp file
// would be even better though (node doesn't have such functionality yet)
function runTests(atime, mtime, callback) {
function runTest(atime, mtime, callback) {
var fd, err;
//
@ -144,10 +144,10 @@ function runTests(atime, mtime, callback) {
var stats = fs.statSync(__filename);
runTests(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() {
runTests(new Date(), new Date(), function() {
runTests(123456.789, 123456.789, function() {
runTests(stats.mtime, stats.mtime, function() {
runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() {
runTest(new Date(), new Date(), function() {
runTest(123456.789, 123456.789, function() {
runTest(stats.mtime, stats.mtime, function() {
// done
});
});

9
test/simple/test-http-response-no-headers.js

@ -27,8 +27,8 @@ var net = require('net');
var expected = {
'0.9': 'I AM THE WALRUS',
'1.0': 'I AM THE WALRUS',
'1.1': '',
}
'1.1': ''
};
var gotExpected = false;
@ -38,11 +38,12 @@ function test(httpVersion, callback) {
});
var server = net.createServer(function(conn) {
var reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' + expected[httpVersion];
var reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' +
expected[httpVersion];
conn.write(reply, function() {
conn.destroy();
})
});
});
server.listen(common.PORT, '127.0.0.1', function() {

15
test/simple/test-init.js

@ -36,11 +36,13 @@
child.exec(process.execPath + ' test-init', {env: {'TEST_INIT': 1}},
function(err, stdout, stderr) {
assert.equal(stdout, 'Loaded successfully!', '`node test-init` failed!');
assert.equal(stdout, 'Loaded successfully!',
'`node test-init` failed!');
});
child.exec(process.execPath + ' test-init.js', {env: {'TEST_INIT': 1}},
function(err, stdout, stderr) {
assert.equal(stdout, 'Loaded successfully!', '`node test-init.js` failed!');
assert.equal(stdout, 'Loaded successfully!',
'`node test-init.js` failed!');
});
// test-init-index is in fixtures dir as requested by ry, so go there
@ -48,16 +50,19 @@
child.exec(process.execPath + ' test-init-index', {env: {'TEST_INIT': 1}},
function(err, stdout, stderr) {
assert.equal(stdout, 'Loaded successfully!', '`node test-init-index failed!');
assert.equal(stdout, 'Loaded successfully!',
'`node test-init-index failed!');
});
// ensures that `node fs` does not mistakenly load the native 'fs' module
// instead of the desired file and that the fs module loads as expected in node
// instead of the desired file and that the fs module loads as
// expected in node
process.chdir(common.fixturesDir + '/test-init-native/');
child.exec(process.execPath + ' fs', {env: {'TEST_INIT': 1}},
function(err, stdout, stderr) {
assert.equal(stdout, 'fs loaded successfully', '`node fs` failed!');
assert.equal(stdout, 'fs loaded successfully',
'`node fs` failed!');
});
}
})();

13
test/simple/test-module-load-list.js

@ -24,19 +24,20 @@
// beginning of this file.
function assertEqual(x, y) {
if (x !== y) throw new Error("Expected '" + x + "' got '" + y + "'");
if (x !== y) throw new Error('Expected \'' + x + '\' got \'' + y + '\'');
}
function checkExpected() {
var toCompare = Math.max(expected.length, process.moduleLoadList.length);
for (var i = 0; i < toCompare; i++) {
if (expected[i] !== process.moduleLoadList[i]) {
console.error("process.moduleLoadList[" + i + "] = " + process.moduleLoadList[i]);
console.error("expected[" + i + "] = " + expected[i]);
console.error('process.moduleLoadList[' + i + '] = ' +
process.moduleLoadList[i]);
console.error('expected[' + i + '] = ' + expected[i]);
console.error("process.moduleLoadList", process.moduleLoadList);
console.error("expected = ", expected);
throw new Error("mismatch");
console.error('process.moduleLoadList', process.moduleLoadList);
console.error('expected = ', expected);
throw new Error('mismatch');
}
}
}

2
test/simple/test-net-connect-buffer.js

@ -85,7 +85,7 @@ tcp.listen(common.PORT, function() {
// Write a string that contains a multi-byte character sequence to test that
// `bytesWritten` is incremented with the # of bytes, not # of characters.
var a = "L'État, c'est ";
var b = "moi";
var b = 'moi';
// We're still connecting at this point so the datagram is first pushed onto
// the connect queue. Make sure that it's not added to `bytesWritten` again

8
test/simple/test-net-pipe-connect-errors.js

@ -31,12 +31,10 @@ var accessErrorFired = false;
// Test if ENOTSOCK is fired when trying to connect to a file which is not
// a socket.
var notSocketClient = net.createConnection(
path.join(common.fixturesDir, 'empty.txt'),
function () {
var emptyTxt = path.join(common.fixturesDir, 'empty.txt');
var notSocketClient = net.createConnection(emptyTxt, function() {
assert.ok(false);
}
);
});
notSocketClient.on('error', function(err) {
assert(err.code === 'ENOTSOCK' || err.code === 'ECONNREFUSED');

10
test/simple/test-path.js

@ -35,12 +35,14 @@ assert.equal(path.basename(f, '.js'), 'test-path');
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
if (!isWindows) {
var controlCharFilename = 'Icon' + String.fromCharCode(13);
assert.equal(path.basename('/a/b/' + controlCharFilename), controlCharFilename);
assert.equal(path.basename('/a/b/' + controlCharFilename),
controlCharFilename);
}
assert.equal(path.extname(f), '.js');
assert.equal(path.dirname(f).substr(-11), isWindows ? 'test\\simple' : 'test/simple');
assert.equal(path.dirname(f).substr(-11),
isWindows ? 'test\\simple' : 'test/simple');
assert.equal(path.dirname('/a/b/'), '/a');
assert.equal(path.dirname('/a/b'), '/a');
assert.equal(path.dirname('/a'), '/');
@ -237,7 +239,9 @@ var failures = [];
relativeTests.forEach(function(test) {
var actual = path.relative(test[0], test[1]);
var expected = test[2];
var message = 'path.relative(' + test.slice(0, 2).map(JSON.stringify).join(',') + ')' +
var message = 'path.relative(' +
test.slice(0, 2).map(JSON.stringify).join(',') +
')' +
'\n expect=' + JSON.stringify(expected) +
'\n actual=' + JSON.stringify(actual);
if (actual !== expected) failures.push('\n' + message);

3
test/simple/test-punycode.js

@ -115,7 +115,8 @@ var tests = {
'\u006E\u0074\u0065\u0068\u0061\u0062\u006C\u0061\u0072\u0065\u006E' +
'\u0045\u0073\u0070\u0061\u00F1\u006F\u006C',
// (K) Vietnamese: T<adotbelow>isaoh<odotbelow>kh<ocirc>ngth<ecirchookabove>ch<ihookabove>n<oacute>iti<ecircacute>ngVi<ecircdotbelow>t
// (K) Vietnamese: T<adotbelow>isaoh<odotbelow>kh<ocirc>ngth
// <ecirchookabove>ch<ihookabove>n<oacute>iti<ecircacute>ngVi<ecircdotbelow>t
'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g':
'\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B\u0068\u00F4' +
'\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068\u1EC9\u006E\u00F3\u0069' +

2
test/simple/test-readdir.js

@ -66,7 +66,7 @@ process.on('exit', function() {
var has_caught = false;
try {
fs.readdirSync(__filename)
fs.readdirSync(__filename);
}
catch (e) {
has_caught = true;

6
test/simple/test-regress-GH-1899.js

@ -20,11 +20,13 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var path = require('path');
var assert = require('assert')
var assert = require('assert');
var spawn = require('child_process').spawn;
var common = require('../common');
var child = spawn(process.argv[0], [path.join(common.fixturesDir, 'GH-1899-output.js')]);
var child = spawn(process.argv[0], [
path.join(common.fixturesDir, 'GH-1899-output.js')
]);
var output = '';
child.stdout.on('data', function(data) {

15
test/simple/test-regress-GH-877.js

@ -35,6 +35,8 @@ var server = http.createServer(function(req, res) {
res.end('Hello World\n');
});
var addrString = '127.0.0.1:' + common.PORT;
server.listen(common.PORT, '127.0.0.1', function() {
for (var i = 0; i < N; i++) {
var options = {
@ -50,12 +52,15 @@ server.listen(common.PORT, '127.0.0.1', function() {
assert.equal(req.agent, agent);
console.log('Socket: ' + agent.sockets['127.0.0.1:' + common.PORT].length +
'/' + agent.maxSockets +
' queued: ' + (agent.requests['127.0.0.1:' + common.PORT] ? agent.requests['127.0.0.1:' + common.PORT].length : 0));
console.log('Socket: ' + agent.sockets[addrString].length + '/' +
agent.maxSockets + ' queued: ' + (agent.requests[addrString] ?
agent.requests['127.0.0.1:' + common.PORT].length : 0));
var agentRequests = agent.requests[addrString] ?
agent.requests[addrString].length : 0;
if (maxQueued < (agent.requests['127.0.0.1:' + common.PORT] ? agent.requests['127.0.0.1:' + common.PORT].length : 0)) {
maxQueued = (agent.requests['127.0.0.1:' + common.PORT] ? agent.requests['127.0.0.1:' + common.PORT].length : 0);
if (maxQueued < agentRequests) {
maxQueued = agentRequests;
}
}
});

7
test/simple/test-repl-.save.load.js

@ -61,9 +61,7 @@ putIn.run(testFile);
putIn.run(['.save ' + saveFileName]);
// the file should have what I wrote
assert.equal(
fs.readFileSync(saveFileName, 'utf8'),
testFile.join('\n') + '\n');
assert.equal(fs.readFileSync(saveFileName, 'utf8'), testFile.join('\n') + '\n');
// make sure that the REPL data is "correct"
// so when I load it back I know I'm good
@ -90,8 +88,7 @@ var loadFile = join(common.tmpDir, 'file.does.not.exist');
// shold not break
putIn.write = function(data) {
// make sure I get a failed to load message and not some crazy error
assert.equal(data,
'Failed to load:' + loadFile + '\n');
assert.equal(data, 'Failed to load:' + loadFile + '\n');
// eat me to avoid work
putIn.write = function() {};
};

4
test/simple/test-setproctitle.js

@ -23,14 +23,14 @@
// FIXME add sunos support
if ('linux freebsd'.indexOf(process.platform) === -1) {
console.error("Skipping test, platform not supported.");
console.error('Skipping test, platform not supported.');
process.exit();
}
var assert = require('assert');
var exec = require('child_process').exec;
var title = "testTestTESTtest123123123123123123HiHaiJo";
var title = 'testTestTESTtest123123123123123123HiHaiJo';
assert.notEqual(process.title, title);
process.title = title;

12
test/simple/test-stdin-pause-resume.js

@ -19,19 +19,19 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
console.error("before opening stdin");
console.error('before opening stdin');
process.stdin.resume();
console.error("stdin opened");
console.error('stdin opened');
setTimeout(function() {
console.error("pausing stdin");
console.error('pausing stdin');
process.stdin.pause();
setTimeout(function() {
console.error("opening again");
console.error('opening again');
process.stdin.resume();
setTimeout(function() {
console.error("pausing again");
console.error('pausing again');
process.stdin.pause();
console.error("should exit now");
console.error('should exit now');
}, 1);
}, 1);
}, 1);

4
test/simple/test-tls-session-cache.js

@ -20,12 +20,12 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
if (!process.versions.openssl) {
console.error("Skipping because node compiled without OpenSSL.");
console.error('Skipping because node compiled without OpenSSL.');
process.exit(0);
}
require('child_process').exec('openssl version', function(err) {
if (err !== null) {
console.error("Skipping because openssl command is not available.");
console.error('Skipping because openssl command is not available.');
process.exit(0);
}
doTest();

3
test/simple/test-tls-set-ciphers.js

@ -51,7 +51,8 @@ var server = tls.createServer(options, function(conn) {
});
server.listen(common.PORT, '127.0.0.1', function() {
var cmd = 'openssl s_client -cipher NULL-MD5 -connect 127.0.0.1:' + common.PORT;
var cmd = 'openssl s_client -cipher NULL-MD5 -connect 127.0.0.1:' +
common.PORT;
exec(cmd, function(err, stdout, stderr) {
if (err) throw err;

2
test/simple/test-util-inspect.js

@ -61,7 +61,7 @@ assert.ok(ex.indexOf('[type]') != -1);
// GH-1941
// should not throw:
assert.equal(util.inspect(Object.create(Date.prototype)), '{}')
assert.equal(util.inspect(Object.create(Date.prototype)), '{}');
// GH-1944
assert.doesNotThrow(function() {

74
test/simple/test-util.js

@ -26,46 +26,46 @@ var util = require('util');
var context = require('vm').runInNewContext;
// isArray
assert.equal(true, util.isArray([]))
assert.equal(true, util.isArray(Array()))
assert.equal(true, util.isArray(new Array()))
assert.equal(true, util.isArray(new Array(5)))
assert.equal(true, util.isArray(new Array('with', 'some', 'entries')))
assert.equal(true, util.isArray(context('Array')()))
assert.equal(false, util.isArray({}))
assert.equal(false, util.isArray({ push: function () {} }))
assert.equal(false, util.isArray(/regexp/))
assert.equal(false, util.isArray(new Error))
assert.equal(false, util.isArray(Object.create(Array.prototype)))
assert.equal(true, util.isArray([]));
assert.equal(true, util.isArray(Array()));
assert.equal(true, util.isArray(new Array()));
assert.equal(true, util.isArray(new Array(5)));
assert.equal(true, util.isArray(new Array('with', 'some', 'entries')));
assert.equal(true, util.isArray(context('Array')()));
assert.equal(false, util.isArray({}));
assert.equal(false, util.isArray({ push: function() {} }));
assert.equal(false, util.isArray(/regexp/));
assert.equal(false, util.isArray(new Error));
assert.equal(false, util.isArray(Object.create(Array.prototype)));
// isRegExp
assert.equal(true, util.isRegExp(/regexp/))
assert.equal(true, util.isRegExp(RegExp()))
assert.equal(true, util.isRegExp(new RegExp()))
assert.equal(true, util.isRegExp(context('RegExp')()))
assert.equal(false, util.isRegExp({}))
assert.equal(false, util.isRegExp([]))
assert.equal(false, util.isRegExp(new Date()))
assert.equal(false, util.isRegExp(Object.create(RegExp.prototype)))
assert.equal(true, util.isRegExp(/regexp/));
assert.equal(true, util.isRegExp(RegExp()));
assert.equal(true, util.isRegExp(new RegExp()));
assert.equal(true, util.isRegExp(context('RegExp')()));
assert.equal(false, util.isRegExp({}));
assert.equal(false, util.isRegExp([]));
assert.equal(false, util.isRegExp(new Date()));
assert.equal(false, util.isRegExp(Object.create(RegExp.prototype)));
// isDate
assert.equal(true, util.isDate(new Date()))
assert.equal(true, util.isDate(new Date(0)))
assert.equal(true, util.isDate(new (context('Date'))))
assert.equal(false, util.isDate(Date()))
assert.equal(false, util.isDate({}))
assert.equal(false, util.isDate([]))
assert.equal(false, util.isDate(new Error))
assert.equal(false, util.isDate(Object.create(Date.prototype)))
assert.equal(true, util.isDate(new Date()));
assert.equal(true, util.isDate(new Date(0)));
assert.equal(true, util.isDate(new (context('Date'))));
assert.equal(false, util.isDate(Date()));
assert.equal(false, util.isDate({}));
assert.equal(false, util.isDate([]));
assert.equal(false, util.isDate(new Error));
assert.equal(false, util.isDate(Object.create(Date.prototype)));
// isError
assert.equal(true, util.isError(new Error))
assert.equal(true, util.isError(new TypeError))
assert.equal(true, util.isError(new SyntaxError))
assert.equal(true, util.isError(new (context('Error'))))
assert.equal(true, util.isError(new (context('TypeError'))))
assert.equal(true, util.isError(new (context('SyntaxError'))))
assert.equal(false, util.isError({}))
assert.equal(false, util.isError({ name: 'Error', message: '' }))
assert.equal(false, util.isError([]))
assert.equal(false, util.isError(Object.create(Error.prototype)))
assert.equal(true, util.isError(new Error));
assert.equal(true, util.isError(new TypeError));
assert.equal(true, util.isError(new SyntaxError));
assert.equal(true, util.isError(new (context('Error'))));
assert.equal(true, util.isError(new (context('TypeError'))));
assert.equal(true, util.isError(new (context('SyntaxError'))));
assert.equal(false, util.isError({}));
assert.equal(false, util.isError({ name: 'Error', message: '' }));
assert.equal(false, util.isError([]));
assert.equal(false, util.isError(Object.create(Error.prototype)));

33
test/simple/test-zlib-from-string.js

@ -25,12 +25,31 @@ var common = require('../common.js');
var assert = require('assert');
var zlib = require('zlib');
var inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi faucibus, purus at gravida dictum, libero arcu convallis lacus, in commodo libero metus eu nisi. Nullam commodo, neque nec porta placerat, nisi est fermentum augue, vitae gravida tellus sapien sit amet tellus. Aenean non diam orci. Proin quis elit turpis. Suspendisse non diam ipsum. Suspendisse nec ullamcorper odio. Vestibulum arcu mi, sodales non suscipit id, ultrices ut massa. Sed ac sem sit amet arcu malesuada fermentum. Nunc sed. ';
var expectedBase64Deflate = 'eJxdUUtOQzEMvMoc4OndgT0gJCT2buJWlpI4jePeqZfpmXAKLRKbLOzx/HK73q6vOrhCunlF1qIDJhNUeW5I2ozT5OkDlKWLJWkncJG5403HQXAkT3Jw29B9uIEmToMukglZ0vS6ociBh4JG8sV4oVLEUCitK2kxq1WzPnChHDzsaGKy491LofoAbWh8do43oeuYhB5EPCjcLjzYJo48KrfQBvnJecNFJvHT1+RSQsGoC7dn2t/xjhduTA1NWyQIZR0pbHwMDatnD+crPqKSqGPHp1vnlsWM/07ubf7bheF7kqSj84Bm0R1fYTfaK8vqqqfKBtNMhe3OZh6N95CTvMX5HJJi4xOVzCgUOIMSLH7wmeOHaFE4RdpnGavKtrB5xzfO/Ll9';
var expectedBase64Gzip = 'H4sIAAAAAAAAA11RS05DMQy8yhzg6d2BPSAkJPZu4laWkjiN496pl+mZcAotEpss7PH8crverq86uEK6eUXWogMmE1R5bkjajNPk6QOUpYslaSdwkbnjTcdBcCRPcnDb0H24gSZOgy6SCVnS9LqhyIGHgkbyxXihUsRQKK0raTGrVbM+cKEcPOxoYrLj3Uuh+gBtaHx2jjeh65iEHkQ8KNwuPNgmjjwqt9AG+cl5w0Um8dPX5FJCwagLt2fa3/GOF25MDU1bJAhlHSlsfAwNq2cP5ys+opKoY8enW+eWxYz/Tu5t/tuF4XuSpKPzgGbRHV9hN9ory+qqp8oG00yF7c5mHo33kJO8xfkckmLjE5XMKBQ4gxIsfvCZ44doUThF2mcZq8q2sHnHNzRtagj5AQAA';
var inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing el' +
'it. Morbi faucibus, purus at gravida dictum, libero arcu convallis la' +
'cus, in commodo libero metus eu nisi. Nullam commodo, neque nec porta' +
' placerat, nisi est fermentum augue, vitae gravida tellus sapien sit ' +
'amet tellus. Aenean non diam orci. Proin quis elit turpis. Suspendiss' +
'e non diam ipsum. Suspendisse nec ullamcorper odio. Vestibulum arcu m' +
'i, sodales non suscipit id, ultrices ut massa. Sed ac sem sit amet ar' +
'cu malesuada fermentum. Nunc sed. ';
var expectedBase64Deflate = 'eJxdUUtOQzEMvMoc4OndgT0gJCT2buJWlpI4jePeqZfpm' +
'XAKLRKbLOzx/HK73q6vOrhCunlF1qIDJhNUeW5I2ozT5OkDlKWLJWkncJG5403HQXAkT3' +
'Jw29B9uIEmToMukglZ0vS6ociBh4JG8sV4oVLEUCitK2kxq1WzPnChHDzsaGKy491Lofo' +
'AbWh8do43oeuYhB5EPCjcLjzYJo48KrfQBvnJecNFJvHT1+RSQsGoC7dn2t/xjhduTA1N' +
'WyQIZR0pbHwMDatnD+crPqKSqGPHp1vnlsWM/07ubf7bheF7kqSj84Bm0R1fYTfaK8vqq' +
'qfKBtNMhe3OZh6N95CTvMX5HJJi4xOVzCgUOIMSLH7wmeOHaFE4RdpnGavKtrB5xzfO/Ll9';
var expectedBase64Gzip = 'H4sIAAAAAAAAA11RS05DMQy8yhzg6d2BPSAkJPZu4laWkjiN' +
'496pl+mZcAotEpss7PH8crverq86uEK6eUXWogMmE1R5bkjajNPk6QOUpYslaSdwkbnjT' +
'cdBcCRPcnDb0H24gSZOgy6SCVnS9LqhyIGHgkbyxXihUsRQKK0raTGrVbM+cKEcPOxoYr' +
'Lj3Uuh+gBtaHx2jjeh65iEHkQ8KNwuPNgmjjwqt9AG+cl5w0Um8dPX5FJCwagLt2fa3/G' +
'OF25MDU1bJAhlHSlsfAwNq2cP5ys+opKoY8enW+eWxYz/Tu5t/tuF4XuSpKPzgGbRHV9h' +
'N9ory+qqp8oG00yF7c5mHo33kJO8xfkckmLjE5XMKBQ4gxIsfvCZ44doUThF2mcZq8q2s' +
'HnHNzRtagj5AQAA';
zlib.deflate(inputString, function(err, buffer) {
assert.equal(buffer.toString('base64'), expectedBase64Deflate, 'deflate encoded string should match');
assert.equal(buffer.toString('base64'), expectedBase64Deflate,
'deflate encoded string should match');
});
zlib.gzip(inputString, function(err, buffer) {
@ -48,10 +67,12 @@ zlib.gzip(inputString, function(err, buffer) {
var buffer = new Buffer(expectedBase64Deflate, 'base64');
zlib.unzip(buffer, function(err, buffer) {
assert.equal(buffer.toString(), inputString, 'decoded inflated string should match');
assert.equal(buffer.toString(), inputString,
'decoded inflated string should match');
});
buffer = new Buffer(expectedBase64Gzip, 'base64');
zlib.unzip(buffer, function(err, buffer) {
assert.equal(buffer.toString(), inputString, 'decoded gunzipped string should match');
assert.equal(buffer.toString(), inputString,
'decoded gunzipped string should match');
});

6
test/simple/test-zlib-random-byte-pipes.js

@ -67,7 +67,7 @@ RandomReadStream.prototype.resume = function() {
// console.error("rrs resume");
this._paused = false;
this.emit('resume');
this._process()
this._process();
};
RandomReadStream.prototype._process = function() {
@ -91,7 +91,7 @@ RandomReadStream.prototype._process = function() {
if (jitter) {
block += Math.ceil(Math.random() * jitter - (jitter / 2));
}
block = Math.min(block, this._remaining)
block = Math.min(block, this._remaining);
var buf = new Buffer(block);
for (var i = 0; i < block; i++) {
buf[i] = Math.random() * 256;
@ -160,4 +160,4 @@ out.on('data', function (c) {
process.on('exit', function() {
assert(didSomething, 'should have done something');
})
});

Loading…
Cancel
Save