From 48650639248e73f78b2bd4ba2d3d1590749753ce Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Tue, 17 Jan 2012 19:43:34 +0100 Subject: [PATCH] Tests: fix jslint issues --- test/internet/test-dns.js | 4 +- test/message/throw_custom_error.js | 2 +- test/message/throw_non_error.js | 2 +- test/pummel/test-net-timeout2.js | 14 ++-- test/simple/test-assert.js | 2 +- test/simple/test-child-process-fork2.js | 6 +- test/simple/test-cluster-kill-workers.js | 18 ++--- test/simple/test-crypto-ecb.js | 9 +-- test/simple/test-dgram-send-error.js | 4 +- test/simple/test-eval.js | 4 +- test/simple/test-fs-long-path.js | 6 +- test/simple/test-fs-mkdir.js | 2 +- test/simple/test-fs-symlink.js | 10 +-- test/simple/test-fs-utimes.js | 10 +-- test/simple/test-http-abort-before-end.js | 2 +- ...test-http-res-write-end-dont-take-array.js | 6 +- test/simple/test-http-response-no-headers.js | 9 ++- test/simple/test-init.js | 15 ++-- test/simple/test-module-load-list.js | 13 +-- test/simple/test-net-connect-buffer.js | 2 +- test/simple/test-net-pipe-connect-errors.js | 26 +++--- test/simple/test-path.js | 10 ++- test/simple/test-punycode.js | 81 ++++++++++--------- test/simple/test-readdir.js | 2 +- test/simple/test-regress-GH-1899.js | 10 ++- test/simple/test-regress-GH-877.js | 15 ++-- test/simple/test-repl-.save.load.js | 23 +++--- test/simple/test-setproctitle.js | 4 +- test/simple/test-stdin-pause-resume.js | 12 +-- test/simple/test-tls-passphrase.js | 2 +- test/simple/test-tls-session-cache.js | 6 +- test/simple/test-tls-set-ciphers.js | 3 +- test/simple/test-tty-stdout-end.js | 2 +- test/simple/test-util-inspect.js | 6 +- test/simple/test-util.js | 74 ++++++++--------- test/simple/test-zlib-from-gzip.js | 2 +- test/simple/test-zlib-from-string.js | 35 ++++++-- test/simple/test-zlib-random-byte-pipes.js | 14 ++-- 38 files changed, 251 insertions(+), 216 deletions(-) diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index 095b47ad66..9da388cb54 100644 --- a/test/internet/test-dns.js +++ b/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'); diff --git a/test/message/throw_custom_error.js b/test/message/throw_custom_error.js index 5c994c009d..bef7f5dab0 100644 --- a/test/message/throw_custom_error.js +++ b/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'); diff --git a/test/message/throw_non_error.js b/test/message/throw_non_error.js index 702a40d9b6..afea96f49c 100644 --- a/test/message/throw_non_error.js +++ b/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'); diff --git a/test/pummel/test-net-timeout2.js b/test/pummel/test-net-timeout2.js index 2e2568b490..16f69cc022 100644 --- a/test/pummel/test-net-timeout2.js +++ b/test/pummel/test-net-timeout2.js @@ -32,12 +32,12 @@ var counter = 0; var server = net.createServer(function(socket) { socket.setTimeout((seconds / 2) * 1000, function() { gotTimeout = true; - console.log('timeout!!'); - socket.destroy(); + console.log('timeout!!'); + socket.destroy(); process.exit(1); - }); + }); - var interval = setInterval(function() { + var interval = setInterval(function() { counter++; if (counter == seconds) { @@ -46,9 +46,9 @@ var server = net.createServer(function(socket) { socket.destroy(); } - if (socket.writable) { - socket.write(Date.now()+'\n'); - } + if (socket.writable) { + socket.write(Date.now() + '\n'); + } }, 1000); }); diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js index 9a3b021f3c..df8d810204 100644 --- a/test/simple/test-assert.js +++ b/test/simple/test-assert.js @@ -197,7 +197,7 @@ threw = false; try { assert.throws( function() { - throw {} + throw {}; }, Array ); diff --git a/test/simple/test-child-process-fork2.js b/test/simple/test-child-process-fork2.js index 3116320830..6f292fa199 100644 --- a/test/simple/test-child-process-fork2.js +++ b/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(); diff --git a/test/simple/test-cluster-kill-workers.js b/test/simple/test-cluster-kill-workers.js index c9f2bf260b..39846fab03 100644 --- a/test/simple/test-cluster-kill-workers.js +++ b/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); diff --git a/test/simple/test-crypto-ecb.js b/test/simple/test-crypto-ecb.js index 23a5e682f1..1ffaa4f24b 100644 --- a/test/simple/test-crypto-ecb.js +++ b/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!'); diff --git a/test/simple/test-dgram-send-error.js b/test/simple/test-dgram-send-error.js index 803a371fcc..346f36dbe2 100644 --- a/test/simple/test-dgram-send-error.js +++ b/test/simple/test-dgram-send-error.js @@ -73,9 +73,9 @@ function doSend() { } process.on('exit', function() { - console.log(packetsSent + ' UDP packets sent, ' + + console.log(packetsSent + ' UDP packets sent, ' + packetsReceived + ' received'); - + assert.strictEqual(packetsSent, ITERATIONS * 2); assert.strictEqual(packetsReceived, ITERATIONS); }); diff --git a/test/simple/test-eval.js b/test/simple/test-eval.js index a2e56e02c9..9c656a8770 100644 --- a/test/simple/test-eval.js +++ b/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) { diff --git a/test/simple/test-fs-long-path.js b/test/simple/test-fs-long-path.js index 2ae80d0edb..eac58f68e5 100644 --- a/test/simple/test-fs-long-path.js +++ b/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; diff --git a/test/simple/test-fs-mkdir.js b/test/simple/test-fs-mkdir.js index 324c08a5f9..176cc4cf8d 100644 --- a/test/simple/test-fs-mkdir.js +++ b/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() {}); diff --git a/test/simple/test-fs-symlink.js b/test/simple/test-fs-symlink.js index 83bf13e494..6b23b1e1c1 100644 --- a/test/simple/test-fs-symlink.js +++ b/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); diff --git a/test/simple/test-fs-utimes.js b/test/simple/test-fs-utimes.js index df75fcb641..eae80238bc 100644 --- a/test/simple/test-fs-utimes.js +++ b/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 }); }); diff --git a/test/simple/test-http-abort-before-end.js b/test/simple/test-http-abort-before-end.js index e701ed9050..11e424fbe1 100644 --- a/test/simple/test-http-abort-before-end.js +++ b/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 diff --git a/test/simple/test-http-res-write-end-dont-take-array.js b/test/simple/test-http-res-write-end-dont-take-array.js index 2a7c025a06..f4b3f8ccee 100644 --- a/test/simple/test-http-res-write-end-dont-take-array.js +++ b/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(); }); }); diff --git a/test/simple/test-http-response-no-headers.js b/test/simple/test-http-response-no-headers.js index 95bd01aed5..cc5250d826 100644 --- a/test/simple/test-http-response-no-headers.js +++ b/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() { diff --git a/test/simple/test-init.js b/test/simple/test-init.js index 0aaa0d3d5a..da059846d1 100644 --- a/test/simple/test-init.js +++ b/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!'); }); } })(); diff --git a/test/simple/test-module-load-list.js b/test/simple/test-module-load-list.js index 0ecf7a8798..a2a1b33230 100644 --- a/test/simple/test-module-load-list.js +++ b/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'); } } } diff --git a/test/simple/test-net-connect-buffer.js b/test/simple/test-net-connect-buffer.js index 75486af974..d0878ebb4c 100644 --- a/test/simple/test-net-connect-buffer.js +++ b/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 diff --git a/test/simple/test-net-pipe-connect-errors.js b/test/simple/test-net-pipe-connect-errors.js index f5896bf889..b659f43983 100644 --- a/test/simple/test-net-pipe-connect-errors.js +++ b/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 () { - assert.ok(false); - } -); +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); diff --git a/test/simple/test-path.js b/test/simple/test-path.js index e16b459d92..1ee78dad68 100644 --- a/test/simple/test-path.js +++ b/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); diff --git a/test/simple/test-punycode.js b/test/simple/test-punycode.js index 9a144c58a1..1fd67105d6 100644 --- a/test/simple/test-punycode.js +++ b/test/simple/test-punycode.js @@ -62,101 +62,102 @@ assert.equal(punycode.decode('wgv71a119e'), '日本語'); var tests = { // (A) Arabic (Egyptian) 'egbpdaj6bu4bxfgehfvwxn': - '\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648' + - '\u0634\u0639\u0631\u0628\u064A\u061F', + '\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648' + + '\u0634\u0639\u0631\u0628\u064A\u061F', // (B) Chinese (simplified) 'ihqwcrb4cv8a8dqg056pqjye': - '\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587', + '\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587', // (C) Chinese (traditional) 'ihqwctvzc91f659drss3x8bo0yb': - '\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587', + '\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587', // (D) Czech: Proprostnemluvesky 'Proprostnemluvesky-uyb24dma41a': - '\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074\u011B\u006E' + - '\u0065\u006D\u006C\u0075\u0076\u00ED\u010D\u0065\u0073\u006B\u0079', + '\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074\u011B\u006E' + + '\u0065\u006D\u006C\u0075\u0076\u00ED\u010D\u0065\u0073\u006B\u0079', // (E) Hebrew '4dbcagdahymbxekheh6e0a7fei0b': - '\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0' + - '\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA', + '\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0' + + '\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA', // (F) Hindi (Devanagari) 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd': - '\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940' + - '\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B' + - '\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902', + '\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940' + + '\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B' + + '\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902', // (G) Japanese (kanji and hiragana) 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa': - '\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057' + - '\u3066\u304F\u308C\u306A\u3044\u306E\u304B', + '\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057' + + '\u3066\u304F\u308C\u306A\u3044\u306E\u304B', // (H) Korean (Hangul syllables) '989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c': - '\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D' + - '\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B' + - '\uC744\uAE4C', + '\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D' + + '\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B' + + '\uC744\uAE4C', // (I) Russian (Cyrillic) /* XXX disabled, fails - possibly a bug in the RFC 'b1abfaaepdrnnbgefbaDotcwatmq2g4l': - '\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438' + - '\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E' + - '\u0440\u0443\u0441\u0441\u043A\u0438', + '\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438' + + '\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E' + + '\u0440\u0443\u0441\u0441\u043A\u0438', */ // (J) Spanish: PorqunopuedensimplementehablarenEspaol 'PorqunopuedensimplementehablarenEspaol-fmd56a': - '\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070\u0075\u0065' + - '\u0064\u0065\u006E\u0073\u0069\u006D\u0070\u006C\u0065\u006D\u0065' + - '\u006E\u0074\u0065\u0068\u0061\u0062\u006C\u0061\u0072\u0065\u006E' + - '\u0045\u0073\u0070\u0061\u00F1\u006F\u006C', + '\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070\u0075\u0065' + + '\u0064\u0065\u006E\u0073\u0069\u006D\u0070\u006C\u0065\u006D\u0065' + + '\u006E\u0074\u0065\u0068\u0061\u0062\u006C\u0061\u0072\u0065\u006E' + + '\u0045\u0073\u0070\u0061\u00F1\u006F\u006C', - // (K) Vietnamese: TisaohkhngthchnitingVit + // (K) Vietnamese: Tisaohkhngth + // chnitingVit 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g': - '\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B\u0068\u00F4' + - '\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068\u1EC9\u006E\u00F3\u0069' + - '\u0074\u0069\u1EBF\u006E\u0067\u0056\u0069\u1EC7\u0074', + '\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B\u0068\u00F4' + + '\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068\u1EC9\u006E\u00F3\u0069' + + '\u0074\u0069\u1EBF\u006E\u0067\u0056\u0069\u1EC7\u0074', // (L) 3B '3B-ww4c5e180e575a65lsy2b': - '\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F', + '\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F', // (M) -with-SUPER-MONKEYS '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n': - '\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074\u0068\u002D' + - '\u0053\u0055\u0050\u0045\u0052\u002D\u004D\u004F\u004E\u004B\u0045' + - '\u0059\u0053', + '\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074\u0068\u002D' + + '\u0053\u0055\u0050\u0045\u0052\u002D\u004D\u004F\u004E\u004B\u0045' + + '\u0059\u0053', // (N) Hello-Another-Way- 'Hello-Another-Way--fc4qua05auwb3674vfr0b': - '\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F\u0074\u0068' + - '\u0065\u0072\u002D\u0057\u0061\u0079\u002D\u305D\u308C\u305E\u308C' + - '\u306E\u5834\u6240', + '\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F\u0074\u0068' + + '\u0065\u0072\u002D\u0057\u0061\u0079\u002D\u305D\u308C\u305E\u308C' + + '\u306E\u5834\u6240', // (O) 2 '2-u9tlzr9756bt3uc0v': - '\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032', + '\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032', // (P) MajiKoi5 'MajiKoi5-783gue6qz075azm5e': - '\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059\u308B\u0035' + - '\u79D2\u524D', + '\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059\u308B\u0035' + + '\u79D2\u524D', // (Q) de 'de-jg4avhby1noc0d': - '\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0', + '\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0', // (R) 'd9juau41awczczp': - '\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067', + '\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067', // (S) -> $1.00 <- '-> $1.00 <--': - '\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020\u003C\u002D' + '\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020\u003C\u002D' }; var errors = 0; diff --git a/test/simple/test-readdir.js b/test/simple/test-readdir.js index 0f95ea2852..24997241f9 100644 --- a/test/simple/test-readdir.js +++ b/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; diff --git a/test/simple/test-regress-GH-1899.js b/test/simple/test-regress-GH-1899.js index 350e6947a3..7fc8007a24 100644 --- a/test/simple/test-regress-GH-1899.js +++ b/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'); }); diff --git a/test/simple/test-regress-GH-877.js b/test/simple/test-regress-GH-877.js index 0714e6df5d..d9877f431f 100644 --- a/test/simple/test-regress-GH-877.js +++ b/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; } } }); diff --git a/test/simple/test-repl-.save.load.js b/test/simple/test-repl-.save.load.js index 97a0a53de9..ef31831171 100644 --- a/test/simple/test-repl-.save.load.js +++ b/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? diff --git a/test/simple/test-setproctitle.js b/test/simple/test-setproctitle.js index 0bf6fd35c3..207c2e3f51 100644 --- a/test/simple/test-setproctitle.js +++ b/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; diff --git a/test/simple/test-stdin-pause-resume.js b/test/simple/test-stdin-pause-resume.js index cfa44bae2c..fed5d66532 100644 --- a/test/simple/test-stdin-pause-resume.js +++ b/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); diff --git a/test/simple/test-tls-passphrase.js b/test/simple/test-tls-passphrase.js index 7dbb1d711f..bb458bcc25 100644 --- a/test/simple/test-tls-passphrase.js +++ b/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) { diff --git a/test/simple/test-tls-session-cache.js b/test/simple/test-tls-session-cache.js index 53f736b84d..64e4199358 100644 --- a/test/simple/test-tls-session-cache.js +++ b/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; diff --git a/test/simple/test-tls-set-ciphers.js b/test/simple/test-tls-set-ciphers.js index ba5c868d12..576094dcb7 100644 --- a/test/simple/test-tls-set-ciphers.js +++ b/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; diff --git a/test/simple/test-tty-stdout-end.js b/test/simple/test-tty-stdout-end.js index f09bf8ac76..7c7f7feb2b 100644 --- a/test/simple/test-tty-stdout-end.js +++ b/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); diff --git a/test/simple/test-util-inspect.js b/test/simple/test-util-inspect.js index c7a64f6390..d866b41dd2 100644 --- a/test/simple/test-util-inspect.js +++ b/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); diff --git a/test/simple/test-util.js b/test/simple/test-util.js index bb1e7c012b..87ee77509a 100644 --- a/test/simple/test-util.js +++ b/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))); diff --git a/test/simple/test-zlib-from-gzip.js b/test/simple/test-zlib-from-gzip.js index 9607bd3911..3993542099 100644 --- a/test/simple/test-zlib-from-gzip.js +++ b/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 + ']'); } }); diff --git a/test/simple/test-zlib-from-string.js b/test/simple/test-zlib-from-string.js index fe4fb49840..83bdeea83a 100644 --- a/test/simple/test-zlib-from-string.js +++ b/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'); }); diff --git a/test/simple/test-zlib-random-byte-pipes.js b/test/simple/test-zlib-random-byte-pipes.js index ec5d7015e7..88838c68ca 100644 --- a/test/simple/test-zlib-random-byte-pipes.js +++ b/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'); -}) +});