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/pummel/test-net-timeout2.js
  5. 2
      test/simple/test-assert.js
  6. 6
      test/simple/test-child-process-fork2.js
  7. 18
      test/simple/test-cluster-kill-workers.js
  8. 9
      test/simple/test-crypto-ecb.js
  9. 4
      test/simple/test-eval.js
  10. 6
      test/simple/test-fs-long-path.js
  11. 2
      test/simple/test-fs-mkdir.js
  12. 10
      test/simple/test-fs-symlink.js
  13. 10
      test/simple/test-fs-utimes.js
  14. 2
      test/simple/test-http-abort-before-end.js
  15. 6
      test/simple/test-http-res-write-end-dont-take-array.js
  16. 9
      test/simple/test-http-response-no-headers.js
  17. 15
      test/simple/test-init.js
  18. 13
      test/simple/test-module-load-list.js
  19. 2
      test/simple/test-net-connect-buffer.js
  20. 24
      test/simple/test-net-pipe-connect-errors.js
  21. 10
      test/simple/test-path.js
  22. 3
      test/simple/test-punycode.js
  23. 2
      test/simple/test-readdir.js
  24. 10
      test/simple/test-regress-GH-1899.js
  25. 15
      test/simple/test-regress-GH-877.js
  26. 23
      test/simple/test-repl-.save.load.js
  27. 4
      test/simple/test-setproctitle.js
  28. 12
      test/simple/test-stdin-pause-resume.js
  29. 2
      test/simple/test-tls-passphrase.js
  30. 6
      test/simple/test-tls-session-cache.js
  31. 3
      test/simple/test-tls-set-ciphers.js
  32. 2
      test/simple/test-tty-stdout-end.js
  33. 6
      test/simple/test-util-inspect.js
  34. 74
      test/simple/test-util.js
  35. 2
      test/simple/test-zlib-from-gzip.js
  36. 35
      test/simple/test-zlib-from-string.js
  37. 14
      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/pummel/test-net-timeout2.js

@ -47,7 +47,7 @@ var server = net.createServer(function(socket) {
}
if (socket.writable) {
socket.write(Date.now()+'\n');
socket.write(Date.now() + '\n');
}
}, 1000);
});

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();

18
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...");
var master = fork(__filename, [ 'child' ]);
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;
}
});
@ -56,13 +56,13 @@ if (isTestRunner) {
assert(workerPID > 0);
try {
process.kill(workerPID, 0);
} catch(e) {
} 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;

2
test/simple/test-fs-mkdir.js

@ -81,4 +81,4 @@ function unlink(pathname) {
// Keep the event loop alive so the async mkdir() requests
// have a chance to run (since they don't ref the event loop).
process.nextTick(function(){});
process.nextTick(function() {});

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
});
});

2
test/simple/test-http-abort-before-end.js

@ -28,7 +28,7 @@ var server = http.createServer(function(req, res) {
});
server.listen(common.PORT, function() {
var req = http.request({method:'GET', host:'127.0.0.1', port:common.PORT});
var req = http.request({method: 'GET', host: '127.0.0.1', port: common.PORT});
req.on('error', function(ex) {
// https://github.com/joyent/node/issues/1399#issuecomment-2597359

6
test/simple/test-http-res-write-end-dont-take-array.js

@ -25,7 +25,7 @@ var http = require('http');
var test = 1;
var server = http.createServer(function (req, res) {
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
if (test === 1) {
// write should accept string
@ -53,11 +53,11 @@ var server = http.createServer(function (req, res) {
server.listen(common.PORT, function() {
// just make a request, other tests handle responses
http.get({port:common.PORT}, function() {
http.get({port: common.PORT}, function() {
// lazy serial test, becuase we can only call end once per request
test += 1;
// do it again to test .end(Buffer);
http.get({port:common.PORT}, function() {
http.get({port: common.PORT}, function() {
server.close();
});
});

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

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

@ -31,42 +31,40 @@ 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) {
notSocketClient.on('error', function(err) {
assert(err.code === 'ENOTSOCK' || err.code === 'ECONNREFUSED');
notSocketErrorFired = true;
});
// Trying to connect to not-existing socket should result in ENOENT error
var noEntSocketClient = net.createConnection('no-ent-file', function () {
var noEntSocketClient = net.createConnection('no-ent-file', function() {
assert.ok(false);
});
noEntSocketClient.on('error', function (err) {
noEntSocketClient.on('error', function(err) {
assert.equal(err.code, 'ENOENT');
noEntErrorFired = true;
});
// Trying to connect to a socket one has no access to should result in EACCES
var accessServer = net.createServer(function () {
var accessServer = net.createServer(function() {
assert.ok(false);
});
accessServer.listen(common.PIPE, function () {
accessServer.listen(common.PIPE, function() {
fs.chmodSync(common.PIPE, 0);
var accessClient = net.createConnection(common.PIPE, function () {
var accessClient = net.createConnection(common.PIPE, function() {
assert.ok(false);
});
accessClient.on('error', function (err) {
accessClient.on('error', function(err) {
assert.equal(err.code, 'EACCES');
accessErrorFired = true;
accessServer.close();
@ -75,7 +73,7 @@ accessServer.listen(common.PIPE, function () {
// Assert that all error events were fired
process.on('exit', function () {
process.on('exit', function() {
assert.ok(notSocketErrorFired);
assert.ok(noEntErrorFired);
assert.ok(accessErrorFired);

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;

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

@ -20,18 +20,20 @@
// 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) {
child.stdout.on('data', function(data) {
output += data;
});
child.on('exit', function (code, signal) {
child.on('exit', function(code, signal) {
assert.equal(code, 0);
assert.equal(output, 'hello, world!\n');
});

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;
}
}
});

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

@ -29,9 +29,9 @@ var repl = require('repl');
// A stream to push an array into a REPL
function ArrayStream() {
this.run = function (data) {
this.run = function(data) {
var self = this;
data.forEach(function (line) {
data.forEach(function(line) {
self.emit('data', line);
});
}
@ -39,10 +39,10 @@ function ArrayStream() {
util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true;
ArrayStream.prototype.writable = true;
ArrayStream.prototype.resume = function () {};
ArrayStream.prototype.write = function () {};
ArrayStream.prototype.resume = function() {};
ArrayStream.prototype.write = function() {};
var works = [ [ 'inner.one' ], 'inner.o' ];
var works = [['inner.one'], 'inner.o'];
var putIn = new ArrayStream();
var testMe = repl.start('', putIn);
@ -61,13 +61,11 @@ 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
testMe.complete('inner.o', function (error, data) {
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
@ -78,7 +76,7 @@ putIn.run(['.clear']);
putIn.run(['.load ' + saveFileName]);
// make sure that the REPL data is "correct"
testMe.complete('inner.o', function (error, data) {
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});
@ -90,12 +88,11 @@ 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() {};
};
putIn.run(['.load ' +loadFile]);
putIn.run(['.load ' + loadFile]);
//TODO how do I do a failed .save test?

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);

2
test/simple/test-tls-passphrase.js

@ -37,7 +37,7 @@ var server = tls.Server({
key: key,
passphrase: 'passphrase',
cert: cert,
ca: [ cert ],
ca: [cert],
requestCert: true,
rejectUnauthorized: true
}, function(s) {

6
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();
@ -46,7 +46,7 @@ function doTest() {
var options = {
key: key,
cert: cert,
ca: [ cert ],
ca: [cert],
requestCert: true
};
var requestCount = 0;

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-tty-stdout-end.js

@ -27,7 +27,7 @@ var exceptionCaught = false;
try {
process.stdout.end();
} catch(e) {
} catch (e) {
exceptionCaught = true;
assert.ok(common.isError(e));
assert.equal('process.stdout cannot be closed', e.message);

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

@ -61,16 +61,16 @@ 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 () {
assert.doesNotThrow(function() {
var d = new Date();
d.toUTCString = null;
util.inspect(d);
});
assert.doesNotThrow(function () {
assert.doesNotThrow(function() {
var r = /regexp/;
r.toString = null;
util.inspect(r);

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)));

2
test/simple/test-zlib-from-gzip.js

@ -43,6 +43,6 @@ out.on('close', function() {
var actual = fs.readFileSync(outputFile);
assert.equal(actual.length, expect.length, 'length should match');
for (var i = 0, l = actual.length; i < l; i++) {
assert.equal(actual[i], expect[i], 'byte['+i+']');
assert.equal(actual[i], expect[i], 'byte[' + i + ']');
}
});

35
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) {
@ -40,7 +59,7 @@ zlib.gzip(inputString, function(err, buffer) {
// However, decrypting it should definitely yield the same
// result that we're expecting, and this should match what we get
// from inflating the known valid deflate data.
zlib.gunzip(buffer, function (err, gunzipped) {
zlib.gunzip(buffer, function(err, gunzipped) {
assert.equal(gunzipped.toString(), inputString,
'Should get original string after gzip/gunzip');
});
@ -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');
});

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

@ -29,7 +29,7 @@ var zlib = require('zlib');
// emit random bytes, and keep a shasum
function RandomReadStream (opt) {
function RandomReadStream(opt) {
Stream.call(this);
this.readable = true;
@ -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,9 +91,9 @@ 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 ++) {
for (var i = 0; i < block; i++) {
buf[i] = Math.random() * 256;
}
@ -110,7 +110,7 @@ RandomReadStream.prototype._process = function() {
// a filter that just verifies a shasum
function HashStream () {
function HashStream() {
Stream.call(this);
this.readable = this.writable = true;
@ -152,7 +152,7 @@ var gunz = zlib.createGunzip();
inp.pipe(gzip).pipe(gunz).pipe(out);
var didSomething = false;
out.on('data', function (c) {
out.on('data', function(c) {
didSomething = true;
console.error('hash=%s', c);
assert.equal(c, inp._hash, 'hashes should match');
@ -160,4 +160,4 @@ out.on('data', function (c) {
process.on('exit', function() {
assert(didSomething, 'should have done something');
})
});

Loading…
Cancel
Save