From a248653e9ddf6396d7ba98fbbdda46932015d796 Mon Sep 17 00:00:00 2001 From: Saquib Khan Date: Wed, 13 May 2015 00:28:34 +0530 Subject: [PATCH] test: Lint added for test folder. Added closure linter for test folder. Fixed 2k+ issues in 300 files. After this fix there is no lint error in test scripts. Fixes #25280 --- Makefile | 4 +- test/addons/async-hello-world/test.js | 6 +- test/addons/repl-domain-abort/test.js | 4 +- test/common.js | 36 +-- test/debugger/test-debug-break-on-uncaught.js | 48 ++-- .../test-debugger-repl-break-in-module.js | 26 +- test/debugger/test-debugger-repl-restart.js | 6 +- test/debugger/test-debugger-repl-term.js | 6 +- test/disabled/test-debug-brk-file.js | 4 +- test/disabled/test-readline.js | 11 +- test/external/ssl-options/test.js | 115 ++++---- test/fixtures/child-process-persistent.js | 2 +- test/fixtures/clustered-server/app.js | 2 +- test/fixtures/parent-process-nonpersistent.js | 2 +- test/fixtures/throws_error4.js | 2 +- test/gc/node_modules/weak/lib/weak.js | 18 +- test/gc/test-http-client-connaborted.js | 22 +- test/gc/test-http-client-onerror.js | 22 +- test/gc/test-http-client-timeout.js | 32 +-- test/gc/test-http-client.js | 26 +- test/gc/test-net-timeout.js | 20 +- .../test-dgram-multicast-multi-process.js | 4 +- test/internet/test-dns.js | 22 +- test/internet/test-net-connect-unref.js | 2 +- test/message/eval_messages.js | 10 +- test/message/stdin_messages.js | 10 +- test/message/vm_dont_display_runtime_error.js | 12 +- test/message/vm_dont_display_syntax_error.js | 12 +- test/pummel/test-crypto-dh.js | 21 +- test/pummel/test-dh-regr.js | 6 +- test/pummel/test-dtrace-jsstack.js | 20 +- test/pummel/test-exec.js | 26 +- test/pummel/test-fs-readfile-large.js | 8 +- test/pummel/test-fs-watch-file-slow.js | 32 +-- test/pummel/test-fs-watch-file.js | 2 +- test/pummel/test-keep-alive.js | 5 +- test/pummel/test-net-throttle.js | 3 +- test/pummel/test-postmortem-details.js | 34 +-- test/pummel/test-postmortem-findjsobjects.js | 18 +- test/pummel/test-postmortem-jsstack.js | 42 +-- test/pummel/test-regress-GH-892.js | 6 +- test/pummel/test-smalloc-alloc-segfault.js | 2 +- test/pummel/test-smalloc-dispose-segfault.js | 2 +- .../pummel/test-smalloc-sliceonto-segfault.js | 2 +- test/pummel/test-stream2-basic.js | 206 +++++++-------- test/pummel/test-tls-server-large-request.js | 2 +- test/pummel/test-tls-session-timeout.js | 8 +- test/simple/test-assert.js | 12 +- test/simple/test-beforeexit-event.js | 10 +- test/simple/test-buffer-concat.js | 8 +- test/simple/test-buffer-inspect.js | 2 +- test/simple/test-buffer-slice.js | 4 +- test/simple/test-buffer.js | 44 ++- test/simple/test-child-process-buffering.js | 2 +- test/simple/test-child-process-cwd.js | 2 +- test/simple/test-child-process-detached.js | 13 +- test/simple/test-child-process-double-pipe.js | 2 +- test/simple/test-child-process-exec-buffer.js | 4 +- test/simple/test-child-process-execsync.js | 3 +- .../test-child-process-fork-and-spawn.js | 24 +- test/simple/test-child-process-fork-dgram.js | 20 +- .../test-child-process-fork-exec-argv.js | 4 +- .../test-child-process-fork-getconnections.js | 2 +- test/simple/test-child-process-fork-ref.js | 8 +- test/simple/test-child-process-fork-ref2.js | 6 +- test/simple/test-child-process-spawn-error.js | 2 +- .../test-child-process-spawn-typeerror.js | 27 +- .../test-child-process-spawnsync-timeout.js | 3 +- test/simple/test-child-process-spawnsync.js | 3 +- test/simple/test-child-process-stdin.js | 2 +- .../test-child-process-stdout-flush-exit.js | 6 +- test/simple/test-cluster-basic.js | 2 +- test/simple/test-cluster-dgram-1.js | 2 +- test/simple/test-cluster-dgram-2.js | 5 +- .../test-cluster-disconnect-unshared-tcp.js | 2 +- test/simple/test-cluster-rr-domain-listen.js | 2 +- .../test-cluster-setup-master-cumulative.js | 4 +- .../test-cluster-setup-master-multiple.js | 2 +- test/simple/test-cluster-worker-exit.js | 72 ++--- .../simple/test-cluster-worker-forced-exit.js | 22 +- .../simple/test-cluster-worker-isconnected.js | 22 +- test/simple/test-cluster-worker-isdead.js | 20 +- test/simple/test-cluster-worker-kill.js | 82 +++--- test/simple/test-cluster-worker-no-exit.js | 8 +- test/simple/test-console-instance.js | 2 +- test/simple/test-console.js | 10 +- test/simple/test-crypto-authenticated.js | 4 +- test/simple/test-crypto-binary-default.js | 8 +- test/simple/test-crypto-certificate.js | 6 +- test/simple/test-crypto-domains.js | 17 +- test/simple/test-crypto-hash-stream-pipe.js | 2 +- test/simple/test-crypto-padding-aes256.js | 14 +- test/simple/test-crypto-stream.js | 18 +- test/simple/test-crypto-verify-failure.js | 10 +- test/simple/test-crypto.js | 22 +- test/simple/test-debug-cluster.js | 8 +- test/simple/test-debug-port-cluster.js | 8 +- test/simple/test-debug-signal-cluster.js | 6 +- test/simple/test-deprecation-flags.js | 3 +- test/simple/test-dgram-bind.js | 2 +- .../test-dgram-broadcast-multi-process.js | 4 +- test/simple/test-dgram-bytes-length.js | 9 +- test/simple/test-dgram-empty-packet.js | 6 +- test/simple/test-dgram-listen-after-bind.js | 6 +- test/simple/test-dgram-multicast-setTTL.js | 2 +- test/simple/test-dgram-oob-buffer.js | 2 +- test/simple/test-dgram-send-bad-arguments.js | 12 +- .../test-dgram-send-callback-buffer-length.js | 10 +- test/simple/test-dgram-send-empty-buffer.js | 4 +- test/simple/test-dh-padding.js | 4 +- test/simple/test-dns-cares-domains.js | 4 +- test/simple/test-dns-regress-7070.js | 4 +- test/simple/test-dns.js | 18 +- test/simple/test-domain-enter-exit.js | 2 +- test/simple/test-domain-exit-dispose-again.js | 4 +- test/simple/test-domain-exit-dispose.js | 4 +- test/simple/test-domain-from-timer.js | 2 +- test/simple/test-domain-http-server.js | 4 +- test/simple/test-domain-multi.js | 12 +- test/simple/test-domain-nested-throw.js | 8 +- test/simple/test-domain-nested.js | 14 +- test/simple/test-domain.js | 14 +- .../test-event-emitter-max-listeners.js | 2 +- ...mitter-no-error-provided-to-error-event.js | 4 +- test/simple/test-event-emitter-once.js | 6 +- ...test-event-emitter-remove-all-listeners.js | 2 +- test/simple/test-event-emitter-subclass.js | 2 +- test/simple/test-file-write-stream.js | 12 +- test/simple/test-fs-access.js | 6 +- test/simple/test-fs-empty-readStream.js | 16 +- .../test-fs-non-number-arguments-throw.js | 14 +- test/simple/test-fs-null-bytes.js | 50 ++-- test/simple/test-fs-read-stream-resume.js | 2 +- test/simple/test-fs-read-stream.js | 2 +- .../simple/test-fs-readfile-zero-byte-liar.js | 4 +- test/simple/test-fs-realpath.js | 14 +- test/simple/test-fs-watch-recursive.js | 2 +- test/simple/test-fs-watch.js | 4 +- .../test-fs-write-stream-change-open.js | 2 +- test/simple/test-http-1.0-keep-alive.js | 34 +-- test/simple/test-http-abort-client.js | 2 +- test/simple/test-http-abort-queued.js | 6 +- test/simple/test-http-agent-false.js | 11 +- test/simple/test-http-agent-keepalive.js | 32 +-- test/simple/test-http-agent-no-protocol.js | 2 +- test/simple/test-http-client-pipe-end.js | 2 +- .../test-http-client-response-domain.js | 2 +- test/simple/test-http-client-timeout-agent.js | 23 +- test/simple/test-http-client-timeout-event.js | 6 +- .../test-http-client-timeout-with-data.js | 2 +- test/simple/test-http-createConnection.js | 2 +- .../test-http-destroyed-socket-write2.js | 4 +- .../test-http-end-throw-socket-handling.js | 4 +- test/simple/test-http-flush.js | 2 +- ...-http-incoming-pipelined-socket-destroy.js | 4 +- test/simple/test-http-keepalive-client.js | 2 +- test/simple/test-http-keepalive-request.js | 2 +- .../test-http-localaddress-bind-error.js | 4 +- test/simple/test-http-localaddress.js | 6 +- test/simple/test-http-many-ended-pipelines.js | 2 +- test/simple/test-http-parser.js | 4 +- .../test-http-remove-header-stays-removed.js | 2 +- .../test-http-response-status-message.js | 21 +- test/simple/test-http-server-multiheaders.js | 6 +- test/simple/test-http-server-multiheaders2.js | 16 +- test/simple/test-http-server-stale-close.js | 2 +- test/simple/test-http-timeout-overflow.js | 4 +- test/simple/test-http-timeout.js | 32 +-- ....parse-only-support-http-https-protocol.js | 18 +- test/simple/test-http-zero-length-write.js | 4 +- .../test-https-client-checkServerIdentity.js | 16 +- .../test-https-localaddress-bind-error.js | 4 +- test/simple/test-https-localaddress.js | 6 +- test/simple/test-https-socket-options.js | 5 +- test/simple/test-https-strict.js | 15 +- test/simple/test-intl.js | 8 +- test/simple/test-listen-fd-cluster.js | 12 +- .../simple/test-listen-fd-detached-inherit.js | 10 +- test/simple/test-listen-fd-detached.js | 10 +- test/simple/test-listen-fd-ebadf.js | 4 +- test/simple/test-listen-fd-server.js | 10 +- ...test-microtask-queue-integration-domain.js | 18 +- .../test-microtask-queue-integration.js | 18 +- .../test-module-globalpaths-nodepath.js | 2 +- test/simple/test-module-loading.js | 2 +- test/simple/test-module-nodemodulepaths.js | 4 +- test/simple/test-net-GH-5504.js | 2 +- test/simple/test-net-create-connection.js | 2 +- test/simple/test-net-error-twice.js | 8 +- test/simple/test-net-isip.js | 2 +- test/simple/test-net-listen-fd0.js | 6 +- test/simple/test-net-localerror.js | 4 +- test/simple/test-net-localport.js | 4 +- test/simple/test-net-remote-address-port.js | 2 +- test/simple/test-net-server-address.js | 12 +- test/simple/test-net-socket-timeout-unref.js | 11 +- test/simple/test-net-stream.js | 16 +- test/simple/test-next-tick-domain.js | 3 +- test/simple/test-next-tick-error-spin.js | 14 +- test/simple/test-path-parse-format.js | 42 +-- test/simple/test-path.js | 91 +++---- test/simple/test-process-argv-0.js | 6 +- test/simple/test-process-binding.js | 14 +- test/simple/test-process-exec-argv.js | 4 +- test/simple/test-process-exit-code.js | 2 +- test/simple/test-process-hrtime.js | 2 +- test/simple/test-process-kill-pid.js | 4 +- test/simple/test-querystring.js | 10 +- test/simple/test-readline-interface.js | 32 ++- test/simple/test-regress-GH-1726.js | 2 +- test/simple/test-regress-GH-3542.js | 6 +- test/simple/test-regress-GH-4015.js | 6 +- test/simple/test-regress-GH-4256.js | 2 +- test/simple/test-regress-GH-4948.js | 20 +- test/simple/test-regress-GH-5927.js | 4 +- test/simple/test-regress-GH-7511.js | 4 +- test/simple/test-regress-GH-9161.js | 2 +- test/simple/test-repl-autolibs.js | 14 +- test/simple/test-repl-console.js | 2 +- test/simple/test-repl-domain.js | 14 +- test/simple/test-repl-end-emits-exit.js | 2 +- test/simple/test-repl-options.js | 2 +- test/simple/test-repl-reset-event.js | 9 +- test/simple/test-repl-setprompt.js | 4 +- test/simple/test-repl-tab-complete.js | 2 +- test/simple/test-repl-timeout-throw.js | 2 +- test/simple/test-repl.js | 45 +++- .../test-socket-write-after-fin-error.js | 2 +- test/simple/test-socket-write-after-fin.js | 2 +- test/simple/test-stream-big-packet.js | 14 +- test/simple/test-stream-duplex.js | 8 +- test/simple/test-stream-push-order.js | 6 +- test/simple/test-stream-push-strings.js | 2 +- ...tream-transform-objectmode-falsey-value.js | 2 +- .../test-stream-transform-split-objectmode.js | 20 +- .../simple/test-stream-unshift-empty-chunk.js | 38 +-- ...stream-writable-change-default-encoding.js | 4 +- .../test-stream-writable-decoded-encoding.js | 8 +- test/simple/test-stream-writev.js | 3 +- ...est-stream2-base64-single-char-read-end.js | 6 +- test/simple/test-stream2-fs.js | 4 +- test/simple/test-stream2-push.js | 14 +- ...st-stream2-readable-empty-buffer-no-eof.js | 4 +- .../simple/test-stream2-readable-from-list.js | 16 +- .../test-stream2-readable-non-empty-end.js | 2 +- .../test-stream2-readable-wrap-empty.js | 10 +- test/simple/test-stream2-readable-wrap.js | 18 +- test/simple/test-stream2-set-encoding.js | 250 +++++++++--------- test/simple/test-stream2-stderr-sync.js | 2 +- test/simple/test-stream2-transform.js | 24 +- test/simple/test-stream2-unpipe-drain.js | 20 +- test/simple/test-stream2-writable.js | 40 +-- test/simple/test-stream3-pause-then-read.js | 2 +- test/simple/test-string-decoder-end.js | 2 +- test/simple/test-string-decoder.js | 22 +- test/simple/test-stringbytes-external.js | 14 +- test/simple/test-timers-immediate.js | 2 +- test/simple/test-timers-ordering.js | 6 +- ...imeout-removes-other-socket-unref-timer.js | 2 +- test/simple/test-timers-this.js | 20 +- test/simple/test-timers-unref-active.js | 2 +- test/simple/test-timers-unref.js | 3 +- test/simple/test-tls-alert.js | 5 +- test/simple/test-tls-cert-regression.js | 36 +-- test/simple/test-tls-check-server-identity.js | 28 +- test/simple/test-tls-cipher-list.js | 10 +- .../simple/test-tls-client-default-ciphers.js | 2 +- test/simple/test-tls-dhe.js | 2 +- test/simple/test-tls-econnreset.js | 56 ++-- test/simple/test-tls-fast-writing.js | 4 +- test/simple/test-tls-hello-parser-failure.js | 2 +- ...test-tls-honorcipherorder-secureOptions.js | 14 +- test/simple/test-tls-honorcipherorder.js | 2 +- test/simple/test-tls-inception.js | 14 +- test/simple/test-tls-interleave.js | 6 +- test/simple/test-tls-npn-server-client.js | 2 +- .../test-tls-peer-certificate-encoding.js | 2 +- test/simple/test-tls-peer-certificate.js | 4 +- test/simple/test-tls-session-cache.js | 2 +- test/simple/test-tls-sni-option.js | 4 +- test/simple/test-tls-sni-server-client.js | 4 +- test/simple/test-tls-ticket.js | 3 +- test/simple/test-url.js | 39 +-- test/simple/test-util-format.js | 3 +- test/simple/test-util-inspect.js | 16 +- test/simple/test-util-log.js | 4 +- test/simple/test-util.js | 14 +- test/simple/test-vm-basic.js | 22 +- test/simple/test-vm-context-async-script.js | 2 +- test/simple/test-vm-context.js | 4 +- test/simple/test-vm-create-context-arg.js | 6 +- test/simple/test-vm-cross-context.js | 2 +- test/simple/test-vm-function-declaration.js | 2 +- test/simple/test-vm-new-script-new-context.js | 2 +- test/simple/test-vm-run-in-new-context.js | 2 +- test/simple/test-vm-timeout-rethrow.js | 4 +- test/simple/test-zlib-convenience-methods.js | 20 +- test/simple/test-zlib-dictionary-fail.js | 4 +- test/simple/test-zlib-invalid-input.js | 10 +- test/simple/test-zlib-zero-byte.js | 2 +- test/timers/test-timers-reliability.js | 22 +- 301 files changed, 1863 insertions(+), 1777 deletions(-) diff --git a/Makefile b/Makefile index c241480dfc57..5ff071823243 100644 --- a/Makefile +++ b/Makefile @@ -419,10 +419,10 @@ bench-idle: ./node benchmark/idle_clients.js & jslintfix: - PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js + PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/fixjsstyle.py --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js jslint: - PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js + PYTHONPATH=tools/closure_linter/ $(PYTHON) tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ -r test/ --exclude_files lib/punycode.js,test/fixtures/throws_error4.js,test/fixtures/uncaught-exceptions/parse-error-mod.js,test/message/throw_in_line_with_tabs.js CPPLINT_EXCLUDE ?= CPPLINT_EXCLUDE += src/node_root_certs.h diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js index 83f5e7206ec0..4fdc70634ad0 100644 --- a/test/addons/async-hello-world/test.js +++ b/test/addons/async-hello-world/test.js @@ -2,14 +2,14 @@ var assert = require('assert'); var binding = require('./build/Release/binding'); var called = false; -process.on('exit', function () { +process.on('exit', function() { assert(called); }); -binding(5, function (err, val) { +binding(5, function(err, val) { assert.equal(null, err); assert.equal(10, val); - process.nextTick(function () { + process.nextTick(function() { called = true; }); }); diff --git a/test/addons/repl-domain-abort/test.js b/test/addons/repl-domain-abort/test.js index c35faafb4559..f713cd5dbc98 100644 --- a/test/addons/repl-domain-abort/test.js +++ b/test/addons/repl-domain-abort/test.js @@ -34,8 +34,8 @@ process.on('exit', function() { var lines = [ // This line shouldn't cause an assertion error. 'require(\'' + buildPath + '\')' + - // Log output to double check callback ran. - '.method(function() { console.log(\'cb_ran\'); });', + // Log output to double check callback ran. + '.method(function() { console.log(\'cb_ran\'); });' ]; var dInput = new stream.Readable(); diff --git a/test/common.js b/test/common.js index fb81e9f0f01a..741335367919 100644 --- a/test/common.js +++ b/test/common.js @@ -48,8 +48,8 @@ if (!fs.existsSync(exports.opensslCli)) if (process.platform === 'win32') { exports.faketimeCli = false; } else { - exports.faketimeCli = path.join(__dirname, "..", "tools", "faketime", "src", - "faketime"); + exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src', + 'faketime'); } var ifaces = os.networkInterfaces(); @@ -175,8 +175,8 @@ function leakedGlobals() { if (-1 === knownGlobals.indexOf(global[val])) leaked.push(val); - return leaked; -}; + return leaked; +} exports.leakedGlobals = leakedGlobals; // Turn this off if the test should not check for global leaks. @@ -243,7 +243,7 @@ exports.checkSpawnSyncRet = function(ret) { var etcServicesFileName = path.join('/etc', 'services'); if (process.platform === 'win32') { etcServicesFileName = path.join(process.env.SystemRoot, 'System32', 'drivers', - 'etc', 'services'); + 'etc', 'services'); } /* @@ -258,11 +258,11 @@ if (process.platform === 'win32') { */ exports.getServiceName = function getServiceName(port, protocol) { if (port == null) { - throw new Error("Missing port number"); + throw new Error('Missing port number'); } if (typeof protocol !== 'string') { - throw new Error("Protocol must be a string"); + throw new Error('Protocol must be a string'); } /* @@ -273,13 +273,13 @@ exports.getServiceName = function getServiceName(port, protocol) { try { /* - * I'm not a big fan of readFileSync, but reading /etc/services asynchronously - * here would require implementing a simple line parser, which seems overkill - * for a simple utility function that is not running concurrently with any - * other one. + * I'm not a big fan of readFileSync, but reading /etc/services + * asynchronously here would require implementing a simple + * line parser, which seems overkill for a simple utility function + * that is not running concurrently with any other one. */ var servicesContent = fs.readFileSync(etcServicesFileName, - { encoding: 'utf8'}); + { encoding: 'utf8'}); var regexp = util.format('^(\\w+)\\s+\\s%d/%s\\s', port, protocol); var re = new RegExp(regexp, 'm'); @@ -287,22 +287,22 @@ exports.getServiceName = function getServiceName(port, protocol) { if (matches && matches.length > 1) { serviceName = matches[1]; } - } catch(e) { + } catch (e) { console.error('Cannot read file: ', etcServicesFileName); return undefined; } return serviceName; -} +}; exports.isValidHostname = function(str) { // See http://stackoverflow.com/a/3824105 var re = new RegExp( - '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' + - '(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$'); + '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' + + '(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$'); return !!str.match(re) && str.length <= 255; -} +}; exports.hasMultiLocalhost = function hasMultiLocalhost() { var TCP = process.binding('tcp_wrap').TCP; var t = new TCP(); @@ -328,4 +328,4 @@ exports.getNodeVersion = function getNodeVersion() { patch: patch, pre: pre }; -} +}; diff --git a/test/debugger/test-debug-break-on-uncaught.js b/test/debugger/test-debug-break-on-uncaught.js index c41d940b8770..4f5febaf36e3 100644 --- a/test/debugger/test-debug-break-on-uncaught.js +++ b/test/debugger/test-debug-break-on-uncaught.js @@ -41,7 +41,7 @@ var scenarios; function addScenario(scriptName, throwsInFile, throwsOnLine) { if (!scenarios) scenarios = []; scenarios.push( - runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run) + runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run) ); } @@ -56,16 +56,16 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { var port = common.PORT + 1337; var testScript = path.join( - common.fixturesDir, - 'uncaught-exceptions', - scriptName - ); + common.fixturesDir, + 'uncaught-exceptions', + scriptName + ); - var child = spawn(process.execPath, [ '--debug-brk=' + port, testScript ]); + var child = spawn(process.execPath, ['--debug-brk=' + port, testScript]); child.on('close', function() { assert(asserted, 'debugger did not pause on exception'); if (next) next(); - }) + }); var exceptions = []; @@ -90,25 +90,25 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { function runTest(client) { client.req( - { - command: 'setexceptionbreak', - arguments: { - type: 'uncaught', - enabled: true - } - }, - function(error, result) { - assert.ifError(error); + { + command: 'setexceptionbreak', + arguments: { + type: 'uncaught', + enabled: true + } + }, + function(error, result) { + assert.ifError(error); - client.on('exception', function(event) { - exceptions.push(event.body); - }); + client.on('exception', function(event) { + exceptions.push(event.body); + }); - client.reqContinue(function(error, result) { - assert.ifError(error); - setTimeout(assertHasPaused.bind(null, client), 100); - }); - } + client.reqContinue(function(error, result) { + assert.ifError(error); + setTimeout(assertHasPaused.bind(null, client), 100); + }); + } ); } diff --git a/test/debugger/test-debugger-repl-break-in-module.js b/test/debugger/test-debugger-repl-break-in-module.js index 1fe0aba841ea..4730b57b0a39 100644 --- a/test/debugger/test-debugger-repl-break-in-module.js +++ b/test/debugger/test-debugger-repl-break-in-module.js @@ -39,25 +39,25 @@ repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [ // continue - the breakpoint should be triggered repl.addTest('c', [ - /break in .*[\\\/]mod\.js:23/, - /21/, /22/, /23/, /24/, /25/ + /break in .*[\\\/]mod\.js:23/, + /21/, /22/, /23/, /24/, /25/ ]); // -- RESTORE BREAKPOINT ON RESTART -- // Restart the application - breakpoint should be restored repl.addTest('restart', [].concat( - [ - /terminated/ - ], - repl.handshakeLines, - [ - /Restoring breakpoint mod.js:23/, - /Warning: script 'mod\.js' was not loaded yet\./, - /Restoring breakpoint \).*:\d+/, - /Warning: script '\)[^']*' was not loaded yet\./ - ], - repl.initialBreakLines)); + [ + /terminated/ + ], + repl.handshakeLines, + [ + /Restoring breakpoint mod.js:23/, + /Warning: script 'mod\.js' was not loaded yet\./, + /Restoring breakpoint \).*:\d+/, + /Warning: script '\)[^']*' was not loaded yet\./ + ], + repl.initialBreakLines)); // continue - the breakpoint should be triggered repl.addTest('c', [ diff --git a/test/debugger/test-debugger-repl-restart.js b/test/debugger/test-debugger-repl-restart.js index 5bfc3bbed7e3..bb50d889f6f1 100644 --- a/test/debugger/test-debugger-repl-restart.js +++ b/test/debugger/test-debugger-repl-restart.js @@ -23,17 +23,17 @@ var repl = require('./helper-debugger-repl.js'); repl.startDebugger('breakpoints.js'); var linesWithBreakpoint = [ - /1/, /2/, /3/, /4/, /5/, /\* 6/ + /1/, /2/, /3/, /4/, /5/, /\* 6/ ]; // We slice here, because addTest will change the given array. repl.addTest('sb(6)', linesWithBreakpoint.slice()); -var initialLines = repl.initialLines.slice() +var initialLines = repl.initialLines.slice(); initialLines.splice(2, 0, /Restoring/, /Warning/); // Restart the debugged script repl.addTest('restart', [ - /terminated/, + /terminated/ ].concat(initialLines)); repl.addTest('list(5)', linesWithBreakpoint); diff --git a/test/debugger/test-debugger-repl-term.js b/test/debugger/test-debugger-repl-term.js index edd54203c562..53e22943f7e5 100644 --- a/test/debugger/test-debugger-repl-term.js +++ b/test/debugger/test-debugger-repl-term.js @@ -38,7 +38,7 @@ addTest('n', [ addTest('', [ /debug>/, /break in .*:5/, - /3/, /4/, /5/, /6/, /7/, + /3/, /4/, /5/, /6/, /7/ ]); // continue @@ -52,12 +52,12 @@ addTest('c', [ addTest('', [ /debug>/, /break in .*:5/, - /3/, /4/, /5/, /6/, /7/, + /3/, /4/, /5/, /6/, /7/ ]); // should repeat continue addTest('', [ /debug>/, /break in .*:23/, - /21/, /22/, /23/, /24/, /25/, + /21/, /22/, /23/, /24/, /25/ ]); diff --git a/test/disabled/test-debug-brk-file.js b/test/disabled/test-debug-brk-file.js index ee9f4a58a06d..66ca0a9ea953 100644 --- a/test/disabled/test-debug-brk-file.js +++ b/test/disabled/test-debug-brk-file.js @@ -83,7 +83,7 @@ function debug_client_connect() { // get breakpoint list and check if it exists on line 0 if (!body.length) { var req = JSON.stringify({'seq': 1, 'type': 'request', - 'command': 'listbreakpoints'}); + 'command': 'listbreakpoints'}); conn.write('Content-Length: ' + req.length + '\r\n\r\n' + req); return; } @@ -97,7 +97,7 @@ function debug_client_connect() { } var req = JSON.stringify({'seq': 100, 'type': 'request', - 'command': 'disconnect'}); + 'command': 'disconnect'}); conn.write('Content-Length: ' + req.length + '\r\n\r\n' + req); } finally { msg = null; diff --git a/test/disabled/test-readline.js b/test/disabled/test-readline.js index 4a67b5d65f54..51c34c70ec3a 100644 --- a/test/disabled/test-readline.js +++ b/test/disabled/test-readline.js @@ -60,7 +60,7 @@ var readlineFakeStream = function() { } }); var _stdoutWrite = process.stdout.write; - process.stdout.write = function (data) { + process.stdout.write = function(data) { data.split('').forEach(rl.written_bytes.push.bind(rl.written_bytes)); _stdoutWrite.apply(this, arguments); } @@ -73,7 +73,7 @@ var written_bytes_length, refreshed; rl.write('foo'); assert.equal(3, rl.cursor); -[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function (key) { +[key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) { rl.write.apply(rl, key.home); assert.equal(0, rl.cursor); rl.write.apply(rl, key.end); @@ -95,8 +95,8 @@ rl.write.apply(rl, key.xterm.home); {cursor: 8, key: key.xterm.metab}, {cursor: 7, key: key.xterm.metab}, {cursor: 4, key: key.xterm.metab}, - {cursor: 0, key: key.xterm.metab}, -].forEach(function (action) { + {cursor: 0, key: key.xterm.metab} +].forEach(function(action) { written_bytes_length = rl.written_bytes.length; rl.write.apply(rl, action.key); assert.equal(action.cursor, rl.cursor); @@ -107,7 +107,8 @@ rl.write.apply(rl, key.xterm.home); rl = readlineFakeStream(); rl.write('foo bar.hop/zoo'); rl.write.apply(rl, key.xterm.home); -['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', ''].forEach(function (expectedLine) { +['bar.hop/zoo', '.hop/zoo', 'hop/zoo', '/zoo', 'zoo', '' +].forEach(function(expectedLine) { rl.write.apply(rl, key.xterm.metad); assert.equal(0, rl.cursor); assert.equal(expectedLine, rl.line); diff --git a/test/external/ssl-options/test.js b/test/external/ssl-options/test.js index 320d323077e7..a14252bfc5df 100644 --- a/test/external/ssl-options/test.js +++ b/test/external/ssl-options/test.js @@ -1,26 +1,26 @@ -var tls = require('tls'); -var fs = require('fs'); -var path = require('path'); -var fork = require('child_process').fork; -var assert = require('assert'); +var tls = require('tls'); +var fs = require('fs'); +var path = require('path'); +var fork = require('child_process').fork; +var assert = require('assert'); var constants = require('constants'); -var os = require('os'); +var os = require('os'); -var async = require('async'); -var debug = require('debug')('test-node-ssl'); +var async = require('async'); +var debug = require('debug')('test-node-ssl'); var common = require('../../common'); var SSL2_COMPATIBLE_CIPHERS = 'RC4-MD5'; -var CMD_LINE_OPTIONS = [ null, "--enable-ssl2", "--enable-ssl3" ]; +var CMD_LINE_OPTIONS = [null, '--enable-ssl2', '--enable-ssl3']; var SERVER_SSL_PROTOCOLS = [ null, 'SSLv2_method', 'SSLv2_server_method', 'SSLv3_method', 'SSLv3_server_method', 'TLSv1_method', 'TLSv1_server_method', - 'SSLv23_method','SSLv23_server_method' + 'SSLv23_method', 'SSLv23_server_method' ]; var CLIENT_SSL_PROTOCOLS = [ @@ -28,7 +28,7 @@ var CLIENT_SSL_PROTOCOLS = [ 'SSLv2_method', 'SSLv2_client_method', 'SSLv3_method', 'SSLv3_client_method', 'TLSv1_method', 'TLSv1_client_method', - 'SSLv23_method','SSLv23_client_method' + 'SSLv23_method', 'SSLv23_client_method' ]; var SECURE_OPTIONS = [ @@ -54,15 +54,17 @@ function xtend(source) { function isAutoNegotiationProtocol(sslProtocol) { assert(sslProtocol === null || typeof sslProtocol === 'string'); - return sslProtocol == null || - sslProtocol === 'SSLv23_method' || + return sslProtocol == null || + sslProtocol === 'SSLv23_method' || sslProtocol === 'SSLv23_client_method' || sslProtocol === 'SSLv23_server_method'; } function isSameSslProtocolVersion(serverSecureProtocol, clientSecureProtocol) { - assert(serverSecureProtocol === null || typeof serverSecureProtocol === 'string'); - assert(clientSecureProtocol === null || typeof clientSecureProtocol === 'string'); + assert(serverSecureProtocol === null || + typeof serverSecureProtocol === 'string'); + assert(clientSecureProtocol === null || + typeof clientSecureProtocol === 'string'); if (serverSecureProtocol === clientSecureProtocol) { return true; @@ -113,7 +115,8 @@ function isSsl2Protocol(secureProtocol) { secureProtocol === 'SSLv2_server_method'; } -function secureProtocolCompatibleWithSecureOptions(secureProtocol, secureOptions, cmdLineOption) { +function secureProtocolCompatibleWithSecureOptions(secureProtocol, + secureOptions, cmdLineOption) { if (secureOptions == null) { if (isSsl2Protocol(secureProtocol) && (!cmdLineOption || cmdLineOption.indexOf('--enable-ssl2') === -1)) { @@ -125,11 +128,13 @@ function secureProtocolCompatibleWithSecureOptions(secureProtocol, secureOptions return false; } } else { - if (secureOptions & constants.SSL_OP_NO_SSLv2 && isSsl2Protocol(secureProtocol)) { + if (secureOptions & constants.SSL_OP_NO_SSLv2 && + isSsl2Protocol(secureProtocol)) { return false; } - if (secureOptions & constants.SSL_OP_NO_SSLv3 && isSsl3Protocol(secureProtocol)) { + if (secureOptions & constants.SSL_OP_NO_SSLv3 && + isSsl3Protocol(secureProtocol)) { return false; } } @@ -188,14 +193,16 @@ function testSetupsCompatible(serverSetup, clientSetup) { function sslSetupMakesSense(cmdLineOption, secureProtocol, secureOption) { if (isSsl2Protocol(secureProtocol)) { if (secureOption & constants.SSL_OP_NO_SSLv2 || - (secureOption == null && (!cmdLineOption || cmdLineOption.indexOf('--enable-ssl2') === -1))) { + (secureOption == null && (!cmdLineOption || + cmdLineOption.indexOf('--enable-ssl2') === -1))) { return false; } } if (isSsl3Protocol(secureProtocol)) { if (secureOption & constants.SSL_OP_NO_SSLv3 || - (secureOption == null && (!cmdLineOption || cmdLineOption.indexOf('--enable-ssl3') === -1))) { + (secureOption == null && (!cmdLineOption || + cmdLineOption.indexOf('--enable-ssl3') === -1))) { return false; } } @@ -208,9 +215,9 @@ function createTestsSetups() { var serversSetup = []; var clientsSetup = []; - CMD_LINE_OPTIONS.forEach(function (cmdLineOption) { - SERVER_SSL_PROTOCOLS.forEach(function (serverSecureProtocol) { - SECURE_OPTIONS.forEach(function (secureOption) { + CMD_LINE_OPTIONS.forEach(function(cmdLineOption) { + SERVER_SSL_PROTOCOLS.forEach(function(serverSecureProtocol) { + SECURE_OPTIONS.forEach(function(secureOption) { if (sslSetupMakesSense(cmdLineOption, serverSecureProtocol, secureOption)) { @@ -231,8 +238,8 @@ function createTestsSetups() { }); }); - CLIENT_SSL_PROTOCOLS.forEach(function (clientSecureProtocol) { - SECURE_OPTIONS.forEach(function (secureOption) { + CLIENT_SSL_PROTOCOLS.forEach(function(clientSecureProtocol) { + SECURE_OPTIONS.forEach(function(secureOption) { if (sslSetupMakesSense(cmdLineOption, clientSecureProtocol, secureOption)) { @@ -256,8 +263,8 @@ function createTestsSetups() { var testSetups = []; var testId = 0; - serversSetup.forEach(function (serverSetup) { - clientsSetup.forEach(function (clientSetup) { + serversSetup.forEach(function(serverSetup) { + clientsSetup.forEach(function(clientSetup) { var testSetup = { server: serverSetup, client: clientSetup, @@ -291,12 +298,12 @@ function runServer(port, secureProtocol, secureOptions, ciphers) { var cert = fs.readFileSync(certPath).toString(); var server = new tls.Server({ key: key, - cert: cert, - ca: [], - ciphers: ciphers, - secureProtocol: secureProtocol, - secureOptions: secureOptions - }); + cert: cert, + ca: [], + ciphers: ciphers, + secureProtocol: secureProtocol, + secureOptions: secureOptions + }); server.listen(port, function() { process.on('message', function onChildMsg(msg) { @@ -336,15 +343,15 @@ function runClient(port, secureProtocol, secureOptions, ciphers) { }, function() { - // TODO jgilli: test that sslProtocolUsed is at least as "secure" as - // "secureProtocol" - /* + // TODO jgilli: test that sslProtocolUsed is at least as "secure" as + // "secureProtocol" + /* * var sslProtocolUsed = con.getVersion(); * debug('Protocol used: ' + sslProtocolUsed); */ - process.send('client_done'); - }); + process.send('client_done'); + }); con.on('error', function(err) { debug('Client could not connect:' + err); @@ -358,7 +365,7 @@ function stringToSecureOptions(secureOptionsString) { var secureOptions; var optionStrings = secureOptionsString.split('|'); - optionStrings.forEach(function (option) { + optionStrings.forEach(function(option) { if (option === 'SSL_OP_NO_SSLv2') { secureOptions |= constants.SSL_OP_NO_SSLv2; } @@ -375,10 +382,10 @@ function stringToSecureOptions(secureOptionsString) { return secureOptions; } -function processTestCmdLineOptions(argv){ +function processTestCmdLineOptions(argv) { var options = {}; - argv.forEach(function (arg) { + argv.forEach(function(arg) { var key; var value; @@ -438,7 +445,7 @@ function secureOptionsToString(secureOptions) { } function forkTestProcess(processType, testSetup, port) { - var argv = [ processType ]; + var argv = [processType]; if (testSetup.secureProtocol) { argv.push('secureProtocol:' + testSetup.secureProtocol); @@ -459,8 +466,8 @@ function forkTestProcess(processType, testSetup, port) { var forkOptions; if (testSetup.cmdLine) { forkOptions = { - execArgv: [ testSetup.cmdLine ] - } + execArgv: [testSetup.cmdLine] + }; } return fork(process.argv[1], @@ -508,7 +515,7 @@ function runTest(testSetup, testDone) { if (serverExitCode != null) { var err; if (!checkTestExitCode(testSetup, serverExitCode, clientExitCode)) - err = new Error("Test failed!"); + err = new Error('Test failed!'); return testDone(err); } else { @@ -522,7 +529,7 @@ function runTest(testSetup, testDone) { if (msg === 'client_done' && serverChild.connected) { serverChild.send('close'); } - }) + }); } }); @@ -533,7 +540,7 @@ function runTest(testSetup, testDone) { if (clientExitCode != null || !clientStarted) { var err; if (!checkTestExitCode(testSetup, serverExitCode, clientExitCode)) - err = new Error("Test failed!"); + err = new Error('Test failed!'); return testDone(err); } @@ -600,7 +607,7 @@ function processDriverCmdLineOptions(argv) { function outputTestResult(test, err, output) { output.write(os.EOL); output.write('Test:' + os.EOL); - output.write(JSON.stringify(test, null, " ")); + output.write(JSON.stringify(test, null, ' ')); output.write(os.EOL); output.write('Result:'); output.write(err ? 'failure' : 'success'); @@ -653,14 +660,14 @@ if (agentType === 'client' || agentType === 'server') { if (driverOptions.outputFile) { testOutput = fs.createWriteStream(driverOptions.outputFile) .on('error', function onError(err) { - console.error(err); - process.exit(1); - }); + console.error(err); + process.exit(1); + }); } debug('Tests setups:'); debug('Number of tests: ' + testSetups.length); - debug(JSON.stringify(testSetups, null, " ")); + debug(JSON.stringify(testSetups, null, ' ')); debug(); var nbTestsStarted = 0; @@ -676,7 +683,7 @@ if (agentType === 'client' || agentType === 'server') { debug('Starting new batch of tests...'); var port = common.PORT; - async.each(tests, function (test, testDone) { + async.each(tests, function(test, testDone) { test.port = port++; ++nbTestsStarted; @@ -698,7 +705,7 @@ if (agentType === 'client' || agentType === 'server') { }, function testsDone(err, results) { if (err) { assert(false, - "At least one test in the most recent batch failed: " + err); + 'At least one test in the most recent batch failed: ' + err); } return callback(err); diff --git a/test/fixtures/child-process-persistent.js b/test/fixtures/child-process-persistent.js index 226ab3329d91..45a50f5a263a 100644 --- a/test/fixtures/child-process-persistent.js +++ b/test/fixtures/child-process-persistent.js @@ -1 +1 @@ -setInterval(function () {}, 500); +setInterval(function() {}, 500); diff --git a/test/fixtures/clustered-server/app.js b/test/fixtures/clustered-server/app.js index 3fca2aaa42fa..260373d3a89d 100644 --- a/test/fixtures/clustered-server/app.js +++ b/test/fixtures/clustered-server/app.js @@ -31,5 +31,5 @@ if (cluster.isMaster) { } } else { var server = http.createServer(handleRequest); - server.listen(common.PORT+1000); + server.listen(common.PORT + 1000); } diff --git a/test/fixtures/parent-process-nonpersistent.js b/test/fixtures/parent-process-nonpersistent.js index a71d1a3882de..4e327ab91926 100644 --- a/test/fixtures/parent-process-nonpersistent.js +++ b/test/fixtures/parent-process-nonpersistent.js @@ -3,7 +3,7 @@ var spawn = require('child_process').spawn, path = require('path'), childPath = path.join(__dirname, 'child-process-persistent.js'); -var child = spawn(process.execPath, [ childPath ], { +var child = spawn(process.execPath, [childPath], { detached: true, stdio: 'ignore' }); diff --git a/test/fixtures/throws_error4.js b/test/fixtures/throws_error4.js index bc7d6f8c6bd6..c1cc12affd75 100644 --- a/test/fixtures/throws_error4.js +++ b/test/fixtures/throws_error4.js @@ -19,7 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -01234567890123456789012345/** +01234567890123456789012345;/** 01234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 01234567890123456789012345678901234567890123456789 diff --git a/test/gc/node_modules/weak/lib/weak.js b/test/gc/node_modules/weak/lib/weak.js index 8081a76c45f9..b110e6782b7d 100644 --- a/test/gc/node_modules/weak/lib/weak.js +++ b/test/gc/node_modules/weak/lib/weak.js @@ -1,18 +1,18 @@ -var bindings +var bindings; try { - bindings = require('../build/Release/weakref.node') + bindings = require('../build/Release/weakref.node'); } catch (e) { if (e.code === 'MODULE_NOT_FOUND') { - bindings = require('../build/Debug/weakref.node') + bindings = require('../build/Debug/weakref.node'); } else { - throw e + throw e; } } -module.exports = bindings.create +module.exports = bindings.create; // backwards-compat with node-weakref -bindings.weaken = bindings.create +bindings.weaken = bindings.create; -Object.keys(bindings).forEach(function (name) { - module.exports[name] = bindings[name] -}) +Object.keys(bindings).forEach(function(name) { + module.exports[name] = bindings[name]; +}); diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 4fbb4292987f..778aaef21f8a 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -5,17 +5,17 @@ function serverHandler(req, res) { res.connection.destroy(); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, +var http = require('http'), + weak = require('weak'), + done = 0, + count = 0, countGC = 0, - todo = 500, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; -console.log('We should do '+ todo +' requests'); +console.log('We should do ' + todo + ' requests'); var http = require('http'); var server = http.createServer(serverHandler); @@ -25,9 +25,9 @@ function getall() { if (count >= todo) return; - (function(){ + (function() { function cb(res) { - done+=1; + done += 1; statusLater(); } @@ -39,7 +39,7 @@ function getall() { count++; weak(req, afterGC); - })() + })(); setImmediate(getall); } @@ -47,8 +47,8 @@ function getall() { for (var i = 0; i < 10; i++) getall(); -function afterGC(){ - countGC ++; +function afterGC() { + countGC++; } var timer; diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 80a3fcf5b6cd..6396c1a17970 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -7,17 +7,17 @@ function serverHandler(req, res) { res.end('Hello World\n'); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, +var http = require('http'), + weak = require('weak'), + done = 0, + count = 0, countGC = 0, - todo = 500, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; -console.log('We should do '+ todo +' requests'); +console.log('We should do ' + todo + ' requests'); var http = require('http'); var server = http.createServer(serverHandler); @@ -27,10 +27,10 @@ function getall() { if (count >= todo) return; - (function(){ + (function() { function cb(res) { res.resume(); - done+=1; + done += 1; statusLater(); } function onerror(er) { @@ -45,7 +45,7 @@ function getall() { count++; weak(req, afterGC); - })() + })(); setImmediate(getall); } @@ -53,8 +53,8 @@ function getall() { for (var i = 0; i < 10; i++) getall(); -function afterGC(){ - countGC ++; +function afterGC() { + countGC++; } var timer; diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index 99a97d73b751..54a9faa84cb9 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -2,24 +2,24 @@ // but with a timeout set function serverHandler(req, res) { - setTimeout(function () { + setTimeout(function() { req.resume(); - res.writeHead(200) + res.writeHead(200); res.end('hello\n'); }, 100); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, +var http = require('http'), + weak = require('weak'), + done = 0, + count = 0, countGC = 0, - todo = 550, + todo = 550, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; -console.log('We should do '+ todo +' requests'); +console.log('We should do ' + todo + ' requests'); var http = require('http'); var server = http.createServer(serverHandler); @@ -29,10 +29,10 @@ function getall() { if (count >= todo) return; - (function(){ + (function() { function cb(res) { res.resume(); - done+=1; + done += 1; statusLater(); } @@ -42,22 +42,22 @@ function getall() { port: PORT }, cb); req.on('error', cb); - req.setTimeout(10, function(){ - console.log('timeout (expected)') + req.setTimeout(10, function() { + console.log('timeout (expected)'); }); count++; weak(req, afterGC); - })() + })(); setImmediate(getall); } -for(var i = 0; i < 10; i++) +for (var i = 0; i < 10; i++) getall(); -function afterGC(){ - countGC ++; +function afterGC() { + countGC++; } var timer; diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 4c64bbadbb95..8aa09945b936 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -5,17 +5,17 @@ function serverHandler(req, res) { res.end('Hello World\n'); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, +var http = require('http'), + weak = require('weak'), + done = 0, + count = 0, countGC = 0, - todo = 500, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; -console.log('We should do '+ todo +' requests'); +console.log('We should do ' + todo + ' requests'); var http = require('http'); var server = http.createServer(serverHandler); @@ -26,11 +26,11 @@ function getall() { if (count >= todo) return; - (function(){ + (function() { function cb(res) { res.resume(); - console.error('in cb') - done+=1; + console.error('in cb'); + done += 1; res.on('end', gc); } @@ -38,11 +38,11 @@ function getall() { hostname: 'localhost', pathname: '/', port: PORT - }, cb) + }, cb); count++; weak(req, afterGC); - })() + })(); setImmediate(getall); } @@ -50,8 +50,8 @@ function getall() { for (var i = 0; i < 10; i++) getall(); -function afterGC(){ - countGC ++; +function afterGC() { + countGC++; } setInterval(status, 1000).unref(); diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 5d2387dc748b..7dc476ed2201 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -11,22 +11,22 @@ function serverHandler(sock) { sock.on('error', function(err) { assert.strictEqual(err.code, 'ECONNRESET'); }); - timer = setTimeout(function () { + timer = setTimeout(function() { sock.end('hello\n'); }, 100); } -var net = require('net'), - weak = require('weak'), - done = 0, - count = 0, +var net = require('net'), + weak = require('weak'), + done = 0, + count = 0, countGC = 0, - todo = 500, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; -console.log('We should do '+ todo +' requests'); +console.log('We should do ' + todo + ' requests'); var server = net.createServer(serverHandler); server.listen(PORT, getall); @@ -35,7 +35,7 @@ function getall() { if (count >= todo) return; - (function(){ + (function() { var req = net.connect(PORT, '127.0.0.1'); req.resume(); req.setTimeout(10, function() { @@ -55,8 +55,8 @@ function getall() { for (var i = 0; i < 10; i++) getall(); -function afterGC(){ - countGC ++; +function afterGC() { + countGC++; } setInterval(status, 100).unref(); diff --git a/test/internet/test-dgram-multicast-multi-process.js b/test/internet/test-dgram-multicast-multi-process.js index 267a801064b1..fc99f847e291 100644 --- a/test/internet/test-dgram-multicast-multi-process.js +++ b/test/internet/test-dgram-multicast-multi-process.js @@ -150,7 +150,7 @@ if (process.argv[2] !== 'child') { sendSocket.bind(); // The socket is actually created async now - sendSocket.on('listening', function () { + sendSocket.on('listening', function() { sendSocket.setTTL(1); sendSocket.setBroadcast(true); sendSocket.setMulticastTTL(1); @@ -227,7 +227,7 @@ if (process.argv[2] === 'child') { listenSocket.bind(common.PORT); - listenSocket.on('listening', function () { + listenSocket.on('listening', function() { listenSocket.addMembership(LOCAL_BROADCAST_HOST); }); } diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index 623a845c03f3..f3448d002927 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -247,34 +247,34 @@ TEST(function test_resolveNaptr(done) { TEST(function test_resolveSoa(done) { var req = dns.resolveSoa('nodejs.org', function(err, result) { if (err) throw err; - + assert.ok(result); assert.ok(typeof result === 'object'); - + assert.ok(typeof result.nsname === 'string'); assert.ok(result.nsname.length > 0); - + assert.ok(typeof result.hostmaster === 'string'); assert.ok(result.hostmaster.length > 0); - + assert.ok(typeof result.serial === 'number'); assert.ok((result.serial > 0) && (result.serial < 4294967295)); - + assert.ok(typeof result.refresh === 'number'); - assert.ok((result.refresh > 0) && (result.refresh < 2147483647)); - + assert.ok((result.refresh > 0) && (result.refresh < 2147483647)); + assert.ok(typeof result.retry === 'number'); assert.ok((result.retry > 0) && (result.retry < 2147483647)); - + assert.ok(typeof result.expire === 'number'); assert.ok((result.expire > 0) && (result.expire < 2147483647)); - + assert.ok(typeof result.minttl === 'number'); assert.ok((result.minttl >= 0) && (result.minttl < 2147483647)); done(); }); - + checkWrap(req); }); @@ -595,7 +595,7 @@ TEST(function test_resolve_failure(done) { var req = dns.resolve4('nosuchhostimsure', function(err) { assert(err instanceof Error); - switch(err.code) { + switch (err.code) { case 'ENOTFOUND': case 'ESERVFAIL': break; diff --git a/test/internet/test-net-connect-unref.js b/test/internet/test-net-connect-unref.js index 29f43b10e4a6..587cdf2281f0 100644 --- a/test/internet/test-net-connect-unref.js +++ b/test/internet/test-net-connect-unref.js @@ -24,7 +24,7 @@ var assert = require('assert'); var net = require('net'); var client, killed = false, ended = false; -var TIMEOUT = 10 * 1000 +var TIMEOUT = 10 * 1000; client = net.createConnection(53, '8.8.8.8', function() { client.unref(); diff --git a/test/message/eval_messages.js b/test/message/eval_messages.js index d03c0eb1b1d7..c9bde31f30c6 100644 --- a/test/message/eval_messages.js +++ b/test/message/eval_messages.js @@ -36,11 +36,11 @@ function run(cmd, strict, cb) { } var queue = - [ 'with(this){__filename}', - '42', - 'throw new Error("hello")', - 'var x = 100; y = x;', - 'var ______________________________________________; throw 10' ]; + ['with(this){__filename}', + '42', + 'throw new Error("hello")', + 'var x = 100; y = x;', + 'var ______________________________________________; throw 10']; function go() { var c = queue.shift(); diff --git a/test/message/stdin_messages.js b/test/message/stdin_messages.js index b1eaf4707b21..82fb3d636e06 100644 --- a/test/message/stdin_messages.js +++ b/test/message/stdin_messages.js @@ -37,11 +37,11 @@ function run(cmd, strict, cb) { } var queue = - [ 'with(this){__filename}', - '42', - 'throw new Error("hello")', - 'var x = 100; y = x;', - 'var ______________________________________________; throw 10' ]; + ['with(this){__filename}', + '42', + 'throw new Error("hello")', + 'var x = 100; y = x;', + 'var ______________________________________________; throw 10']; function go() { var c = queue.shift(); diff --git a/test/message/vm_dont_display_runtime_error.js b/test/message/vm_dont_display_runtime_error.js index d77b19dbe06c..889b6fa53f8b 100644 --- a/test/message/vm_dont_display_runtime_error.js +++ b/test/message/vm_dont_display_runtime_error.js @@ -26,17 +26,17 @@ var vm = require('vm'); console.error('beginning'); try { - vm.runInThisContext('throw new Error("boo!")', { - filename: 'test.vm', - displayErrors: false - }); + vm.runInThisContext('throw new Error("boo!")', { + filename: 'test.vm', + displayErrors: false + }); } catch (e) {} console.error('middle'); vm.runInThisContext('throw new Error("boo!")', { - filename: 'test.vm', - displayErrors: false + filename: 'test.vm', + displayErrors: false }); console.error('end'); diff --git a/test/message/vm_dont_display_syntax_error.js b/test/message/vm_dont_display_syntax_error.js index f2ef19c57d1b..50f1d2174a1e 100644 --- a/test/message/vm_dont_display_syntax_error.js +++ b/test/message/vm_dont_display_syntax_error.js @@ -26,17 +26,17 @@ var vm = require('vm'); console.error('beginning'); try { - vm.runInThisContext('var 5;', { - filename: 'test.vm', - displayErrors: false - }); + vm.runInThisContext('var 5;', { + filename: 'test.vm', + displayErrors: false + }); } catch (e) {} console.error('middle'); vm.runInThisContext('var 5;', { - filename: 'test.vm', - displayErrors: false + filename: 'test.vm', + displayErrors: false }); console.error('end'); diff --git a/test/pummel/test-crypto-dh.js b/test/pummel/test-crypto-dh.js index e4e883f69964..ece66580d183 100644 --- a/test/pummel/test-crypto-dh.js +++ b/test/pummel/test-crypto-dh.js @@ -40,21 +40,22 @@ assert.throws(function() { }); var hashes = { - modp1 : "b4b330a6ffeacfbd861e7fe2135b4431", - modp2 : "7c3c5cad8b9f378d88f1dd64a4b6413a", - modp5 : "b1d2acc22c542e08669a5c5ae812694d", - modp14 : "8d041538cecc1a7d915ba4b718f8ad20", - modp15 : "dc3b93def24e078c4fbf92d5e14ba69b", - modp16 : "a273487f46f699461f613b3878d9dfd9", - modp17 : "dc76e09935310348c492de9bd82014d0", - modp18 : "db08973bfd2371758a69db180871c993" -} + modp1: 'b4b330a6ffeacfbd861e7fe2135b4431', + modp2: '7c3c5cad8b9f378d88f1dd64a4b6413a', + modp5: 'b1d2acc22c542e08669a5c5ae812694d', + modp14: '8d041538cecc1a7d915ba4b718f8ad20', + modp15: 'dc3b93def24e078c4fbf92d5e14ba69b', + modp16: 'a273487f46f699461f613b3878d9dfd9', + modp17: 'dc76e09935310348c492de9bd82014d0', + modp18: 'db08973bfd2371758a69db180871c993' +}; for (var name in hashes) { var group = crypto.getDiffieHellman(name); var private_key = group.getPrime('hex'); var hash1 = hashes[name]; - var hash2 = crypto.createHash('md5').update(private_key.toUpperCase()).digest('hex'); + var hash2 = crypto.createHash('md5'). + update(private_key.toUpperCase()).digest('hex'); assert.equal(hash1, hash2); assert.equal(group.getGenerator('hex'), '02'); } diff --git a/test/pummel/test-dh-regr.js b/test/pummel/test-dh-regr.js index 2910dedc26e0..17dde8c533fd 100644 --- a/test/pummel/test-dh-regr.js +++ b/test/pummel/test-dh-regr.js @@ -34,8 +34,8 @@ for (var i = 0; i < 2000; i++) { b.generateKeys(); assert.deepEqual( - a.computeSecret(b.getPublicKey()), - b.computeSecret(a.getPublicKey()), - 'secrets should be equal!' + a.computeSecret(b.getPublicKey()), + b.computeSecret(a.getPublicKey()), + 'secrets should be equal!' ); } diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js index 6779a766a70c..2f89c9b744b5 100644 --- a/test/pummel/test-dtrace-jsstack.js +++ b/test/pummel/test-dtrace-jsstack.js @@ -32,21 +32,21 @@ if (os.type() != 'SunOS') { /* * Some functions to create a recognizable stack. */ -var frames = [ 'stalloogle', 'bagnoogle', 'doogle' ]; +var frames = ['stalloogle', 'bagnoogle', 'doogle']; var expected; -var stalloogle = function (str) { +var stalloogle = function(str) { expected = str; os.loadavg(); }; -var bagnoogle = function (arg0, arg1) { +var bagnoogle = function(arg0, arg1) { stalloogle(arg0 + ' is ' + arg1 + ' except that it is read-only'); }; var done = false; -var doogle = function () { +var doogle = function() { if (!done) setTimeout(doogle, 10); @@ -62,20 +62,20 @@ var corefile = prefix + '.' + process.pid; * when we call getloadavg() -- with the implicit assumption that our * deepest function is the only caller of os.loadavg(). */ -var dtrace = spawn('dtrace', [ '-qwn', 'syscall::getloadavg:entry/pid == ' + - process.pid + '/{ustack(100, 8192); exit(0); }' ]); +var dtrace = spawn('dtrace', ['-qwn', 'syscall::getloadavg:entry/pid == ' + + process.pid + '/{ustack(100, 8192); exit(0); }']); var output = ''; -dtrace.stderr.on('data', function (data) { +dtrace.stderr.on('data', function(data) { console.log('dtrace: ' + data); }); -dtrace.stdout.on('data', function (data) { +dtrace.stdout.on('data', function(data) { output += data; }); -dtrace.on('exit', function (code) { +dtrace.on('exit', function(code) { if (code != 0) { console.error('dtrace exited with code ' + code); process.exit(code); @@ -96,7 +96,7 @@ dtrace.on('exit', function (code) { var top = frames.shift(); assert.equal(frame.indexOf(top), 0, 'unexpected frame where ' + - top + ' was expected'); + top + ' was expected'); } assert.equal(frames.length, 0, 'did not find expected frame ' + frames[0]); diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 6eacda783c5c..4675f6cf6530 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -25,11 +25,11 @@ var exec = require('child_process').exec; if (process.platform !== 'win32') { // Unix. - var SLEEP3_COMMAND = "sleep 3"; + var SLEEP3_COMMAND = 'sleep 3'; } else { // Windows: `choice` is a command built into cmd.exe. Use another cmd process // to create a process tree, so we can catch bugs related to it. - var SLEEP3_COMMAND = "cmd /c choice /t 3 /c X /d X"; + var SLEEP3_COMMAND = 'cmd /c choice /t 3 /c X /d X'; } @@ -39,17 +39,17 @@ var error_count = 0; exec(process.execPath + ' -p -e process.versions', function(err, stdout, stderr) { - if (err) { - error_count++; - console.log('error!: ' + err.code); - console.log('stdout: ' + JSON.stringify(stdout)); - console.log('stderr: ' + JSON.stringify(stderr)); - assert.equal(false, err.killed); - } else { - success_count++; - console.dir(stdout); - } -}); + if (err) { + error_count++; + console.log('error!: ' + err.code); + console.log('stdout: ' + JSON.stringify(stdout)); + console.log('stderr: ' + JSON.stringify(stderr)); + assert.equal(false, err.killed); + } else { + success_count++; + console.dir(stdout); + } + }); exec('thisisnotavalidcommand', function(err, stdout, stderr) { diff --git a/test/pummel/test-fs-readfile-large.js b/test/pummel/test-fs-readfile-large.js index 6021aac8952f..196237a12d2e 100644 --- a/test/pummel/test-fs-readfile-large.js +++ b/test/pummel/test-fs-readfile-large.js @@ -23,8 +23,8 @@ var common = require('../common'); var assert = require('assert'); var path = require('path'), - fs = require('fs'), - filename = path.join(common.fixturesDir, 'large_file.txt'); + fs = require('fs'), + filename = path.join(common.fixturesDir, 'large_file.txt'); var filesize = 1024 * 1024 * 1024; @@ -47,7 +47,7 @@ function makeFile(done) { } } -makeFile(function () { +makeFile(function() { fs.readFile(filename, function(err) { assert.ok(err, 'should get RangeError'); assert.equal(err.name, 'RangeError', 'should get RangeError'); @@ -55,6 +55,6 @@ makeFile(function () { }); }); -process.on('uncaughtException', function (err) { +process.on('uncaughtException', function(err) { assert.ok(!err, 'should not throw uncaughtException'); }); diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index 2e4bc1001682..7d9ee208baf2 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -36,22 +36,22 @@ catch (e) { // swallow } -fs.watchFile(FILENAME, {interval:TIMEOUT - 250}, function(curr, prev) { +fs.watchFile(FILENAME, {interval: TIMEOUT - 250}, function(curr, prev) { console.log([curr, prev]); switch (++nevents) { - case 1: - assert.equal(fs.existsSync(FILENAME), false); - break; - case 2: - case 3: - assert.equal(fs.existsSync(FILENAME), true); - break; - case 4: - assert.equal(fs.existsSync(FILENAME), false); - fs.unwatchFile(FILENAME); - break; - default: - assert(0); + case 1: + assert.equal(fs.existsSync(FILENAME), false); + break; + case 2: + case 3: + assert.equal(fs.existsSync(FILENAME), true); + break; + case 4: + assert.equal(fs.existsSync(FILENAME), false); + fs.unwatchFile(FILENAME); + break; + default: + assert(0); } }); @@ -63,13 +63,13 @@ setTimeout(createFile, TIMEOUT); function createFile() { console.log('creating file'); - fs.writeFileSync(FILENAME, "test"); + fs.writeFileSync(FILENAME, 'test'); setTimeout(touchFile, TIMEOUT); } function touchFile() { console.log('touch file'); - fs.writeFileSync(FILENAME, "test"); + fs.writeFileSync(FILENAME, 'test'); setTimeout(removeFile, TIMEOUT); } diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js index 3e8a17a4b8b2..410551b0d194 100644 --- a/test/pummel/test-fs-watch-file.js +++ b/test/pummel/test-fs-watch-file.js @@ -144,7 +144,7 @@ assert.doesNotThrow( function a(curr, prev) { ++watchSeenFour; assert.equal(1, watchSeenFour); - fs.unwatchFile("." + path.sep + filenameFour, a); + fs.unwatchFile('.' + path.sep + filenameFour, a); } fs.watchFile(filenameFour, a); } diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 8611f4dbec6c..c03befd37302 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -51,7 +51,7 @@ function runAb(opts, callback) { var args = [ '-c', opts.concurrent || 100, '-t', opts.threads || 2, - '-d', opts.duration || '10s', + '-d', opts.duration || '10s' ]; if (!opts.keepalive) { @@ -59,7 +59,8 @@ function runAb(opts, callback) { args.push('Connection: close'); } - args.push(url.format({ hostname: '127.0.0.1', port: common.PORT, protocol: 'http'})); + args.push(url.format({ hostname: '127.0.0.1', port: common.PORT, protocol: + 'http'})); var comm = path.join(__dirname, '..', '..', 'tools', 'wrk', 'wrk'); diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index 228b55181831..f8760738f594 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -44,7 +44,8 @@ var server = net.createServer(function(connection) { connection.write(body.slice(part_N, 2 * part_N)); assert.equal(false, connection.write(body.slice(2 * part_N, N))); console.log('bufferSize: ' + connection.bufferSize, 'expecting', N); - assert.ok(0 <= connection.bufferSize && connection._writableState.length <= N); + assert.ok(0 <= connection.bufferSize && + connection._writableState.length <= N); connection.end(); }); diff --git a/test/pummel/test-postmortem-details.js b/test/pummel/test-postmortem-details.js index 912dc8f078ec..ec0ee751866a 100644 --- a/test/pummel/test-postmortem-details.js +++ b/test/pummel/test-postmortem-details.js @@ -36,7 +36,7 @@ if (os.type() != 'SunOS') { */ function myTestFunction() { - [ 1 ].forEach(function myIterFunction(t) {}); + [1].forEach(function myIterFunction(t) {}); return (new Buffer(bufstr)); } @@ -62,20 +62,20 @@ var spawn = require('child_process').spawn; var prefix = '/var/tmp/node'; var corefile = prefix + '.' + process.pid; var tmpfile = '/var/tmp/node-postmortem-func' + '.' + process.pid; -var gcore = spawn('gcore', [ '-o', prefix, process.pid + '' ]); +var gcore = spawn('gcore', ['-o', prefix, process.pid + '']); var output = ''; var unlinkSync = require('fs').unlinkSync; -var args = [ corefile ]; +var args = [corefile]; var mybuffer; if (process.env.MDB_LIBRARY_PATH && process.env.MDB_LIBRARY_PATH != '') - args = args.concat([ '-L', process.env.MDB_LIBRARY_PATH ]); + args = args.concat(['-L', process.env.MDB_LIBRARY_PATH]); -gcore.stderr.on('data', function (data) { +gcore.stderr.on('data', function(data) { console.log('gcore: ' + data); }); -gcore.on('exit', function (code) { +gcore.on('exit', function(code) { if (code != 0) { console.error('gcore exited with code ' + code); process.exit(code); @@ -83,7 +83,7 @@ gcore.on('exit', function (code) { var mdb = spawn('mdb', args, { stdio: 'pipe' }); - mdb.on('exit', function (code) { + mdb.on('exit', function(code) { unlinkSync(tmpfile); var retained = '; core retained as ' + corefile; @@ -122,18 +122,18 @@ gcore.on('exit', function (code) { process.exit(0); }); - mdb.stdout.on('data', function (data) { + mdb.stdout.on('data', function(data) { output += data; }); - mdb.stderr.on('data', function (data) { + mdb.stderr.on('data', function(data) { console.log('mdb stderr: ' + data); }); var verifiers = []; var buffer; verifiers.push(function verifyConstructor(testlines) { - assert.deepEqual(testlines, [ 'Buffer' ]); + assert.deepEqual(testlines, ['Buffer']); }); verifiers.push(function verifyNodebuffer(testlines) { assert.equal(testlines.length, 1); @@ -145,7 +145,7 @@ gcore.on('exit', function (code) { assert.equal(testlines[0], '0x' + buffer + ': Hello'); }); verifiers.push(function verifyV8internal(testlines) { - assert.deepEqual(testlines, [ buffer ]); + assert.deepEqual(testlines, [buffer]); }); verifiers.push(function verifyJsfunctionN(testlines) { assert.equal(testlines.length, 2); @@ -157,7 +157,7 @@ gcore.on('exit', function (code) { verifiers.push(function verifyJsfunctionS(testlines) { var foundtest = false, founditer = false; assert.ok(testlines.length > 1); - testlines.forEach(function (line) { + testlines.forEach(function(line) { var parts = line.trim().split(/\s+/); if (parts[2] == 'myIterFunction') { assert.equal(parts[1], '3'); @@ -176,7 +176,7 @@ gcore.on('exit', function (code) { assert.ok(content.indexOf('function myTestFunction()\n') != -1); assert.ok(content.indexOf('return (new Buffer(bufstr));\n') != -1); }); - OBJECT_KINDS.forEach(function (kind) { + OBJECT_KINDS.forEach(function(kind) { verifiers.push(function verifyFindObjectsKind(testLines) { // There should be at least one object for // every kind of objects (except for the special cases @@ -205,7 +205,8 @@ gcore.on('exit', function (code) { mdb.stdin.write(mod); mdb.stdin.write('!echo test: jsconstructor\n'); mdb.stdin.write('::findjsobjects -p my_buffer | ::findjsobjects | ' + - '::jsprint -b length ! awk -F: \'$2 == ' + bufstr.length + '{ print $1 }\'' + + '::jsprint -b length ! awk -F: \'$2 ==' + + bufstr.length + '{ print $1 }\'' + '| head -1 > ' + tmpfile + '\n'); mdb.stdin.write('::cat ' + tmpfile + ' | ::jsconstructor\n'); mdb.stdin.write('!echo test: nodebuffer\n'); @@ -214,7 +215,8 @@ gcore.on('exit', function (code) { mdb.stdin.write('::cat ' + tmpfile + ' | ::nodebuffer | ::eval "./ccccc"\n'); mdb.stdin.write('!echo test: v8internal\n'); - mdb.stdin.write('::cat ' + tmpfile + ' | ::v8print ! awk \'$2 == "elements"{' + + mdb.stdin.write('::cat ' + tmpfile + + ' | ::v8print ! awk \'$2 == "elements"{' + 'print $4 }\' > ' + tmpfile + '\n'); mdb.stdin.write('::cat ' + tmpfile + ' | ::v8internal 0\n'); @@ -226,7 +228,7 @@ gcore.on('exit', function (code) { mdb.stdin.write('::jsfunctions -n myTestFunction ! ' + 'awk \'NR == 2 {print $1}\' | head -1 > ' + tmpfile + '\n'); mdb.stdin.write('::cat ' + tmpfile + ' | ::jssource -n 0\n'); - OBJECT_KINDS.forEach(function (kind) { + OBJECT_KINDS.forEach(function(kind) { mdb.stdin.write(util.format('!echo test: findjsobjects -k %s\n', kind)); mdb.stdin.write(util.format('::findjsobjects -k %s\n', kind)); }); diff --git a/test/pummel/test-postmortem-findjsobjects.js b/test/pummel/test-postmortem-findjsobjects.js index 8dc04dab7985..ec9e7ce77838 100644 --- a/test/pummel/test-postmortem-findjsobjects.js +++ b/test/pummel/test-postmortem-findjsobjects.js @@ -39,19 +39,19 @@ var obj = new LanguageH(1); var spawn = require('child_process').spawn; var prefix = '/var/tmp/node'; var corefile = prefix + '.' + process.pid; -var gcore = spawn('gcore', [ '-o', prefix, process.pid + '' ]); +var gcore = spawn('gcore', ['-o', prefix, process.pid + '']); var output = ''; var unlinkSync = require('fs').unlinkSync; -var args = [ corefile ]; +var args = [corefile]; if (process.env.MDB_LIBRARY_PATH && process.env.MDB_LIBRARY_PATH != '') - args = args.concat([ '-L', process.env.MDB_LIBRARY_PATH ]); + args = args.concat(['-L', process.env.MDB_LIBRARY_PATH]); -gcore.stderr.on('data', function (data) { +gcore.stderr.on('data', function(data) { console.log('gcore: ' + data); }); -gcore.on('exit', function (code) { +gcore.on('exit', function(code) { if (code != 0) { console.error('gcore exited with code ' + code); process.exit(code); @@ -59,7 +59,7 @@ gcore.on('exit', function (code) { var mdb = spawn('mdb', args, { stdio: 'pipe' }); - mdb.on('exit', function (code) { + mdb.on('exit', function(code) { var retained = '; core retained as ' + corefile; if (code != 0) { @@ -76,17 +76,17 @@ gcore.on('exit', function (code) { } assert.equal(found, nexpected, 'expected ' + nexpected + - ' objects, found ' + found + retained); + ' objects, found ' + found + retained); unlinkSync(corefile); process.exit(0); }); - mdb.stdout.on('data', function (data) { + mdb.stdout.on('data', function(data) { output += data; }); - mdb.stderr.on('data', function (data) { + mdb.stderr.on('data', function(data) { console.log('mdb stderr: ' + data); }); diff --git a/test/pummel/test-postmortem-jsstack.js b/test/pummel/test-postmortem-jsstack.js index 95af899e0853..1ff9c7abd70d 100644 --- a/test/pummel/test-postmortem-jsstack.js +++ b/test/pummel/test-postmortem-jsstack.js @@ -33,21 +33,21 @@ if (os.type() != 'SunOS') { /* * Some functions to create a recognizable stack. */ -var frames = [ 'stalloogle', 'bagnoogle', 'doogle' ]; +var frames = ['stalloogle', 'bagnoogle', 'doogle']; var expected; -var stalloogle = function (str) { +var stalloogle = function(str) { expected = str; os.loadavg(); }; -var bagnoogle = function (arg0, arg1) { +var bagnoogle = function(arg0, arg1) { stalloogle(arg0 + ' is ' + arg1 + ' except that it is read-only'); }; var done = false; -var doogle = function () { +var doogle = function() { if (!done) setTimeout(doogle, 10); @@ -57,28 +57,28 @@ var doogle = function () { var spawn = require('child_process').spawn; var prefix = '/var/tmp/node'; var corefile = prefix + '.' + process.pid; -var args = [ corefile ]; +var args = [corefile]; if (process.env.MDB_LIBRARY_PATH && process.env.MDB_LIBRARY_PATH != '') - args = args.concat([ '-L', process.env.MDB_LIBRARY_PATH ]); + args = args.concat(['-L', process.env.MDB_LIBRARY_PATH]); /* * We're going to use DTrace to stop us, gcore us, and set us running again * when we call getloadavg() -- with the implicit assumption that our * deepest function is the only caller of os.loadavg(). */ -var dtrace = spawn('dtrace', [ '-qwn', 'syscall::getloadavg:entry/pid == ' + - process.pid + '/{stop(); system("gcore -o ' + - prefix + ' %d", pid); system("prun %d", pid); exit(0); }' ]); +var dtrace = spawn('dtrace', ['-qwn', 'syscall::getloadavg:entry/pid == ' + + process.pid + '/{stop(); system("gcore -o ' + + prefix + ' %d", pid); system("prun %d", pid); exit(0); }']); var output = ''; var unlinkSync = require('fs').unlinkSync; -dtrace.stderr.on('data', function (data) { +dtrace.stderr.on('data', function(data) { console.log('dtrace: ' + data); }); -dtrace.on('exit', function (code) { +dtrace.on('exit', function(code) { if (code != 0) { console.error('dtrace exited with code ' + code); process.exit(code); @@ -99,7 +99,7 @@ dtrace.on('exit', function (code) { 'Release', 'mdb_v8.so')); - mdb.on('exit', function (code) { + mdb.on('exit', function(code) { var retained = '; core retained as ' + corefile; if (code != 0) { @@ -127,16 +127,16 @@ dtrace.on('exit', function (code) { var top = frames.shift(); assert.equal(frame.indexOf(top), 0, 'unexpected frame where ' + - top + ' was expected' + retained); + top + ' was expected' + retained); matched++; } assert.equal(frames.length, 0, 'did not find expected frame ' + - frames[0] + retained); + frames[0] + retained); assert.notEqual(straddr, undefined, - 'did not find arg1 for top frame' + retained); + 'did not find arg1 for top frame' + retained); /* * Now we're going to take one more swing at the core file to print out @@ -145,24 +145,24 @@ dtrace.on('exit', function (code) { output = ''; mdb = spawn('mdb', args, { stdio: 'pipe' }); - mdb.on('exit', function (code) { + mdb.on('exit', function(code) { if (code != 0) { console.error('mdb (second) exited with code ' + code + retained); process.exit(code); } assert.notEqual(output.indexOf(expected), -1, 'did not find arg1 (' + - straddr + ') to contain expected string' + retained); + straddr + ') to contain expected string' + retained); unlinkSync(corefile); process.exit(0); }); - mdb.stdout.on('data', function (data) { + mdb.stdout.on('data', function(data) { output += data; }); - mdb.stderr.on('data', function (data) { + mdb.stderr.on('data', function(data) { console.log('mdb (second) stderr: ' + data); }); @@ -171,11 +171,11 @@ dtrace.on('exit', function (code) { mdb.stdin.end(); }); - mdb.stdout.on('data', function (data) { + mdb.stdout.on('data', function(data) { output += data; }); - mdb.stderr.on('data', function (data) { + mdb.stderr.on('data', function(data) { console.log('mdb stderr: ' + data); }); diff --git a/test/pummel/test-regress-GH-892.js b/test/pummel/test-regress-GH-892.js index 0c4118494633..8efc05efb3e0 100644 --- a/test/pummel/test-regress-GH-892.js +++ b/test/pummel/test-regress-GH-892.js @@ -54,9 +54,9 @@ function makeRequest() { // process.execArgv to track down nextTick recursion errors // more easily. Also, this is handy when using this test to // view V8 opt/deopt behavior. - var args = process.execArgv.concat([ childScript, - common.PORT, - bytesExpected ]); + var args = process.execArgv.concat([childScript, + common.PORT, + bytesExpected]); var child = spawn(process.execPath, args); diff --git a/test/pummel/test-smalloc-alloc-segfault.js b/test/pummel/test-smalloc-alloc-segfault.js index 6d484857fa89..61167ff43fe9 100644 --- a/test/pummel/test-smalloc-alloc-segfault.js +++ b/test/pummel/test-smalloc-alloc-segfault.js @@ -47,7 +47,7 @@ if (process.argv[2] === 'child') { } else { // test case var child = spawn(process.execPath, - ['--expose_gc', __filename, 'child']); + ['--expose_gc', __filename, 'child']); child.on('exit', function(code, signal) { assert.equal(code, 0, signal); diff --git a/test/pummel/test-smalloc-dispose-segfault.js b/test/pummel/test-smalloc-dispose-segfault.js index 22c8587535d6..4536bf6d0297 100644 --- a/test/pummel/test-smalloc-dispose-segfault.js +++ b/test/pummel/test-smalloc-dispose-segfault.js @@ -41,7 +41,7 @@ if (process.argv[2] === 'child') { } else { // test case var child = spawn(process.execPath, - ['--expose_gc', __filename, 'child']); + ['--expose_gc', __filename, 'child']); child.on('exit', function(code, signal) { assert.equal(code, 0, signal); diff --git a/test/pummel/test-smalloc-sliceonto-segfault.js b/test/pummel/test-smalloc-sliceonto-segfault.js index 62a438c6e3a3..6a945a06e6fd 100644 --- a/test/pummel/test-smalloc-sliceonto-segfault.js +++ b/test/pummel/test-smalloc-sliceonto-segfault.js @@ -50,7 +50,7 @@ if (process.argv[2] === 'child') { } else { // test case var child = spawn(process.execPath, - ['--expose_gc', __filename, 'child']); + ['--expose_gc', __filename, 'child']); child.on('exit', function(code, signal) { assert.equal(code, 0, signal); diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js index f210c9f0309c..99d3053f9fb0 100644 --- a/test/pummel/test-stream2-basic.js +++ b/test/pummel/test-stream2-basic.js @@ -110,7 +110,7 @@ function run() { same: assert.deepEqual, ok: assert, equal: assert.equal, - end: function () { + end: function() { count--; run(); } @@ -118,7 +118,7 @@ function run() { } // ensure all tests have run -process.on("exit", function () { +process.on('exit', function() { assert.equal(count, 0); }); @@ -129,22 +129,22 @@ test('a most basic test', function(t) { var r = new TestReader(20); var reads = []; - var expect = [ 'x', - 'xx', - 'xxx', - 'xxxx', - 'xxxxx', - 'xxxxxxxxx', - 'xxxxxxxxxx', - 'xxxxxxxxxxxx', - 'xxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxx' ]; + var expect = ['x', + 'xx', + 'xxx', + 'xxxx', + 'xxxxx', + 'xxxxxxxxx', + 'xxxxxxxxxx', + 'xxxxxxxxxxxx', + 'xxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxx']; r.on('end', function() { t.same(reads, expect); @@ -166,16 +166,16 @@ test('a most basic test', function(t) { test('pipe', function(t) { var r = new TestReader(5); - var expect = [ 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx' ] + var expect = ['xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx']; var w = new TestWriter; var flush = true; @@ -190,24 +190,24 @@ test('pipe', function(t) { -[1,2,3,4,5,6,7,8,9].forEach(function(SPLIT) { +[1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(function(SPLIT) { test('unpipe', function(t) { var r = new TestReader(5); // unpipe after 3 writes, then write to another stream instead. - var expect = [ 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx' ]; - expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ]; - - var w = [ new TestWriter(), new TestWriter() ]; + var expect = ['xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx']; + expect = [expect.slice(0, SPLIT), expect.slice(SPLIT)]; + + var w = [new TestWriter(), new TestWriter()]; var writes = SPLIT; w[0].on('write', function() { @@ -248,18 +248,18 @@ test('pipe', function(t) { // both writers should get the same exact data. test('multipipe', function(t) { var r = new TestReader(5); - var w = [ new TestWriter, new TestWriter ]; - - var expect = [ 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx' ]; + var w = [new TestWriter, new TestWriter]; + + var expect = ['xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx']; var c = 2; w[0].on('end', function(received) { @@ -276,24 +276,24 @@ test('multipipe', function(t) { }); -[1,2,3,4,5,6,7,8,9].forEach(function(SPLIT) { +[1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(function(SPLIT) { test('multi-unpipe', function(t) { var r = new TestReader(5); // unpipe after 3 writes, then write to another stream instead. - var expect = [ 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx' ]; - expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ]; - - var w = [ new TestWriter(), new TestWriter(), new TestWriter() ]; + var expect = ['xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx']; + expect = [expect.slice(0, SPLIT), expect.slice(SPLIT)]; + + var w = [new TestWriter(), new TestWriter(), new TestWriter()]; var writes = SPLIT; w[0].on('write', function() { @@ -323,50 +323,50 @@ test('multipipe', function(t) { }); }); -test('back pressure respected', function (t) { +test('back pressure respected', function(t) { function noop() {} var r = new R({ objectMode: true }); r._read = noop; var counter = 0; - r.push(["one"]); - r.push(["two"]); - r.push(["three"]); - r.push(["four"]); + r.push(['one']); + r.push(['two']); + r.push(['three']); + r.push(['four']); r.push(null); var w1 = new R(); - w1.write = function (chunk) { + w1.write = function(chunk) { console.error('w1.emit("close")'); - assert.equal(chunk[0], "one"); - w1.emit("close"); - process.nextTick(function () { + assert.equal(chunk[0], 'one'); + w1.emit('close'); + process.nextTick(function() { r.pipe(w2); r.pipe(w3); - }) + }); }; w1.end = noop; r.pipe(w1); - var expected = ["two", "two", "three", "three", "four", "four"]; + var expected = ['two', 'two', 'three', 'three', 'four', 'four']; var w2 = new R(); - w2.write = function (chunk) { + w2.write = function(chunk) { console.error('w2 write', chunk, counter); assert.equal(chunk[0], expected.shift()); assert.equal(counter, 0); counter++; - if (chunk[0] === "four") { + if (chunk[0] === 'four') { return true; } - setTimeout(function () { + setTimeout(function() { counter--; - console.error("w2 drain"); - w2.emit("drain"); + console.error('w2 drain'); + w2.emit('drain'); }, 10); return false; @@ -374,39 +374,39 @@ test('back pressure respected', function (t) { w2.end = noop; var w3 = new R(); - w3.write = function (chunk) { + w3.write = function(chunk) { console.error('w3 write', chunk, counter); assert.equal(chunk[0], expected.shift()); assert.equal(counter, 1); counter++; - if (chunk[0] === "four") { + if (chunk[0] === 'four') { return true; } - setTimeout(function () { + setTimeout(function() { counter--; - console.error("w3 drain"); - w3.emit("drain"); + console.error('w3 drain'); + w3.emit('drain'); }, 50); return false; }; - w3.end = function () { + w3.end = function() { assert.equal(counter, 2); assert.equal(expected.length, 0); t.end(); }; }); -test('read(0) for ended streams', function (t) { +test('read(0) for ended streams', function(t) { var r = new R(); var written = false; var ended = false; - r._read = function (n) {}; + r._read = function(n) {}; - r.push(new Buffer("foo")); + r.push(new Buffer('foo')); r.push(null); var v = r.read(0); @@ -415,38 +415,38 @@ test('read(0) for ended streams', function (t) { var w = new R(); - w.write = function (buffer) { + w.write = function(buffer) { written = true; assert.equal(ended, false); - assert.equal(buffer.toString(), "foo") + assert.equal(buffer.toString(), 'foo'); }; - w.end = function () { + w.end = function() { ended = true; assert.equal(written, true); t.end(); }; r.pipe(w); -}) +}); -test('sync _read ending', function (t) { +test('sync _read ending', function(t) { var r = new R(); var called = false; - r._read = function (n) { + r._read = function(n) { r.push(null); }; - r.once('end', function () { + r.once('end', function() { called = true; - }) + }); r.read(); - process.nextTick(function () { + process.nextTick(function() { assert.equal(called, true); t.end(); - }) + }); }); test('adding readable triggers data flow', function(t) { diff --git a/test/pummel/test-tls-server-large-request.js b/test/pummel/test-tls-server-large-request.js index 9928e8547ed5..04126027c266 100644 --- a/test/pummel/test-tls-server-large-request.js +++ b/test/pummel/test-tls-server-large-request.js @@ -38,7 +38,7 @@ var options = { function Mediator() { stream.Writable.call(this); this.buf = ''; -}; +} util.inherits(Mediator, stream.Writable); Mediator.prototype._write = function write(data, enc, cb) { diff --git a/test/pummel/test-tls-session-timeout.js b/test/pummel/test-tls-session-timeout.js index 87534f314fc6..33e7d24546d4 100644 --- a/test/pummel/test-tls-session-timeout.js +++ b/test/pummel/test-tls-session-timeout.js @@ -62,7 +62,7 @@ function doTest() { // file containing a proper serialization of a session ticket. // To avoid a source control diff, we copy the ticket to a temporary file. - var sessionFileName = (function () { + var sessionFileName = (function() { var ticketFileName = 'tls-session-ticket.txt'; var fixturesPath = join(common.fixturesDir, ticketFileName); var tmpPath = join(common.tmpDir, ticketFileName); @@ -72,7 +72,7 @@ function doTest() { // Expects a callback -- cb(connectionType : enum ['New'|'Reused']) - var Client = function (cb) { + var Client = function(cb) { var flags = [ 's_client', '-connect', 'localhost:' + common.PORT, @@ -89,7 +89,7 @@ function doTest() { }); client.on('exit', function(code) { var connectionType; - var grepConnectionType = function (line) { + var grepConnectionType = function(line) { var matches = line.match(/(New|Reused), /); if (matches) { connectionType = matches[1]; @@ -117,7 +117,7 @@ function doTest() { assert(connectionType === 'New'); Client(function(connectionType) { assert(connectionType === 'Reused'); - setTimeout(function () { + setTimeout(function() { Client(function(connectionType) { assert(connectionType === 'New'); server.close(); diff --git a/test/simple/test-assert.js b/test/simple/test-assert.js index 58280406bbd0..825fa8b366d1 100644 --- a/test/simple/test-assert.js +++ b/test/simple/test-assert.js @@ -267,7 +267,7 @@ function testAssertionMessage(actual, expected) { } catch (e) { assert.equal(e.toString(), ['AssertionError:', expected, '==', '\'\''].join(' ')); - assert.ok(e.generatedMessage, "Message not marked as generated"); + assert.ok(e.generatedMessage, 'Message not marked as generated'); } } testAssertionMessage(undefined, 'undefined'); @@ -286,7 +286,7 @@ testAssertionMessage([1, 2, 3], '[ 1, 2, 3 ]'); testAssertionMessage(/a/, '/a/'); testAssertionMessage(/abc/gim, '/abc/gim'); testAssertionMessage(function f() {}, '[Function: f]'); -testAssertionMessage(function () {}, '[Function]'); +testAssertionMessage(function() {}, '[Function]'); testAssertionMessage({}, '{}'); testAssertionMessage(circular, '{ y: 1, x: [Circular] }'); testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }'); @@ -295,7 +295,7 @@ testAssertionMessage({a: NaN, b: Infinity, c: -Infinity}, // #2893 try { - assert.throws(function () { + assert.throws(function() { assert.ifError(null); }); } catch (e) { @@ -308,14 +308,14 @@ assert.ok(threw); try { assert.equal(1, 2); } catch (e) { - assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2') + assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2'); assert.ok(e.generatedMessage, 'Message not marked as generated'); } try { assert.equal(1, 2, 'oh no'); } catch (e) { - assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no') + assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no'); assert.equal(e.generatedMessage, false, - 'Message incorrectly marked as generated'); + 'Message incorrectly marked as generated'); } diff --git a/test/simple/test-beforeexit-event.js b/test/simple/test-beforeexit-event.js index 41cc1d376613..e36f35e8b19c 100644 --- a/test/simple/test-beforeexit-event.js +++ b/test/simple/test-beforeexit-event.js @@ -25,7 +25,7 @@ var util = require('util'); var revivals = 0; var deaths = 0; -process.on('beforeExit', function() { deaths++; } ); +process.on('beforeExit', function() { deaths++; }); process.once('beforeExit', tryImmediate); @@ -39,7 +39,7 @@ function tryImmediate() { function tryTimer() { console.log('set a timeout'); - setTimeout(function () { + setTimeout(function() { console.log('timeout cb, do another once beforeExit'); revivals++; process.once('beforeExit', tryListen); @@ -51,9 +51,9 @@ function tryListen() { net.createServer() .listen(0) .on('listening', function() { - revivals++; - this.close(); - }); + revivals++; + this.close(); + }); } process.on('exit', function() { diff --git a/test/simple/test-buffer-concat.js b/test/simple/test-buffer-concat.js index 858d6924f95f..72346191ff87 100644 --- a/test/simple/test-buffer-concat.js +++ b/test/simple/test-buffer-concat.js @@ -23,7 +23,7 @@ var common = require('../common'); var assert = require('assert'); var zero = []; -var one = [ new Buffer('asdf') ]; +var one = [new Buffer('asdf')]; var long = []; for (var i = 0; i < 10; i++) long.push(new Buffer('asdf')); @@ -35,7 +35,7 @@ var flatLongLen = Buffer.concat(long, 40); assert(flatZero.length === 0); assert(flatOne.toString() === 'asdf'); assert(flatOne === one[0]); -assert(flatLong.toString() === (new Array(10+1).join('asdf'))); -assert(flatLongLen.toString() === (new Array(10+1).join('asdf'))); +assert(flatLong.toString() === (new Array(10 + 1).join('asdf'))); +assert(flatLongLen.toString() === (new Array(10 + 1).join('asdf'))); -console.log("ok"); +console.log('ok'); diff --git a/test/simple/test-buffer-inspect.js b/test/simple/test-buffer-inspect.js index a13c69b4e0dc..d2c54b7b71a8 100644 --- a/test/simple/test-buffer-inspect.js +++ b/test/simple/test-buffer-inspect.js @@ -55,4 +55,4 @@ buffer.INSPECT_MAX_BYTES = Infinity; assert.doesNotThrow(function() { assert.strictEqual(util.inspect(b), expected); assert.strictEqual(util.inspect(s), expected); -}); \ No newline at end of file +}); diff --git a/test/simple/test-buffer-slice.js b/test/simple/test-buffer-slice.js index 1a462bd0be31..f428edb51707 100644 --- a/test/simple/test-buffer-slice.js +++ b/test/simple/test-buffer-slice.js @@ -28,5 +28,5 @@ var buff = new Buffer(Buffer.poolSize + 1); var slicedBuffer = buff.slice(); assert.equal(slicedBuffer.parent, buff, - "slicedBufffer should have its parent set to the original " + - " buffer"); + 'slicedBufffer should have its parent set to the original ' + + ' buffer'); diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 0b3052db98f2..d215054e42bf 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -148,8 +148,8 @@ assert.strictEqual(Math.floor(c.length / 2), copied); for (var i = 0; i < Math.floor(c.length / 2); i++) { assert.strictEqual(b[b.length - Math.floor(c.length / 2) + i], c[i]); } -for (var i = Math.floor(c.length /2) + 1; i < c.length; i++) { - assert.strictEqual(c[c.length-1], c[i]); +for (var i = Math.floor(c.length / 2) + 1; i < c.length; i++) { + assert.strictEqual(c[c.length - 1], c[i]); } // try to copy 513 bytes, and check we don't overrun c @@ -842,7 +842,7 @@ assert.equal(b.toString(), 'xxx'); // issue GH-3416 Buffer(Buffer(0), 0, 0); -[ 'hex', +['hex', 'utf8', 'utf-8', 'ascii', @@ -851,29 +851,27 @@ Buffer(Buffer(0), 0, 0); 'ucs2', 'ucs-2', 'utf16le', - 'utf-16le' ].forEach(function(enc) { - assert.equal(Buffer.isEncoding(enc), true); - }); + 'utf-16le'].forEach(function(enc) { + assert.equal(Buffer.isEncoding(enc), true); +}); -[ 'utf9', +['utf9', 'utf-7', 'Unicode-FTW', - 'new gnu gun' ].forEach(function(enc) { - assert.equal(Buffer.isEncoding(enc), false); - }); + 'new gnu gun'].forEach(function(enc) { + assert.equal(Buffer.isEncoding(enc), false); +}); // GH-5110 -(function () { +(function() { var buffer = new Buffer('test'), string = JSON.stringify(buffer); assert.equal(string, '{"type":"Buffer","data":[116,101,115,116]}'); assert.deepEqual(buffer, JSON.parse(string, function(key, value) { - return value && value.type === 'Buffer' - ? new Buffer(value.data) - : value; + return value && value.type === 'Buffer' ? new Buffer(value.data) : value; })); })(); @@ -974,16 +972,16 @@ assert.equal(buf.readInt8(0), -1); var buf = new Buffer([0xFF, 0xFF, 0xFF, 0xFF]); assert.equal(buf['readUInt' + bits + 'BE'](0), - (0xFFFFFFFF >>> (32 - bits))); + (0xFFFFFFFF >>> (32 - bits))); assert.equal(buf['readUInt' + bits + 'LE'](0), - (0xFFFFFFFF >>> (32 - bits))); + (0xFFFFFFFF >>> (32 - bits))); assert.equal(buf['readInt' + bits + 'BE'](0), - (0xFFFFFFFF >> (32 - bits))); + (0xFFFFFFFF >> (32 - bits))); assert.equal(buf['readInt' + bits + 'LE'](0), - (0xFFFFFFFF >> (32 - bits))); + (0xFFFFFFFF >> (32 - bits))); }); // test for common read(U)IntLE/BE @@ -1089,7 +1087,7 @@ assert.equal(buf.readInt8(0), -1); // see https://github.com/joyent/node/issues/5881 SlowBuffer(0).slice(0, 1); // make sure a zero length slice doesn't set the .parent attribute - assert.equal(Buffer(5).slice(0,0).parent, undefined); + assert.equal(Buffer(5).slice(0, 0).parent, undefined); // and make sure a proper slice does have a parent assert.ok(typeof Buffer(5).slice(0, 5).parent === 'object'); })(); @@ -1121,11 +1119,11 @@ assert.throws(function() { })(); -assert.throws(function () { +assert.throws(function() { new Buffer(smalloc.kMaxLength + 1); }, RangeError); -assert.throws(function () { +assert.throws(function() { new SlowBuffer(smalloc.kMaxLength + 1); }, RangeError); @@ -1136,8 +1134,8 @@ var b1 = new Buffer('YW55=======', 'base64'); var b2 = new Buffer('YW55', 'base64'); assert.equal( - crypto.createHash('sha1').update(b1).digest('hex'), - crypto.createHash('sha1').update(b2).digest('hex') + crypto.createHash('sha1').update(b1).digest('hex'), + crypto.createHash('sha1').update(b2).digest('hex') ); // Test Compare diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js index 3fb13b6208f4..f9f6378b1440 100644 --- a/test/simple/test-child-process-buffering.js +++ b/test/simple/test-child-process-buffering.js @@ -44,7 +44,7 @@ function pwd(callback) { childExited = true; }); - child.on('close', function () { + child.on('close', function() { callback(output); pwd_called = true; childClosed = true; diff --git a/test/simple/test-child-process-cwd.js b/test/simple/test-child-process-cwd.js index b06e8e479385..53720f868ebe 100644 --- a/test/simple/test-child-process-cwd.js +++ b/test/simple/test-child-process-cwd.js @@ -47,7 +47,7 @@ function testCwd(options, forCode, forData) { assert.strictEqual(forCode, code); }); - child.on('close', function () { + child.on('close', function() { forData && assert.strictEqual(forData, data.replace(/[\s\r\n]+$/, '')); returns--; }); diff --git a/test/simple/test-child-process-detached.js b/test/simple/test-child-process-detached.js index 10ce5d15274c..b7ca9bbae4f7 100644 --- a/test/simple/test-child-process-detached.js +++ b/test/simple/test-child-process-detached.js @@ -24,21 +24,22 @@ var assert = require('assert'); var path = require('path'); var spawn = require('child_process').spawn; -var childPath = path.join(__dirname, '..', 'fixtures', 'parent-process-nonpersistent.js'); +var childPath = path.join(__dirname, '..', 'fixtures', + 'parent-process-nonpersistent.js'); var persistentPid = -1; -var child = spawn(process.execPath, [ childPath ]); +var child = spawn(process.execPath, [childPath]); -child.stdout.on('data', function (data) { +child.stdout.on('data', function(data) { persistentPid = parseInt(data, 10); }); -process.on('exit', function () { +process.on('exit', function() { assert(persistentPid !== -1); - assert.throws(function () { + assert.throws(function() { process.kill(child.pid); }); - assert.doesNotThrow(function () { + assert.doesNotThrow(function() { process.kill(persistentPid); }); }); diff --git a/test/simple/test-child-process-double-pipe.js b/test/simple/test-child-process-double-pipe.js index c09dfa885327..39a033af5e4c 100644 --- a/test/simple/test-child-process-double-pipe.js +++ b/test/simple/test-child-process-double-pipe.js @@ -116,5 +116,5 @@ sed.stdout.on('data', function(data) { }); sed.stdout.on('end', function(code) { - assert.equal(result, 'hellO' + os.EOL + 'nOde' + os.EOL +'wOrld' + os.EOL); + assert.equal(result, 'hellO' + os.EOL + 'nOde' + os.EOL + 'wOrld' + os.EOL); }); diff --git a/test/simple/test-child-process-exec-buffer.js b/test/simple/test-child-process-exec-buffer.js index 937dce76e6a9..12fd8c1d4488 100644 --- a/test/simple/test-child-process-exec-buffer.js +++ b/test/simple/test-child-process-exec-buffer.js @@ -29,7 +29,7 @@ var success_count = 0; var str = 'hello'; // default encoding -var child = exec("echo " + str, function(err, stdout, stderr) { +var child = exec('echo ' + str, function(err, stdout, stderr) { assert.ok('string', typeof(stdout), 'Expected stdout to be a string'); assert.ok('string', typeof(stderr), 'Expected stderr to be a string'); assert.equal(str + os.EOL, stdout); @@ -38,7 +38,7 @@ var child = exec("echo " + str, function(err, stdout, stderr) { }); // no encoding (Buffers expected) -var child = exec("echo " + str, { +var child = exec('echo ' + str, { encoding: null }, function(err, stdout, stderr) { assert.ok(stdout instanceof Buffer, 'Expected stdout to be a Buffer'); diff --git a/test/simple/test-child-process-execsync.js b/test/simple/test-child-process-execsync.js index 28fa0200f229..08bc7995a1df 100644 --- a/test/simple/test-child-process-execsync.js +++ b/test/simple/test-child-process-execsync.js @@ -79,7 +79,8 @@ assert.deepEqual(ret, msgBuf); ret = execFileSync(process.execPath, args, { encoding: 'utf8' }); -assert.strictEqual(ret, msg + '\n', 'execFileSync encoding result should match'); +assert.strictEqual(ret, msg + '\n', + 'execFileSync encoding result should match'); // Verify that the cwd option works - GH #7824 (function() { diff --git a/test/simple/test-child-process-fork-and-spawn.js b/test/simple/test-child-process-fork-and-spawn.js index 989bf7ee3a1a..557c703dd58f 100644 --- a/test/simple/test-child-process-fork-and-spawn.js +++ b/test/simple/test-child-process-fork-and-spawn.js @@ -26,18 +26,18 @@ var fork = require('child_process').fork; // Fork, then spawn. The spawned process should not hang. switch (process.argv[2] || '') { -case '': - fork(__filename, ['fork']).on('exit', checkExit); - process.on('exit', haveExit); - break; -case 'fork': - spawn(process.execPath, [__filename, 'spawn']).on('exit', checkExit); - process.on('exit', haveExit); - break; -case 'spawn': - break; -default: - assert(0); + case '': + fork(__filename, ['fork']).on('exit', checkExit); + process.on('exit', haveExit); + break; + case 'fork': + spawn(process.execPath, [__filename, 'spawn']).on('exit', checkExit); + process.on('exit', haveExit); + break; + case 'spawn': + break; + default: + assert(0); } var seenExit = false; diff --git a/test/simple/test-child-process-fork-dgram.js b/test/simple/test-child-process-fork-dgram.js index 1c4e9acc3b75..07b1008a328b 100644 --- a/test/simple/test-child-process-fork-dgram.js +++ b/test/simple/test-child-process-fork-dgram.js @@ -51,7 +51,7 @@ if (process.argv[2] === 'child') { if (msg === 'server') { server = clusterServer; - server.on('message', function () { + server.on('message', function() { process.send('gotMessage'); }); @@ -71,14 +71,14 @@ if (process.argv[2] === 'child') { var childGotMessage = false; var parentGotMessage = false; - server.on('message', function (msg, rinfo) { + server.on('message', function(msg, rinfo) { parentGotMessage = true; }); - server.on('listening', function () { + server.on('listening', function() { child.send('server', server); - child.once('message', function (msg) { + child.once('message', function(msg) { if (msg === 'gotMessage') { childGotMessage = true; } @@ -87,11 +87,11 @@ if (process.argv[2] === 'child') { sendMessages(); }); - var sendMessages = function () { - var timer = setInterval(function () { + var sendMessages = function() { + var timer = setInterval(function() { client.send(msg, 0, msg.length, common.PORT, '127.0.0.1', function(err) { - if (err) throw err; - } + if (err) throw err; + } ); /* @@ -106,7 +106,7 @@ if (process.argv[2] === 'child') { }, 1); }; - var shutdown = function () { + var shutdown = function() { child.send('stop'); server.close(); @@ -115,7 +115,7 @@ if (process.argv[2] === 'child') { server.bind(common.PORT, '127.0.0.1'); - process.once('exit', function () { + process.once('exit', function() { assert(parentGotMessage); assert(childGotMessage); }); diff --git a/test/simple/test-child-process-fork-exec-argv.js b/test/simple/test-child-process-fork-exec-argv.js index 1f9f89fbbb7e..8ba77f0583a9 100644 --- a/test/simple/test-child-process-fork-exec-argv.js +++ b/test/simple/test-child-process-fork-exec-argv.js @@ -37,11 +37,11 @@ if (process.argv[2] === 'fork') { var child = spawn(process.execPath, execArgv.concat(args)); var out = ''; - child.stdout.on('data', function (chunk) { + child.stdout.on('data', function(chunk) { out += chunk; }); - child.on('exit', function () { + child.on('exit', function() { assert.deepEqual(JSON.parse(out), execArgv); }); } diff --git a/test/simple/test-child-process-fork-getconnections.js b/test/simple/test-child-process-fork-getconnections.js index f8fed6884f5a..89c7d97171f2 100644 --- a/test/simple/test-child-process-fork-getconnections.js +++ b/test/simple/test-child-process-fork-getconnections.js @@ -101,7 +101,7 @@ if (process.argv[2] === 'child') { closeSockets(i + 1); }); }); - }; + } var closeEmitted = false; server.on('close', function() { diff --git a/test/simple/test-child-process-fork-ref.js b/test/simple/test-child-process-fork-ref.js index 21954ec733b4..c2166bc382ed 100644 --- a/test/simple/test-child-process-fork-ref.js +++ b/test/simple/test-child-process-fork-ref.js @@ -31,7 +31,7 @@ if (process.argv[2] === 'child') { process.send('2'); }, 200); - process.on('disconnect', function () { + process.on('disconnect', function() { process.stdout.write('3'); }); @@ -40,17 +40,17 @@ if (process.argv[2] === 'child') { var ipc = [], stdout = ''; - child.on('message', function (msg) { + child.on('message', function(msg) { ipc.push(msg); if (msg === '2') child.disconnect(); }); - child.stdout.on('data', function (chunk) { + child.stdout.on('data', function(chunk) { stdout += chunk; }); - child.once('exit', function () { + child.once('exit', function() { assert.deepEqual(ipc, ['1', '2']); assert.equal(stdout, '3'); }); diff --git a/test/simple/test-child-process-fork-ref2.js b/test/simple/test-child-process-fork-ref2.js index 3d604142bbac..13814a29a649 100644 --- a/test/simple/test-child-process-fork-ref2.js +++ b/test/simple/test-child-process-fork-ref2.js @@ -29,17 +29,17 @@ if (process.argv[2] === 'child') { setTimeout(function() { console.log('child -> will this keep it alive?'); - process.on('message', function () { }); + process.on('message', function() { }); }, 400); } else { var child = fork(__filename, ['child']); - child.on('disconnect', function () { + child.on('disconnect', function() { console.log('parent -> disconnect'); }); - child.once('exit', function () { + child.once('exit', function() { console.log('parent -> exit'); }); } diff --git a/test/simple/test-child-process-spawn-error.js b/test/simple/test-child-process-spawn-error.js index 5ecfbff263b4..a6808aec1997 100644 --- a/test/simple/test-child-process-spawn-error.js +++ b/test/simple/test-child-process-spawn-error.js @@ -29,7 +29,7 @@ var enoentPath = 'foo123'; assert.equal(fs.existsSync(enoentPath), false); var enoentChild = spawn(enoentPath); -enoentChild.on('error', function (err) { +enoentChild.on('error', function(err) { assert.equal(err.path, enoentPath); errors++; }); diff --git a/test/simple/test-child-process-spawn-typeerror.js b/test/simple/test-child-process-spawn-typeerror.js index 759f17cee9a7..db49eb82fdb4 100644 --- a/test/simple/test-child-process-spawn-typeerror.js +++ b/test/simple/test-child-process-spawn-typeerror.js @@ -20,23 +20,23 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. var assert = require('assert'), - child_process = require('child_process'), - spawn = child_process.spawn, - fork = child_process.fork, - execFile = child_process.execFile, - windows = (process.platform === 'win32'), - cmd = (windows) ? 'rundll32' : 'ls', - invalidcmd = 'hopefully_you_dont_have_this_on_your_machine', - invalidArgsMsg = /Incorrect value of args option/, - invalidOptionsMsg = /options argument must be an object/, - empty = require('../common').fixturesDir + '/empty.js', - errors = 0; + child_process = require('child_process'), + spawn = child_process.spawn, + fork = child_process.fork, + execFile = child_process.execFile, + windows = (process.platform === 'win32'), + cmd = (windows) ? 'rundll32' : 'ls', + invalidcmd = 'hopefully_you_dont_have_this_on_your_machine', + invalidArgsMsg = /Incorrect value of args option/, + invalidOptionsMsg = /options argument must be an object/, + empty = require('../common').fixturesDir + '/empty.js', + errors = 0; try { // Ensure this throws a TypeError var child = spawn(invalidcmd, 'this is not an array'); - child.on('error', function (err) { + child.on('error', function(err) { errors++; }); @@ -87,7 +87,8 @@ process.on('exit', function() { }); // Argument types for combinatorics -var a=[], o={}, c=(function callback(){}), s='string', u=undefined, n=null; +var a = [], o = {}, c = (function callback() {}); +var s = 'string', u = undefined, n = null; // function spawn(file=f [,args=a] [, options=o]) has valid combinations: // (f) diff --git a/test/simple/test-child-process-spawnsync-timeout.js b/test/simple/test-child-process-spawnsync-timeout.js index 691f58786eeb..4f9b6ccc33ad 100644 --- a/test/simple/test-child-process-spawnsync-timeout.js +++ b/test/simple/test-child-process-spawnsync-timeout.js @@ -36,7 +36,8 @@ switch (process.argv[2]) { break; default: var start = Date.now(); - var ret = spawnSync(process.execPath, [__filename, 'child'], {timeout: TIMER}); + var ret = spawnSync(process.execPath, [__filename, 'child'], + {timeout: TIMER}); assert.strictEqual(ret.error.errno, 'ETIMEDOUT'); console.log(ret); var end = Date.now() - start; diff --git a/test/simple/test-child-process-spawnsync.js b/test/simple/test-child-process-spawnsync.js index a7cbb8d1dfb7..0a9bb4164aee 100644 --- a/test/simple/test-child-process-spawnsync.js +++ b/test/simple/test-child-process-spawnsync.js @@ -41,7 +41,8 @@ var ret = spawnSync('sleep', ['1']); var stop = process.hrtime(start); assert.strictEqual(ret.status, 0, 'exit status should be zero'); console.log('sleep exited', stop); -assert.strictEqual(stop[0], 1, 'sleep should not take longer or less than 1 second'); +assert.strictEqual(stop[0], 1, + 'sleep should not take longer or less than 1 second'); // Error test when command does not exist var ret_err = spawnSync('command_does_not_exist'); diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js index fdb40cc82c47..101b3df70688 100644 --- a/test/simple/test-child-process-stdin.js +++ b/test/simple/test-child-process-stdin.js @@ -69,7 +69,7 @@ cat.on('exit', function(status) { exitStatus = status; }); -cat.on('close', function () { +cat.on('close', function() { closed = true; if (is_windows) { assert.equal('hello world\r\n', response); diff --git a/test/simple/test-child-process-stdout-flush-exit.js b/test/simple/test-child-process-stdout-flush-exit.js index 49a0ec0e5f71..d21b4a4e6859 100644 --- a/test/simple/test-child-process-stdout-flush-exit.js +++ b/test/simple/test-child-process-stdout-flush-exit.js @@ -45,14 +45,14 @@ if (process.argv[2] === 'child') { var gotBye = false; child.stderr.setEncoding('utf8'); - child.stderr.on('data', function (data) { + child.stderr.on('data', function(data) { console.log('parent stderr: ' + data); assert.ok(false); }); // check if we receive both 'hello' at start and 'goodbye' at end child.stdout.setEncoding('utf8'); - child.stdout.on('data', function (data) { + child.stdout.on('data', function(data) { if (data.slice(0, 6) == 'hello\n') { gotHello = true; } else if (data.slice(data.length - 8) == 'goodbye\n') { @@ -62,7 +62,7 @@ if (process.argv[2] === 'child') { } }); - child.on('close', function (data) { + child.on('close', function(data) { assert(gotHello); assert(gotBye); }); diff --git a/test/simple/test-cluster-basic.js b/test/simple/test-cluster-basic.js index e6adfb5bad23..15273c55a308 100644 --- a/test/simple/test-cluster-basic.js +++ b/test/simple/test-cluster-basic.js @@ -25,7 +25,7 @@ var assert = require('assert'); var cluster = require('cluster'); assert.equal('NODE_UNIQUE_ID' in process.env, false, - 'NODE_UNIQUE_ID should be removed on startup'); + 'NODE_UNIQUE_ID should be removed on startup'); function forEach(obj, fn) { Object.keys(obj).forEach(function(name, index) { diff --git a/test/simple/test-cluster-dgram-1.js b/test/simple/test-cluster-dgram-1.js index c6dc095d0832..3abaecba3da6 100644 --- a/test/simple/test-cluster-dgram-1.js +++ b/test/simple/test-cluster-dgram-1.js @@ -29,7 +29,7 @@ var dgram = require('dgram'); if (process.platform === 'win32') { - console.warn("dgram clustering is currently not supported on windows."); + console.warn('dgram clustering is currently not supported on windows.'); process.exit(0); } diff --git a/test/simple/test-cluster-dgram-2.js b/test/simple/test-cluster-dgram-2.js index 4ba41b8219f7..c8f6a7088b02 100644 --- a/test/simple/test-cluster-dgram-2.js +++ b/test/simple/test-cluster-dgram-2.js @@ -29,7 +29,7 @@ var dgram = require('dgram'); if (process.platform === 'win32') { - console.warn("dgram clustering is currently not supported on windows."); + console.warn('dgram clustering is currently not supported on windows.'); process.exit(0); } @@ -82,5 +82,6 @@ function worker() { for (var i = 0; i < PACKETS_PER_WORKER; i++) socket.send(buf, 0, buf.length, common.PORT, '127.0.0.1'); - console.log('worker %d sent %d packets', cluster.worker.id, PACKETS_PER_WORKER); + console.log('worker %d sent %d packets', + cluster.worker.id, PACKETS_PER_WORKER); } diff --git a/test/simple/test-cluster-disconnect-unshared-tcp.js b/test/simple/test-cluster-disconnect-unshared-tcp.js index 7a9c5f58ab83..8f3dd12449d5 100644 --- a/test/simple/test-cluster-disconnect-unshared-tcp.js +++ b/test/simple/test-cluster-disconnect-unshared-tcp.js @@ -37,7 +37,7 @@ if (cluster.isMaster) { } } else { if (process.env.BOUND === 'y') { - var source = net.createServer() + var source = net.createServer(); source.listen(0); } diff --git a/test/simple/test-cluster-rr-domain-listen.js b/test/simple/test-cluster-rr-domain-listen.js index 574036df23b8..f652ec8c346f 100755 --- a/test/simple/test-cluster-rr-domain-listen.js +++ b/test/simple/test-cluster-rr-domain-listen.js @@ -28,7 +28,7 @@ var domain = require('domain'); if (cluster.isWorker) { var d = domain.create(); - d.run(function () { }); + d.run(function() { }); var http = require('http'); http.Server(function() { }).listen(common.PORT, '127.0.0.1'); diff --git a/test/simple/test-cluster-setup-master-cumulative.js b/test/simple/test-cluster-setup-master-cumulative.js index 2f69cd368922..ca0b7664977c 100644 --- a/test/simple/test-cluster-setup-master-cumulative.js +++ b/test/simple/test-cluster-setup-master-cumulative.js @@ -34,7 +34,7 @@ assert.deepEqual(cluster.settings, { args: process.argv.slice(2), exec: process.argv[1], execArgv: process.execArgv, - silent: false, + silent: false }); console.log('ok sets defaults'); @@ -57,6 +57,6 @@ assert.deepEqual(cluster.settings, { args: ['foo', 'bar'], exec: 'overridden', execArgv: ['baz', 'bang'], - silent: false, + silent: false }); console.log('ok preserves current settings'); diff --git a/test/simple/test-cluster-setup-master-multiple.js b/test/simple/test-cluster-setup-master-multiple.js index 21756b9c0caa..79d6cbf860f6 100644 --- a/test/simple/test-cluster-setup-master-multiple.js +++ b/test/simple/test-cluster-setup-master-multiple.js @@ -45,7 +45,7 @@ cluster.on('setup', function() { var execs = [ 'node-next', 'node-next-2', - 'node-next-3', + 'node-next-3' ]; process.on('exit', function assertTests() { diff --git a/test/simple/test-cluster-worker-exit.js b/test/simple/test-cluster-worker-exit.js index 7b9d5d86c4a2..a3496730eb36 100644 --- a/test/simple/test-cluster-worker-exit.js +++ b/test/simple/test-cluster-worker-exit.js @@ -45,23 +45,23 @@ if (cluster.isWorker) { } else if (cluster.isMaster) { var expected_results = { - cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], - cluster_emitExit: [1, "the cluster did not emit 'exit'"], - cluster_exitCode: [EXIT_CODE, 'the cluster exited w/ incorrect exitCode'], - cluster_signalCode: [null, 'the cluster exited w/ incorrect signalCode'], - worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], - worker_emitExit: [1, "the worker did not emit 'exit'"], - worker_state: ['disconnected', 'the worker state is incorrect'], - worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], - worker_died: [true, 'the worker is still running'], - worker_exitCode: [EXIT_CODE, 'the worker exited w/ incorrect exitCode'], - worker_signalCode: [null, 'the worker exited w/ incorrect signalCode'] + cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], + cluster_emitExit: [1, "the cluster did not emit 'exit'"], + cluster_exitCode: [EXIT_CODE, 'the cluster exited w/ incorrect exitCode'], + cluster_signalCode: [null, 'the cluster exited w/ incorrect signalCode'], + worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], + worker_emitExit: [1, "the worker did not emit 'exit'"], + worker_state: ['disconnected', 'the worker state is incorrect'], + worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], + worker_died: [true, 'the worker is still running'], + worker_exitCode: [EXIT_CODE, 'the worker exited w/ incorrect exitCode'], + worker_signalCode: [null, 'the worker exited w/ incorrect signalCode'] }; var results = { - cluster_emitDisconnect: 0, - cluster_emitExit: 0, - worker_emitDisconnect: 0, - worker_emitExit: 0 + cluster_emitDisconnect: 0, + cluster_emitExit: 0, + worker_emitDisconnect: 0, + worker_emitExit: 0 }; @@ -122,31 +122,31 @@ if (cluster.isWorker) { // some helper functions ... - function checkResults(expected_results, results) { - for (var k in expected_results) { - var actual = results[k], - expected = expected_results[k]; +function checkResults(expected_results, results) { + for (var k in expected_results) { + var actual = results[k], + expected = expected_results[k]; - if (typeof expected === 'function') { - expected(r[k]); + if (typeof expected === 'function') { + expected(r[k]); + } else { + var msg = (expected[1] || '') + + (' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); + + if (expected && expected.length) { + assert.equal(actual, expected[0], msg); } else { - var msg = (expected[1] || '') + - (' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); - - if (expected && expected.length) { - assert.equal(actual, expected[0], msg); - } else { - assert.equal(actual, expected, msg); - } + assert.equal(actual, expected, msg); } } } +} - function alive(pid) { - try { - process.kill(pid, 'SIGCONT'); - return true; - } catch (e) { - return false; - } +function alive(pid) { + try { + process.kill(pid, 'SIGCONT'); + return true; + } catch (e) { + return false; } +} diff --git a/test/simple/test-cluster-worker-forced-exit.js b/test/simple/test-cluster-worker-forced-exit.js index 66d5f183552e..686c79ecdd36 100644 --- a/test/simple/test-cluster-worker-forced-exit.js +++ b/test/simple/test-cluster-worker-forced-exit.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. var assert = require('assert'); -var cluster = require('cluster') +var cluster = require('cluster'); var net = require('net'); var SENTINEL = 42; @@ -58,21 +58,21 @@ checkForced(); function checkUnforced() { cluster.fork() .on('online', function() { - this.disconnect(); - }) + this.disconnect(); + }) .on('exit', function(status) { - assert.equal(status, SENTINEL); - unforcedOk = true; - }); + assert.equal(status, SENTINEL); + unforcedOk = true; + }); } function checkForced() { cluster.fork() .on('online', function() { - this.process.disconnect(); - }) + this.process.disconnect(); + }) .on('exit', function(status) { - assert.equal(status, 0); - forcedOk = true; - }); + assert.equal(status, 0); + forcedOk = true; + }); } diff --git a/test/simple/test-cluster-worker-isconnected.js b/test/simple/test-cluster-worker-isconnected.js index ed839d496304..c54a87cd6a71 100644 --- a/test/simple/test-cluster-worker-isconnected.js +++ b/test/simple/test-cluster-worker-isconnected.js @@ -6,32 +6,32 @@ if (cluster.isMaster) { var worker = cluster.fork(); assert.ok(worker.isConnected(), - "isConnected() should return true as soon as the worker has " + - "been created."); + 'isConnected() should return true as soon as the worker has ' + + 'been created.'); worker.on('disconnect', function() { assert.ok(!worker.isConnected(), - "After a disconnect event has been emitted, " + - "isConncted should return false"); + 'After a disconnect event has been emitted, ' + + 'isConncted should return false'); }); worker.on('message', function(msg) { if (msg === 'readyToDisconnect') { worker.disconnect(); } - }) + }); } else { assert.ok(cluster.worker.isConnected(), - "isConnected() should return true from within a worker at all " + - "times."); + 'isConnected() should return true from within a worker at all ' + + 'times.'); cluster.worker.process.on('disconnect', function() { assert.ok(!cluster.worker.isConnected(), - "isConnected() should return false from within a worker " + - "after its underlying process has been disconnected from " + - "the master"); - }) + 'isConnected() should return false from within a worker ' + + 'after its underlying process has been disconnected from ' + + 'the master'); + }); process.send('readyToDisconnect'); } diff --git a/test/simple/test-cluster-worker-isdead.js b/test/simple/test-cluster-worker-isdead.js index 11766c597f82..da81497d72a2 100644 --- a/test/simple/test-cluster-worker-isdead.js +++ b/test/simple/test-cluster-worker-isdead.js @@ -5,23 +5,23 @@ var net = require('net'); if (cluster.isMaster) { var worker = cluster.fork(); assert.ok(!worker.isDead(), - "isDead() should return false right after the worker has been " + - "created."); + 'isDead() should return false right after the worker has been ' + + 'created.'); worker.on('exit', function() { - assert.ok(!worker.isConnected(), - "After an event has been emitted, " + - "isDead should return true"); - }) + assert.ok(!worker.isConnected(), + 'After an event has been emitted, ' + + 'isDead should return true'); + }); worker.on('message', function(msg) { - if (msg === 'readyToDie') { - worker.kill(); - } + if (msg === 'readyToDie') { + worker.kill(); + } }); } else if (cluster.isWorker) { assert.ok(!cluster.worker.isDead(), - "isDead() should return false when called from within a worker"); + 'isDead() should return false when called from within a worker'); process.send('readyToDie'); } diff --git a/test/simple/test-cluster-worker-kill.js b/test/simple/test-cluster-worker-kill.js index 8c6068e8db90..9ddce461fb4c 100644 --- a/test/simple/test-cluster-worker-kill.js +++ b/test/simple/test-cluster-worker-kill.js @@ -41,25 +41,27 @@ if (cluster.isWorker) { } else if (cluster.isMaster) { var KILL_SIGNAL = 'SIGKILL', - expected_results = { - cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], - cluster_emitExit: [1, "the cluster did not emit 'exit'"], - cluster_exitCode: [null, 'the cluster exited w/ incorrect exitCode'], - cluster_signalCode: [KILL_SIGNAL, 'the cluster exited w/ incorrect signalCode'], - worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], - worker_emitExit: [1, "the worker did not emit 'exit'"], - worker_state: ['disconnected', 'the worker state is incorrect'], - worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], - worker_died: [true, 'the worker is still running'], - worker_exitCode: [null, 'the worker exited w/ incorrect exitCode'], - worker_signalCode: [KILL_SIGNAL, 'the worker exited w/ incorrect signalCode'] - }, - results = { - cluster_emitDisconnect: 0, - cluster_emitExit: 0, - worker_emitDisconnect: 0, - worker_emitExit: 0 - }; + expected_results = { + cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], + cluster_emitExit: [1, "the cluster did not emit 'exit'"], + cluster_exitCode: [null, 'the cluster exited w/ incorrect exitCode'], + cluster_signalCode: + [KILL_SIGNAL, 'the cluster exited w/ incorrect signalCode'], + worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], + worker_emitExit: [1, "the worker did not emit 'exit'"], + worker_state: ['disconnected', 'the worker state is incorrect'], + worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], + worker_died: [true, 'the worker is still running'], + worker_exitCode: [null, 'the worker exited w/ incorrect exitCode'], + worker_signalCode: + [KILL_SIGNAL, 'the worker exited w/ incorrect signalCode'] + }, + results = { + cluster_emitDisconnect: 0, + cluster_emitExit: 0, + worker_emitDisconnect: 0, + worker_emitExit: 0 + }; // start worker @@ -120,30 +122,30 @@ if (cluster.isWorker) { // some helper functions ... - function checkResults(expected_results, results) { - for (var k in expected_results) { - var actual = results[k], - expected = expected_results[k]; - - if (typeof expected === 'function') { - expected(r[k]); +function checkResults(expected_results, results) { + for (var k in expected_results) { + var actual = results[k], + expected = expected_results[k]; + + if (typeof expected === 'function') { + expected(r[k]); + } else { + var msg = (expected[1] || '') + + (' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); + if (expected && expected.length) { + assert.equal(actual, expected[0], msg); } else { - var msg = (expected[1] || '') + - (' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); - if (expected && expected.length) { - assert.equal(actual, expected[0], msg); - } else { - assert.equal(actual, expected, msg); - } + assert.equal(actual, expected, msg); } } } +} - function alive(pid) { - try { - process.kill(pid, 'SIGCONT'); - return true; - } catch (e) { - return false; - } +function alive(pid) { + try { + process.kill(pid, 'SIGCONT'); + return true; + } catch (e) { + return false; } +} diff --git a/test/simple/test-cluster-worker-no-exit.js b/test/simple/test-cluster-worker-no-exit.js index c521fcbb104a..e856b6486931 100644 --- a/test/simple/test-cluster-worker-no-exit.js +++ b/test/simple/test-cluster-worker-no-exit.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. var assert = require('assert'); -var cluster = require('cluster') +var cluster = require('cluster'); var net = require('net'); var destroyed; @@ -41,7 +41,7 @@ var server; if (cluster.isMaster) { server = net.createServer(function(conn) { server.close(); - worker.disconnect() + worker.disconnect(); worker.once('disconnect', function() { setTimeout(function() { conn.destroy(); @@ -58,8 +58,8 @@ if (cluster.isMaster) { worker = cluster.fork() .on('online', function() { - this.send({port: port}); - }); + this.send({port: port}); + }); }); process.on('exit', function() { assert(success); diff --git a/test/simple/test-console-instance.js b/test/simple/test-console-instance.js index e0166ebd3148..469c29554d8d 100644 --- a/test/simple/test-console-instance.js +++ b/test/simple/test-console-instance.js @@ -37,7 +37,7 @@ assert.equal('function', typeof Console); // make sure that the Console constructor throws // when not given a writable stream instance -assert.throws(function () { +assert.throws(function() { new Console(); }, /Console expects a writable stream/); diff --git a/test/simple/test-console.js b/test/simple/test-console.js index 68e9deb9279a..c8c5aa91d7db 100644 --- a/test/simple/test-console.js +++ b/test/simple/test-console.js @@ -31,17 +31,17 @@ assert.ok(process.stderr.writable); assert.equal('number', typeof process.stdout.fd); assert.equal('number', typeof process.stderr.fd); -assert.throws(function () { +assert.throws(function() { console.timeEnd('no such label'); }); -assert.doesNotThrow(function () { +assert.doesNotThrow(function() { console.time('label'); console.timeEnd('label'); }); // an Object with a custom .inspect() function -var custom_inspect = { foo: 'bar', inspect: function () { return 'inspect'; } }; +var custom_inspect = { foo: 'bar', inspect: function() { return 'inspect'; } }; var stdout_write = global.process.stdout.write; var strings = []; @@ -60,8 +60,8 @@ console.log(custom_inspect); // test console.dir() console.dir(custom_inspect); console.dir(custom_inspect, { showHidden: false }); -console.dir({ foo : { bar : { baz : true } } }, { depth: 0 }); -console.dir({ foo : { bar : { baz : true } } }, { depth: 1 }); +console.dir({ foo: { bar: { baz: true } } }, { depth: 0 }); +console.dir({ foo: { bar: { baz: true } } }, { depth: 1 }); // test console.trace() console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo'); diff --git a/test/simple/test-crypto-authenticated.js b/test/simple/test-crypto-authenticated.js index 2b59c37a473d..ccce022dbe9c 100644 --- a/test/simple/test-crypto-authenticated.js +++ b/test/simple/test-crypto-authenticated.js @@ -60,7 +60,7 @@ var TEST_CASES = [ { algo: 'aes-256-gcm', key: '3zTvzr3p67VC61jmV54rIYu1545x4TlY', iv: '60iP0h6vJoEa', plain: 'Hello node.js world!', ct: '58E62CFF7B1D274011A82267EBB93866E72B6C2B', - tag: '9BB44F663BADABACAE9720881FB1EC7A', tampered: true }, + tag: '9BB44F663BADABACAE9720881FB1EC7A', tampered: true } ]; var ciphers = crypto.getCiphers(); @@ -112,7 +112,7 @@ for (var i in TEST_CASES) { (function() { // non-authenticating mode: var encrypt = crypto.createCipheriv('aes-128-cbc', - 'ipxp9a6i1Mb4USb4', '6fKjEjR3Vl30EUYC'); + 'ipxp9a6i1Mb4USb4', '6fKjEjR3Vl30EUYC'); encrypt.update('blah', 'ascii'); encrypt.final(); assert.throws(function() { encrypt.getAuthTag(); }, / state/); diff --git a/test/simple/test-crypto-binary-default.js b/test/simple/test-crypto-binary-default.js index fe7da668e213..9e8f4a3a5575 100644 --- a/test/simple/test-crypto-binary-default.js +++ b/test/simple/test-crypto-binary-default.js @@ -64,19 +64,19 @@ try { // PFX tests assert.doesNotThrow(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'sample'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'sample'}); }); assert.throws(function() { - tls.createSecureContext({pfx:certPfx}); + tls.createSecureContext({pfx: certPfx}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'test'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'test'}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:'sample', passphrase:'test'}); + tls.createSecureContext({pfx: 'sample', passphrase: 'test'}); }, 'not enough data'); // Test HMAC diff --git a/test/simple/test-crypto-certificate.js b/test/simple/test-crypto-certificate.js index 60fedee74529..994d4a523c01 100644 --- a/test/simple/test-crypto-certificate.js +++ b/test/simple/test-crypto-certificate.js @@ -40,13 +40,11 @@ assert.equal(certificate.verifySpkac(spkacValid), true); assert.equal(certificate.verifySpkac(spkacFail), false); assert.equal(stripLineEndings(certificate.exportPublicKey(spkacValid) - .toString('utf8')), - stripLineEndings(spkacPem.toString('utf8'))); + .toString('utf8')), stripLineEndings(spkacPem.toString('utf8'))); assert.equal(certificate.exportPublicKey(spkacFail), ''); assert.equal(certificate.exportChallenge(spkacValid) - .toString('utf8'), - 'fb9ab814-6677-42a4-a60c-f905d1a6924d'); + .toString('utf8'), 'fb9ab814-6677-42a4-a60c-f905d1a6924d'); assert.equal(certificate.exportChallenge(spkacFail), ''); function stripLineEndings(obj) { diff --git a/test/simple/test-crypto-domains.js b/test/simple/test-crypto-domains.js index 5c383860d14a..3dc0e146f958 100644 --- a/test/simple/test-crypto-domains.js +++ b/test/simple/test-crypto-domains.js @@ -23,28 +23,29 @@ var crypto = require('crypto'); var domain = require('domain'); var assert = require('assert'); var d = domain.create(); -var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'] +var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes']; -d.on('error', function (e) { +d.on('error', function(e) { var idx = expect.indexOf(e.message); assert.notEqual(idx, -1, 'we should have error: ' + e.message); expect.splice(idx, 1); }); -d.run(function () { - crypto.pbkdf2('a', 'b', 1, 8, function () { +d.run(function() { + crypto.pbkdf2('a', 'b', 1, 8, function() { throw new Error('pbkdf2'); }); - crypto.randomBytes(4, function () { + crypto.randomBytes(4, function() { throw new Error('randomBytes'); }); - crypto.pseudoRandomBytes(4, function () { + crypto.pseudoRandomBytes(4, function() { throw new Error('pseudoRandomBytes'); }); }); -process.on('exit', function () { - assert.strictEqual(expect.length, 0, 'we should have seen all error messages'); +process.on('exit', function() { + assert.strictEqual(expect.length, 0, + 'we should have seen all error messages'); }); diff --git a/test/simple/test-crypto-hash-stream-pipe.js b/test/simple/test-crypto-hash-stream-pipe.js index 1394903fab00..19ab9508f78f 100644 --- a/test/simple/test-crypto-hash-stream-pipe.js +++ b/test/simple/test-crypto-hash-stream-pipe.js @@ -23,7 +23,7 @@ var common = require('../common'); var assert = require('assert'); var crypto = require('crypto'); -var stream = require('stream') +var stream = require('stream'); var s = new stream.PassThrough(); var h = crypto.createHash('sha1'); var expect = '15987e60950cf22655b9323bc1e281f9c4aff47e'; diff --git a/test/simple/test-crypto-padding-aes256.js b/test/simple/test-crypto-padding-aes256.js index dd293feb1048..e083791b1b89 100644 --- a/test/simple/test-crypto-padding-aes256.js +++ b/test/simple/test-crypto-padding-aes256.js @@ -32,20 +32,20 @@ try { crypto.DEFAULT_ENCODING = 'buffer'; function aes256(decipherFinal) { - var iv = new Buffer('00000000000000000000000000000000', 'hex'); + var iv = new Buffer('00000000000000000000000000000000', 'hex'); var key = new Buffer('0123456789abcdef0123456789abcdef' + '0123456789abcdef0123456789abcdef', 'hex'); function encrypt(val, pad) { - var c = crypto.createCipheriv('aes256', key, iv); - c.setAutoPadding(pad); - return c.update(val, 'utf8', 'binary') + c.final('binary'); + var c = crypto.createCipheriv('aes256', key, iv); + c.setAutoPadding(pad); + return c.update(val, 'utf8', 'binary') + c.final('binary'); } function decrypt(val, pad) { - var c = crypto.createDecipheriv('aes256', key, iv); - c.setAutoPadding(pad); - return c.update(val, 'binary', 'utf8') + c[decipherFinal]('utf8'); + var c = crypto.createDecipheriv('aes256', key, iv); + c.setAutoPadding(pad); + return c.update(val, 'binary', 'utf8') + c[decipherFinal]('utf8'); } // echo 0123456789abcdef0123456789abcdef \ diff --git a/test/simple/test-crypto-stream.js b/test/simple/test-crypto-stream.js index 34eb3c18d8df..ec475cf4cca6 100644 --- a/test/simple/test-crypto-stream.js +++ b/test/simple/test-crypto-stream.js @@ -36,24 +36,24 @@ function Stream2buffer(callback) { stream.Writable.call(this); this._buffers = []; - this.once('finish', function () { + this.once('finish', function() { callback(null, Buffer.concat(this._buffers)); }); } util.inherits(Stream2buffer, stream.Writable); -Stream2buffer.prototype._write = function (data, encodeing, done) { +Stream2buffer.prototype._write = function(data, encodeing, done) { this._buffers.push(data); return done(null); }; // Create an md5 hash of "Hallo world" var hasher1 = crypto.createHash('md5'); - hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) { - assert.equal(err, null); - assert.equal(hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07'); - }))); - hasher1.end('Hallo world'); +hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) { + assert.equal(err, null); + assert.equal(hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07'); +}))); +hasher1.end('Hallo world'); // Simpler check for unpipe, setEncoding, pause and resume crypto.createHash('md5').unpipe({}); @@ -70,7 +70,7 @@ var key = new Buffer('48fb56eb10ffeb13fc0ef551bbca3b1b', 'hex'), cipher.pipe(decipher) .on('error', common.mustCall(function end(err) { - assert(/bad decrypt/.test(err)); - })); + assert(/bad decrypt/.test(err)); + })); cipher.end('Papaya!'); // Should not cause an unhandled exception. diff --git a/test/simple/test-crypto-verify-failure.js b/test/simple/test-crypto-verify-failure.js index 09c43ddc05ac..081f40d08abc 100644 --- a/test/simple/test-crypto-verify-failure.js +++ b/test/simple/test-crypto-verify-failure.js @@ -48,11 +48,11 @@ var canSend = true; var server = tls.Server(options, function(socket) { setImmediate(function() { - console.log('sending'); - verify(); - setImmediate(function() { - socket.destroy(); - }); + console.log('sending'); + verify(); + setImmediate(function() { + socket.destroy(); + }); }); }); diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js index d3f1ade321c1..5c0bce40b4ff 100644 --- a/test/simple/test-crypto.js +++ b/test/simple/test-crypto.js @@ -49,13 +49,13 @@ var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', 'ascii'); var rsaKeyPemEncrypted = fs.readFileSync( - common.fixturesDir + '/test_rsa_privkey_encrypted.pem', 'ascii'); + common.fixturesDir + '/test_rsa_privkey_encrypted.pem', 'ascii'); var dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem', 'ascii'); var dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem', 'ascii'); var dsaKeyPemEncrypted = fs.readFileSync( - common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii'); + common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii'); // TODO(indunty): move to a separate test eventually @@ -83,19 +83,19 @@ assert.throws(function() { // PFX tests assert.doesNotThrow(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'sample'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'sample'}); }); assert.throws(function() { - tls.createSecureContext({pfx:certPfx}); + tls.createSecureContext({pfx: certPfx}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'test'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'test'}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:'sample', passphrase:'test'}); + tls.createSecureContext({pfx: 'sample', passphrase: 'test'}); }, 'not enough data'); // Test HMAC @@ -146,8 +146,8 @@ var wikipedia = [ 'b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c71214' + '4292c5ad' } - }, -] + } +]; for (var i = 0, l = wikipedia.length; i < l; i++) { for (var hash in wikipedia[i]['hmac']) { @@ -485,15 +485,15 @@ assert.equal(a1, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca' + assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', 'Test SHA256 as base64'); assert.deepEqual( - a3, - new Buffer( + a3, + new Buffer( '\u00c1(4\u00f1\u0003\u001fd\u0097!O\'\u00d4C/&Qz\u00d4' + '\u0094\u0015l\u00b8\u008dQ+\u00db\u001d\u00c4\u00b5}\u00b2' + '\u00d6\u0092\u00a3\u00df\u00a2i\u00a1\u009b\n\n*\u000f' + '\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' + '\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'', 'binary'), - 'Test SHA512 as assumed buffer'); + 'Test SHA512 as assumed buffer'); assert.deepEqual(a4, new Buffer('8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'hex'), 'Test SHA1'); diff --git a/test/simple/test-debug-cluster.js b/test/simple/test-debug-cluster.js index c0963c35a976..cb6879a935fd 100644 --- a/test/simple/test-debug-cluster.js +++ b/test/simple/test-debug-cluster.js @@ -23,7 +23,7 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; -var args = ['--debug', common.fixturesDir + '/clustered-server/app.js' ]; +var args = ['--debug', common.fixturesDir + '/clustered-server/app.js']; var child = spawn(process.execPath, args); var outputLines = []; @@ -31,7 +31,7 @@ child.stderr.on('data', function(data) { var lines = data.toString().replace(/\r/g, '').trim().split('\n'); var line = lines[0]; - lines.forEach(function(ln) { console.log('> ' + ln) } ); + lines.forEach(function(ln) { console.log('> ' + ln) }); if (line === 'all workers are running') { assertOutputLines(); @@ -49,7 +49,7 @@ var assertOutputLines = common.mustCall(function() { var expectedLines = [ 'Debugger listening on port ' + 5858, 'Debugger listening on port ' + 5859, - 'Debugger listening on port ' + 5860, + 'Debugger listening on port ' + 5860 ]; // Do not assume any particular order of output messages, @@ -57,7 +57,7 @@ var assertOutputLines = common.mustCall(function() { // start up outputLines.sort(); - assert.equal(outputLines.length, expectedLines.length) + assert.equal(outputLines.length, expectedLines.length); for (var i = 0; i < expectedLines.length; i++) assert.equal(outputLines[i], expectedLines[i]); }); diff --git a/test/simple/test-debug-port-cluster.js b/test/simple/test-debug-port-cluster.js index 34ae3a02938f..32d409031c2b 100644 --- a/test/simple/test-debug-port-cluster.js +++ b/test/simple/test-debug-port-cluster.js @@ -37,7 +37,7 @@ child.stderr.on('data', function(data) { var lines = data.toString().replace(/\r/g, '').trim().split('\n'); var line = lines[0]; - lines.forEach(function(ln) { console.log('> ' + ln) } ); + lines.forEach(function(ln) { console.log('> ' + ln) }); if (line === 'all workers are running') { assertOutputLines(); @@ -54,8 +54,8 @@ process.on('exit', function onExit() { var assertOutputLines = common.mustCall(function() { var expectedLines = [ 'Debugger listening on port ' + port, - 'Debugger listening on port ' + (port+1), - 'Debugger listening on port ' + (port+2), + 'Debugger listening on port ' + (port + 1), + 'Debugger listening on port ' + (port + 2) ]; // Do not assume any particular order of output messages, @@ -63,7 +63,7 @@ var assertOutputLines = common.mustCall(function() { // start up outputLines.sort(); - assert.equal(outputLines.length, expectedLines.length) + assert.equal(outputLines.length, expectedLines.length); for (var i = 0; i < expectedLines.length; i++) assert.equal(outputLines[i], expectedLines[i]); }); diff --git a/test/simple/test-debug-signal-cluster.js b/test/simple/test-debug-signal-cluster.js index 9e6edb803f64..05a3db6dbf4d 100644 --- a/test/simple/test-debug-signal-cluster.js +++ b/test/simple/test-debug-signal-cluster.js @@ -23,9 +23,9 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; -var args = [ common.fixturesDir + '/clustered-server/app.js' ]; +var args = [common.fixturesDir + '/clustered-server/app.js']; var child = spawn(process.execPath, args, { - stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ] + stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }); var outputLines = []; var outputTimerId; @@ -84,7 +84,7 @@ var expectedLines = [ 'Starting debugger agent.', 'Debugger listening on port ' + 5859, 'Starting debugger agent.', - 'Debugger listening on port ' + 5860, + 'Debugger listening on port ' + 5860 ]; function assertOutputLines() { diff --git a/test/simple/test-deprecation-flags.js b/test/simple/test-deprecation-flags.js index 3d50c097f687..1b7296ae22d3 100644 --- a/test/simple/test-deprecation-flags.js +++ b/test/simple/test-deprecation-flags.js @@ -33,7 +33,8 @@ execFile(node, normal, function(er, stdout, stderr) { console.error('normal: show deprecation warning'); assert.equal(er, null); assert.equal(stdout, ''); - assert.equal(stderr, 'util.p: Use console.error() instead\n\'This is deprecated\'\n'); + assert.equal(stderr, + 'util.p: Use console.error() instead\n\'This is deprecated\'\n'); console.log('normal ok'); }); diff --git a/test/simple/test-dgram-bind.js b/test/simple/test-dgram-bind.js index 8ee67637fcb6..0f9fa1b7b0ac 100644 --- a/test/simple/test-dgram-bind.js +++ b/test/simple/test-dgram-bind.js @@ -25,7 +25,7 @@ var dgram = require('dgram'); var socket = dgram.createSocket('udp4'); -socket.on('listening', function () { +socket.on('listening', function() { socket.close(); }); diff --git a/test/simple/test-dgram-broadcast-multi-process.js b/test/simple/test-dgram-broadcast-multi-process.js index 4d9eebc1012d..db4c606a96f8 100644 --- a/test/simple/test-dgram-broadcast-multi-process.js +++ b/test/simple/test-dgram-broadcast-multi-process.js @@ -38,7 +38,7 @@ var common = require('../common'), // take the first non-internal interface as the address for binding get_bindAddress: for (var name in networkInterfaces) { var interfaces = networkInterfaces[name]; - for(var i = 0; i < interfaces.length; i++) { + for (var i = 0; i < interfaces.length; i++) { var localInterface = interfaces[i]; if (!localInterface.internal && localInterface.family === 'IPv4') { var bindAddress = localInterface.address; @@ -165,7 +165,7 @@ if (process.argv[2] !== 'child') { // bind the address explicitly for sending // INADDR_BROADCAST to only one interface sendSocket.bind(common.PORT, bindAddress); - sendSocket.on('listening', function () { + sendSocket.on('listening', function() { sendSocket.setBroadcast(true); }); diff --git a/test/simple/test-dgram-bytes-length.js b/test/simple/test-dgram-bytes-length.js index 4e90f78c809b..587a8950295f 100644 --- a/test/simple/test-dgram-bytes-length.js +++ b/test/simple/test-dgram-bytes-length.js @@ -25,7 +25,8 @@ var dgram = require('dgram'); var message = new Buffer('Some bytes'); var client = dgram.createSocket('udp4'); -client.send(message, 0, message.length, 41234, "localhost", function(err, bytes) { - assert.strictEqual(bytes, message.length); - client.close(); -}); +client.send(message, 0, message.length, 41234, 'localhost', + function(err, bytes) { + assert.strictEqual(bytes, message.length); + client.close(); + }); diff --git a/test/simple/test-dgram-empty-packet.js b/test/simple/test-dgram-empty-packet.js index 812e88a3b779..4807c8e65276 100644 --- a/test/simple/test-dgram-empty-packet.js +++ b/test/simple/test-dgram-empty-packet.js @@ -44,15 +44,15 @@ function callback() { clearTimeout(timer); client.close(); } else if (callbacks > 2) { - throw new Error("the callbacks should be called only two times"); + throw new Error('the callbacks should be called only two times'); } } -client.on('message', function (buffer, bytes) { +client.on('message', function(buffer, bytes) { callback(); }); -client.send(new Buffer(1), 0, 0, common.PORT, "127.0.0.1", function (err, len) { +client.send(new Buffer(1), 0, 0, common.PORT, '127.0.0.1', function(err, len) { callback(); }); diff --git a/test/simple/test-dgram-listen-after-bind.js b/test/simple/test-dgram-listen-after-bind.js index e5f1c4d653f0..a6e3e50e433d 100644 --- a/test/simple/test-dgram-listen-after-bind.js +++ b/test/simple/test-dgram-listen-after-bind.js @@ -28,16 +28,16 @@ var socket = dgram.createSocket('udp4'); socket.bind(); var fired = false; -var timer = setTimeout(function () { +var timer = setTimeout(function() { socket.close(); }, 100); -socket.on('listening', function () { +socket.on('listening', function() { clearTimeout(timer); fired = true; socket.close(); }); -socket.on('close', function () { +socket.on('close', function() { assert(fired, 'listening should fire after bind'); }); diff --git a/test/simple/test-dgram-multicast-setTTL.js b/test/simple/test-dgram-multicast-setTTL.js index 2ef0c167a883..23c35330e8e0 100644 --- a/test/simple/test-dgram-multicast-setTTL.js +++ b/test/simple/test-dgram-multicast-setTTL.js @@ -26,7 +26,7 @@ var common = require('../common'), socket = dgram.createSocket('udp4'); socket.bind(common.PORT); -socket.on('listening', function () { +socket.on('listening', function() { socket.setMulticastTTL(16); //Try to set an invalid TTL (valid ttl is > 0 and < 256) diff --git a/test/simple/test-dgram-oob-buffer.js b/test/simple/test-dgram-oob-buffer.js index 061c8417cdcb..66cbda207514 100644 --- a/test/simple/test-dgram-oob-buffer.js +++ b/test/simple/test-dgram-oob-buffer.js @@ -28,7 +28,7 @@ var assert = require('assert'); var dgram = require('dgram'); var socket = dgram.createSocket('udp4'); -var buf = Buffer([1,2,3,4]); +var buf = Buffer([1, 2, 3, 4]); function ok() {} socket.send(buf, 0, 0, common.PORT, '127.0.0.1', ok); // useful? no diff --git a/test/simple/test-dgram-send-bad-arguments.js b/test/simple/test-dgram-send-bad-arguments.js index a9a12d458153..881ecc2575ed 100644 --- a/test/simple/test-dgram-send-bad-arguments.js +++ b/test/simple/test-dgram-send-bad-arguments.js @@ -31,10 +31,10 @@ assert.throws(function() { sock.send(); }, TypeError); // First argument should be a buffer. -assert.throws(function() { sock.send(buf, -1, 1, 1, host); }, RangeError); -assert.throws(function() { sock.send(buf, 1, -1, 1, host); }, RangeError); -assert.throws(function() { sock.send(buf, 1, 1, -1, host); }, RangeError); -assert.throws(function() { sock.send(buf, 5, 1, 1, host); }, RangeError); -assert.throws(function() { sock.send(buf, 1, 5, 1, host); }, RangeError); -assert.throws(function() { sock.send(buf, 1, 1, 0, host); }, RangeError); +assert.throws(function() { sock.send(buf, -1, 1, 1, host); }, RangeError); +assert.throws(function() { sock.send(buf, 1, -1, 1, host); }, RangeError); +assert.throws(function() { sock.send(buf, 1, 1, -1, host); }, RangeError); +assert.throws(function() { sock.send(buf, 5, 1, 1, host); }, RangeError); +assert.throws(function() { sock.send(buf, 1, 5, 1, host); }, RangeError); +assert.throws(function() { sock.send(buf, 1, 1, 0, host); }, RangeError); assert.throws(function() { sock.send(buf, 1, 1, 65536, host); }, RangeError); diff --git a/test/simple/test-dgram-send-callback-buffer-length.js b/test/simple/test-dgram-send-callback-buffer-length.js index c3b7d5ccc9e4..bf79d3209e6a 100644 --- a/test/simple/test-dgram-send-callback-buffer-length.js +++ b/test/simple/test-dgram-send-callback-buffer-length.js @@ -37,11 +37,11 @@ offset = 20; len = buf.length - offset; -client.send(buf, offset, len, common.PORT, "127.0.0.1", function (err, bytes) { - assert.notEqual(bytes, buf.length); - assert.equal(bytes, buf.length - offset); - clearTimeout(timer); - client.close(); +client.send(buf, offset, len, common.PORT, '127.0.0.1', function(err, bytes) { + assert.notEqual(bytes, buf.length); + assert.equal(bytes, buf.length - offset); + clearTimeout(timer); + client.close(); }); timer = setTimeout(function() { diff --git a/test/simple/test-dgram-send-empty-buffer.js b/test/simple/test-dgram-send-empty-buffer.js index 4eb0ab4fc3f1..84283af76791 100644 --- a/test/simple/test-dgram-send-empty-buffer.js +++ b/test/simple/test-dgram-send-empty-buffer.js @@ -38,13 +38,13 @@ client = dgram.createSocket('udp4'); client.bind(common.PORT); -client.on('message', function (buffer, bytes) { +client.on('message', function(buffer, bytes) { clearTimeout(timer); client.close(); }); buf = new Buffer(0); -client.send(buf, 0, 0, common.PORT, "127.0.0.1", function (err, len) { }); +client.send(buf, 0, 0, common.PORT, '127.0.0.1', function(err, len) { }); timer = setTimeout(function() { throw new Error('Timeout'); diff --git a/test/simple/test-dh-padding.js b/test/simple/test-dh-padding.js index 753c0eb81955..09cc778a88f2 100644 --- a/test/simple/test-dh-padding.js +++ b/test/simple/test-dh-padding.js @@ -41,6 +41,6 @@ p.setPublicKey(apub, 'hex'); p.setPrivateKey(apriv, 'hex'); assert.equal( - p.computeSecret(bpub, 'hex', 'hex'), - '0025616eed33f1af7975bbd0a8071d98a014f538b243bef90d76c08e81a0b3c5' + p.computeSecret(bpub, 'hex', 'hex'), + '0025616eed33f1af7975bbd0a8071d98a014f538b243bef90d76c08e81a0b3c5' ); diff --git a/test/simple/test-dns-cares-domains.js b/test/simple/test-dns-cares-domains.js index 8581ed64db2b..2da839cdde12 100644 --- a/test/simple/test-dns-cares-domains.js +++ b/test/simple/test-dns-cares-domains.js @@ -34,13 +34,13 @@ var methods = [ 'resolveSrv', 'resolveNaptr', 'resolveSoa' -] +]; methods.forEach(function(method) { var d = domain.create(); d.run(function() { dns[method]('google.com', function() { - assert.strictEqual(process.domain, d, method + ' retains domain') + assert.strictEqual(process.domain, d, method + ' retains domain'); }); }); }); diff --git a/test/simple/test-dns-regress-7070.js b/test/simple/test-dns-regress-7070.js index 9aca4f728d50..2dd135654342 100644 --- a/test/simple/test-dns-regress-7070.js +++ b/test/simple/test-dns-regress-7070.js @@ -24,5 +24,5 @@ var assert = require('assert'); var dns = require('dns'); // Should not raise assertion error. Issue #7070 -assert.throws(function () { dns.resolveNs([]); }); // bad name -assert.throws(function () { dns.resolveNs(''); }); // bad callback +assert.throws(function() { dns.resolveNs([]); }); // bad name +assert.throws(function() { dns.resolveNs(''); }); // bad callback diff --git a/test/simple/test-dns.js b/test/simple/test-dns.js index 405bcf0a089f..2243de99d231 100644 --- a/test/simple/test-dns.js +++ b/test/simple/test-dns.js @@ -31,18 +31,18 @@ function noop() {} var goog = [ '8.8.8.8', - '8.8.4.4', + '8.8.4.4' ]; -assert.doesNotThrow(function () { dns.setServers(goog) }); +assert.doesNotThrow(function() { dns.setServers(goog) }); assert.deepEqual(dns.getServers(), goog); -assert.throws(function () { dns.setServers(['foobar']) }); +assert.throws(function() { dns.setServers(['foobar']) }); assert.deepEqual(dns.getServers(), goog); var goog6 = [ '2001:4860:4860::8888', - '2001:4860:4860::8844', + '2001:4860:4860::8844' ]; -assert.doesNotThrow(function () { dns.setServers(goog6) }); +assert.doesNotThrow(function() { dns.setServers(goog6) }); assert.deepEqual(dns.getServers(), goog6); goog6.push('4.4.4.4'); @@ -51,16 +51,16 @@ assert.deepEqual(dns.getServers(), goog6); var ports = [ '4.4.4.4:53', - '[2001:4860:4860::8888]:53', + '[2001:4860:4860::8888]:53' ]; var portsExpected = [ '4.4.4.4', - '2001:4860:4860::8888', + '2001:4860:4860::8888' ]; dns.setServers(ports); assert.deepEqual(dns.getServers(), portsExpected); -assert.doesNotThrow(function () { dns.setServers([]); }); +assert.doesNotThrow(function() { dns.setServers([]); }); assert.deepEqual(dns.getServers(), []); assert.throws(function() { @@ -121,7 +121,7 @@ assert.doesNotThrow(function() { */ assert.throws(function() { dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 }, - noop); + noop); }); assert.throws(function() { diff --git a/test/simple/test-domain-enter-exit.js b/test/simple/test-domain-enter-exit.js index 7d248ea15f84..728667891bd3 100644 --- a/test/simple/test-domain-enter-exit.js +++ b/test/simple/test-domain-enter-exit.js @@ -27,7 +27,7 @@ var domain = require('domain'); function names(array) { return array.map(function(d) { - return d.name + return d.name; }).join(', '); } diff --git a/test/simple/test-domain-exit-dispose-again.js b/test/simple/test-domain-exit-dispose-again.js index 22928f260451..f693dddff2ca 100644 --- a/test/simple/test-domain-exit-dispose-again.js +++ b/test/simple/test-domain-exit-dispose-again.js @@ -27,7 +27,7 @@ var disposalFailed = false; // no matter what happens, we should increment a 10 times. var a = 0; log(); -function log(){ +function log() { console.log(a++, process.domain); if (a < 10) setTimeout(log, 20); } @@ -37,7 +37,7 @@ var secondTimerRan = false; // in 50ms we'll throw an error. setTimeout(err, 50); setTimeout(secondTimer, 50); -function err(){ +function err() { var d = domain.create(); d.on('error', handle); d.run(err2); diff --git a/test/simple/test-domain-exit-dispose.js b/test/simple/test-domain-exit-dispose.js index fd990911c169..6a4185fa9b9c 100644 --- a/test/simple/test-domain-exit-dispose.js +++ b/test/simple/test-domain-exit-dispose.js @@ -27,14 +27,14 @@ var disposalFailed = false; // no matter what happens, we should increment a 10 times. var a = 0; log(); -function log(){ +function log() { console.log(a++, process.domain); if (a < 10) setTimeout(log, 20); } // in 50ms we'll throw an error. setTimeout(err, 50); -function err(){ +function err() { var d = domain.create(); d.on('error', handle); d.run(err2); diff --git a/test/simple/test-domain-from-timer.js b/test/simple/test-domain-from-timer.js index 3e73a5c4b89e..f30fe9b384fb 100644 --- a/test/simple/test-domain-from-timer.js +++ b/test/simple/test-domain-from-timer.js @@ -32,7 +32,7 @@ setTimeout(function() { var d = domain.create(); d.run(function() { process.nextTick(function() { - console.trace('in nexttick', process.domain === d) + console.trace('in nexttick', process.domain === d); assert.equal(process.domain, d); }); }); diff --git a/test/simple/test-domain-http-server.js b/test/simple/test-domain-http-server.js index 57e8ac4d14a3..04fa940d7312 100644 --- a/test/simple/test-domain-http-server.js +++ b/test/simple/test-domain-http-server.js @@ -24,7 +24,7 @@ var http = require('http'); var assert = require('assert'); var common = require('../common.js'); -var objects = { foo: 'bar', baz: {}, num: 42, arr: [1,2,3] }; +var objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] }; objects.baz.asdf = objects; var serverCaught = 0; @@ -41,7 +41,7 @@ var server = http.createServer(function(req, res) { serverCaught++; console.log('horray! got a server error', er); // try to send a 500. If that fails, oh well. - res.writeHead(500, {'content-type':'text/plain'}); + res.writeHead(500, {'content-type': 'text/plain'}); res.end(er.stack || er.message || 'Unknown error'); }); diff --git a/test/simple/test-domain-multi.js b/test/simple/test-domain-multi.js index 68e4b11a6474..386994de5776 100644 --- a/test/simple/test-domain-multi.js +++ b/test/simple/test-domain-multi.js @@ -42,7 +42,7 @@ a.on('error', function(er) { var http = require('http'); -var server = http.createServer(function (req, res) { +var server = http.createServer(function(req, res) { // child domain of a. var b = domain.create(); a.add(b); @@ -53,9 +53,9 @@ var server = http.createServer(function (req, res) { b.add(req); b.add(res); - b.on('error', function (er) { + b.on('error', function(er) { caughtB = true; - console.error('Error encountered', er) + console.error('Error encountered', er); if (res) { res.writeHead(500); res.end('An error occurred'); @@ -74,7 +74,7 @@ var server = http.createServer(function (req, res) { }).listen(common.PORT); var c = domain.create(); -var req = http.get({ host: 'localhost', port: common.PORT }) +var req = http.get({ host: 'localhost', port: common.PORT }); // add the request to the C domain c.add(req); @@ -93,7 +93,7 @@ c.on('error', function(er) { process.on('exit', function() { assert.equal(caughtA, false); - assert.equal(caughtB, true) - assert.equal(caughtC, true) + assert.equal(caughtB, true); + assert.equal(caughtC, true); console.log('ok - Errors went where they were supposed to go'); }); diff --git a/test/simple/test-domain-nested-throw.js b/test/simple/test-domain-nested-throw.js index e11948667532..75be5b829d56 100644 --- a/test/simple/test-domain-nested-throw.js +++ b/test/simple/test-domain-nested-throw.js @@ -71,7 +71,7 @@ function throw2() { function inner(throw1, throw2) { var domain1 = domain.createDomain(); - domain1.on('error', function (err) { + domain1.on('error', function(err) { if (gotDomain1Error) { console.error('got domain 1 twice'); process.exit(1); @@ -81,7 +81,7 @@ function inner(throw1, throw2) { throw2(); }); - domain1.run(function () { + domain1.run(function() { throw1(); }); } @@ -89,7 +89,7 @@ function inner(throw1, throw2) { function outer() { var domain2 = domain.createDomain(); - domain2.on('error', function (err) { + domain2.on('error', function(err) { if (gotDomain2Error) { console.error('got domain 2 twice'); process.exit(1); @@ -97,7 +97,7 @@ function outer() { gotDomain2Error = true; }); - domain2.run(function () { + domain2.run(function() { inner(throw1, throw2); }); } diff --git a/test/simple/test-domain-nested.js b/test/simple/test-domain-nested.js index efd672b25f94..69c12ccc9311 100644 --- a/test/simple/test-domain-nested.js +++ b/test/simple/test-domain-nested.js @@ -32,11 +32,11 @@ process.on('exit', function(c) { domain.create().run(function() { domain.create().run(function() { domain.create().run(function() { - domain.create().on("error", function(e) { - // Don't need to do anything here + domain.create().on('error', function(e) { + // Don't need to do anything here }).run(function() { - throw new Error("died") - }) - }) - }) -}) + throw new Error('died'); + }); + }); + }); +}); diff --git a/test/simple/test-domain.js b/test/simple/test-domain.js index 25227585357f..da2133478e6f 100644 --- a/test/simple/test-domain.js +++ b/test/simple/test-domain.js @@ -37,7 +37,7 @@ d.on('error', function(er) { console.error('caught', er && (er.message || er)); var er_message = er.message; - var er_path = er.path + var er_path = er.path; // On windows, error messages can contain full path names. If this is the // case, remove the directory part. @@ -151,7 +151,7 @@ expectCaught++; // set up while in the scope of the d domain. d.run(function() { process.nextTick(function() { - var i = setInterval(function () { + var i = setInterval(function() { clearInterval(i); setTimeout(function() { fs.stat('this file does not exist', function(er, stat) { @@ -200,7 +200,7 @@ expectCaught++; // intercepted should never pass first argument to callback function fn2(data) { - assert.equal(data, 'data', 'should not be null err argument') + assert.equal(data, 'data', 'should not be null err argument'); } var bound = d.intercept(fn2); @@ -252,17 +252,17 @@ setTimeout(function() { expectCaught++; -var result = d.run(function () { +var result = d.run(function() { return 'return value'; }); assert.equal(result, 'return value'); -var fst = fs.createReadStream('stream for nonexistent file') -d.add(fst) +var fst = fs.createReadStream('stream for nonexistent file'); +d.add(fst); expectCaught++; -[42, null, , false, function(){}, 'string'].forEach(function(something) { +[42, null, , false, function() {}, 'string'].forEach(function(something) { var d = new domain.Domain(); d.run(function() { process.nextTick(function() { diff --git a/test/simple/test-event-emitter-max-listeners.js b/test/simple/test-event-emitter-max-listeners.js index dfc3e1352d0e..da1587180704 100644 --- a/test/simple/test-event-emitter-max-listeners.js +++ b/test/simple/test-event-emitter-max-listeners.js @@ -47,7 +47,7 @@ assert.throws(function() { }); assert.throws(function() { - e.setMaxListeners("and even this"); + e.setMaxListeners('and even this'); }); e.emit('maxListeners'); diff --git a/test/simple/test-event-emitter-no-error-provided-to-error-event.js b/test/simple/test-event-emitter-no-error-provided-to-error-event.js index 79f14904e0ab..490953374001 100644 --- a/test/simple/test-event-emitter-no-error-provided-to-error-event.js +++ b/test/simple/test-event-emitter-no-error-provided-to-error-event.js @@ -30,13 +30,13 @@ var e = new events.EventEmitter(); var d = domain.create(); d.add(e); -d.on('error', function (er) { +d.on('error', function(er) { assert(er instanceof Error, 'error created'); errorCatched = true; }); e.emit('error'); -process.on('exit', function () { +process.on('exit', function() { assert(errorCatched, 'error got caught'); }); diff --git a/test/simple/test-event-emitter-once.js b/test/simple/test-event-emitter-once.js index 2eaebcc7a5e4..e9f8b899ef2b 100644 --- a/test/simple/test-event-emitter-once.js +++ b/test/simple/test-event-emitter-once.js @@ -50,12 +50,12 @@ process.on('exit', function() { var times_recurse_emitted = 0; e.once('e', function() { - e.emit('e'); - times_recurse_emitted++; + e.emit('e'); + times_recurse_emitted++; }); e.once('e', function() { - times_recurse_emitted++; + times_recurse_emitted++; }); e.emit('e'); diff --git a/test/simple/test-event-emitter-remove-all-listeners.js b/test/simple/test-event-emitter-remove-all-listeners.js index f9848d682314..ef1f51e446cc 100644 --- a/test/simple/test-event-emitter-remove-all-listeners.js +++ b/test/simple/test-event-emitter-remove-all-listeners.js @@ -30,7 +30,7 @@ function expect(expected) { assert.deepEqual(actual.sort(), expected.sort()); }); function listener(name) { - actual.push(name) + actual.push(name); } return common.mustCall(listener, expected.length); } diff --git a/test/simple/test-event-emitter-subclass.js b/test/simple/test-event-emitter-subclass.js index 60b4bf387d69..bcc35f2e5b5c 100644 --- a/test/simple/test-event-emitter-subclass.js +++ b/test/simple/test-event-emitter-subclass.js @@ -64,6 +64,6 @@ MyEE2.prototype = new EventEmitter(); var ee1 = new MyEE2(); var ee2 = new MyEE2(); -ee1.on('x', function () {}); +ee1.on('x', function() {}); assert.equal(EventEmitter.listenerCount(ee2, 'x'), 0); diff --git a/test/simple/test-file-write-stream.js b/test/simple/test-file-write-stream.js index d4d146a84a8c..a9177bd40712 100644 --- a/test/simple/test-file-write-stream.js +++ b/test/simple/test-file-write-stream.js @@ -26,16 +26,16 @@ var path = require('path'); var fs = require('fs'); var fn = path.join(common.tmpDir, 'write.txt'); var file = fs.createWriteStream(fn, { - highWaterMark: 10 - }); + highWaterMark: 10 +}); var EXPECTED = '012345678910'; var callbacks = { - open: -1, - drain: -2, - close: -1 - }; + open: -1, + drain: -2, + close: -1 +}; file .on('open', function(fd) { diff --git a/test/simple/test-fs-access.js b/test/simple/test-fs-access.js index 4bc1028dcf57..f0691359639e 100644 --- a/test/simple/test-fs-access.js +++ b/test/simple/test-fs-access.js @@ -33,13 +33,13 @@ function removeFile(file) { } catch (err) { // Ignore error } -}; +} function createFileWithPerms(file, mode) { removeFile(file); fs.writeFileSync(file, ''); fs.chmodSync(file, mode); -}; +} createFileWithPerms(readOnlyFile, 0444); createFileWithPerms(readWriteFile, 0666); @@ -136,7 +136,7 @@ assert.doesNotThrow(function() { assert.throws(function() { fs.accessSync(doesNotExist); -}, function (err) { +}, function(err) { return err.code === 'ENOENT' && err.path === doesNotExist; }); diff --git a/test/simple/test-fs-empty-readStream.js b/test/simple/test-fs-empty-readStream.js index d181c219820a..864ed45ef2ab 100644 --- a/test/simple/test-fs-empty-readStream.js +++ b/test/simple/test-fs-empty-readStream.js @@ -26,43 +26,43 @@ var fs = require('fs'); var emptyFile = path.join(common.fixturesDir, 'empty.txt'); -fs.open(emptyFile, 'r', function (error, fd) { +fs.open(emptyFile, 'r', function(error, fd) { assert.ifError(error); var read = fs.createReadStream(emptyFile, { 'fd': fd }); - read.once('data', function () { + read.once('data', function() { throw new Error('data event should not emit'); }); var readEmit = false; - read.once('end', function () { + read.once('end', function() { readEmit = true; console.error('end event 1'); }); - setTimeout(function () { + setTimeout(function() { assert.equal(readEmit, true); }, 50); }); -fs.open(emptyFile, 'r', function (error, fd) { +fs.open(emptyFile, 'r', function(error, fd) { assert.ifError(error); var read = fs.createReadStream(emptyFile, { 'fd': fd }); read.pause(); - read.once('data', function () { + read.once('data', function() { throw new Error('data event should not emit'); }); var readEmit = false; - read.once('end', function () { + read.once('end', function() { readEmit = true; console.error('end event 2'); }); - setTimeout(function () { + setTimeout(function() { assert.equal(readEmit, false); }, 50); }); diff --git a/test/simple/test-fs-non-number-arguments-throw.js b/test/simple/test-fs-non-number-arguments-throw.js index 7a1e7bdb5285..846c9860f2e4 100644 --- a/test/simple/test-fs-non-number-arguments-throw.js +++ b/test/simple/test-fs-non-number-arguments-throw.js @@ -5,19 +5,19 @@ var assert = require('assert'), saneEmitter = fs.createReadStream(__filename, { start: 17, end: 29 }); -assert.throws(function () { - fs.createReadStream(__filename, { start: "17", end: 29 }); +assert.throws(function() { + fs.createReadStream(__filename, { start: '17', end: 29 }); }, "start as string didn't throw an error for createReadStream"); -assert.throws(function () { - fs.createReadStream(__filename, { start: 17, end: "29" }); +assert.throws(function() { + fs.createReadStream(__filename, { start: 17, end: '29' }); }, "end as string didn't throw an error"); -assert.throws(function () { - fs.createWriteStream(__filename, { start: "17" }); +assert.throws(function() { + fs.createWriteStream(__filename, { start: '17' }); }, "start as string didn't throw an error for createWriteStream"); -saneEmitter.on('data', function (data) { +saneEmitter.on('data', function(data) { // a sanity check when using numbers instead of strings assert.strictEqual(sanity, data.toString('utf8'), 'read ' + data.toString('utf8') + ' instead of ' + sanity); diff --git a/test/simple/test-fs-null-bytes.js b/test/simple/test-fs-null-bytes.js index 5dec223ba875..f2baaabd7b98 100644 --- a/test/simple/test-fs-null-bytes.js +++ b/test/simple/test-fs-null-bytes.js @@ -40,31 +40,31 @@ function check(async, sync) { async.apply(null, argsAsync); } -check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar'); -check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644'); -check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34); -check(fs.link, fs.linkSync, 'foo\u0000bar', 'foobar'); -check(fs.link, fs.linkSync, 'foobar', 'foo\u0000bar'); -check(fs.lstat, fs.lstatSync, 'foo\u0000bar'); -check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755'); -check(fs.open, fs.openSync, 'foo\u0000bar', 'r'); -check(fs.readFile, fs.readFileSync, 'foo\u0000bar'); -check(fs.readdir, fs.readdirSync, 'foo\u0000bar'); -check(fs.readlink, fs.readlinkSync, 'foo\u0000bar'); -check(fs.realpath, fs.realpathSync, 'foo\u0000bar'); -check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar'); -check(fs.rename, fs.renameSync, 'foobar', 'foo\u0000bar'); -check(fs.rmdir, fs.rmdirSync, 'foo\u0000bar'); -check(fs.stat, fs.statSync, 'foo\u0000bar'); -check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar'); -check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar'); -check(fs.truncate, fs.truncateSync, 'foo\u0000bar'); -check(fs.unlink, fs.unlinkSync, 'foo\u0000bar'); -check(null, fs.unwatchFile, 'foo\u0000bar', assert.fail); -check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0); -check(null, fs.watch, 'foo\u0000bar', assert.fail); -check(null, fs.watchFile, 'foo\u0000bar', assert.fail); -check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar'); +check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar'); +check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644'); +check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34); +check(fs.link, fs.linkSync, 'foo\u0000bar', 'foobar'); +check(fs.link, fs.linkSync, 'foobar', 'foo\u0000bar'); +check(fs.lstat, fs.lstatSync, 'foo\u0000bar'); +check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755'); +check(fs.open, fs.openSync, 'foo\u0000bar', 'r'); +check(fs.readFile, fs.readFileSync, 'foo\u0000bar'); +check(fs.readdir, fs.readdirSync, 'foo\u0000bar'); +check(fs.readlink, fs.readlinkSync, 'foo\u0000bar'); +check(fs.realpath, fs.realpathSync, 'foo\u0000bar'); +check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar'); +check(fs.rename, fs.renameSync, 'foobar', 'foo\u0000bar'); +check(fs.rmdir, fs.rmdirSync, 'foo\u0000bar'); +check(fs.stat, fs.statSync, 'foo\u0000bar'); +check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar'); +check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar'); +check(fs.truncate, fs.truncateSync, 'foo\u0000bar'); +check(fs.unlink, fs.unlinkSync, 'foo\u0000bar'); +check(null, fs.unwatchFile, 'foo\u0000bar', assert.fail); +check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0); +check(null, fs.watch, 'foo\u0000bar', assert.fail); +check(null, fs.watchFile, 'foo\u0000bar', assert.fail); +check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar'); // an 'error' for exists means that it doesn't exist. // one of many reasons why this file is the absolute worst. diff --git a/test/simple/test-fs-read-stream-resume.js b/test/simple/test-fs-read-stream-resume.js index c3ace49e9ffc..3b8e35261881 100644 --- a/test/simple/test-fs-read-stream-resume.js +++ b/test/simple/test-fs-read-stream-resume.js @@ -38,7 +38,7 @@ stream.on('data', function(chunk) { stream.resume(); } }); - + process.nextTick(function() { stream.pause(); setTimeout(function() { diff --git a/test/simple/test-fs-read-stream.js b/test/simple/test-fs-read-stream.js index 4d1eebb2c178..aff5eb40c9ac 100644 --- a/test/simple/test-fs-read-stream.js +++ b/test/simple/test-fs-read-stream.js @@ -162,7 +162,7 @@ file7.on('end', function() { }); }); -function file7Next(){ +function file7Next() { // This will tell us if the fd is usable again or not. file7 = fs.createReadStream(null, {fd: file7.fd, start: 0 }); file7.data = ''; diff --git a/test/simple/test-fs-readfile-zero-byte-liar.js b/test/simple/test-fs-readfile-zero-byte-liar.js index 60f41226f1bb..abc4b305e8cf 100644 --- a/test/simple/test-fs-readfile-zero-byte-liar.js +++ b/test/simple/test-fs-readfile-zero-byte-liar.js @@ -47,12 +47,12 @@ var d = fs.readFileSync(__filename, 'utf8'); assert.equal(d, dataExpected); var called = false; -fs.readFile(__filename, 'utf8', function (er, d) { +fs.readFile(__filename, 'utf8', function(er, d) { assert.equal(d, dataExpected); called = true; }); process.on('exit', function() { assert(called); - console.log("ok"); + console.log('ok'); }); diff --git a/test/simple/test-fs-realpath.js b/test/simple/test-fs-realpath.js index 0c820907d98e..eabc9b17c3e2 100644 --- a/test/simple/test-fs-realpath.js +++ b/test/simple/test-fs-realpath.js @@ -59,7 +59,7 @@ function tmp(p) { var fixturesAbsDir = common.fixturesDir; var tmpAbsDir = common.tmpDir; -console.error("absolutes\n%s\n%s", fixturesAbsDir, tmpAbsDir); +console.error('absolutes\n%s\n%s', fixturesAbsDir, tmpAbsDir); function asynctest(testBlock, args, callback, assertBlock) { async_expected++; @@ -389,12 +389,14 @@ function test_escape_cwd(cb) { console.log('test_escape_cwd'); asynctest(fs.realpath, ['..'], cb, function(er, uponeActual) { assert.equal(upone, uponeActual, - 'realpath("..") expected: ' + path.resolve(upone) + ' actual:' + uponeActual); + 'realpath("..") expected: ' + path.resolve(upone) + + ' actual:' + uponeActual); }); } var uponeActual = fs.realpathSync('..'); assert.equal(upone, uponeActual, - 'realpathSync("..") expected: ' + path.resolve(upone) + ' actual:' + uponeActual); + 'realpathSync("..") expected: ' + path.resolve(upone) + + ' actual:' + uponeActual); // going up with .. multiple times @@ -436,10 +438,10 @@ function test_up_multiple(cb) { assert.equal(fs.realpathSync(abedabeda), abedabeda_real); assert.equal(fs.realpathSync(abedabed), abedabed_real); - fs.realpath(abedabeda, function (er, real) { + fs.realpath(abedabeda, function(er, real) { if (er) throw er; assert.equal(abedabeda_real, real); - fs.realpath(abedabed, function (er, real) { + fs.realpath(abedabed, function(er, real) { if (er) throw er; assert.equal(abedabed_real, real); cb(); @@ -522,7 +524,7 @@ function test_lying_cache_liar(cb) { if (isWindows) { var wc = {}; Object.keys(cache).forEach(function(k) { - wc[ path.resolve(k) ] = path.resolve(cache[k]); + wc[path.resolve(k)] = path.resolve(cache[k]); }); cache = wc; } diff --git a/test/simple/test-fs-watch-recursive.js b/test/simple/test-fs-watch-recursive.js index e421ab022276..9b5df4dbd9da 100644 --- a/test/simple/test-fs-watch-recursive.js +++ b/test/simple/test-fs-watch-recursive.js @@ -42,7 +42,7 @@ if (process.platform === 'darwin') { function cleanup() { try { fs.unlinkSync(filepathOne); } catch (e) { } try { fs.rmdirSync(testsubdir); } catch (e) { } - }; + } try { fs.mkdirSync(testsubdir, 0700); } catch (e) {} diff --git a/test/simple/test-fs-watch.js b/test/simple/test-fs-watch.js index 470736d594ff..1f770e8f2c89 100644 --- a/test/simple/test-fs-watch.js +++ b/test/simple/test-fs-watch.js @@ -62,7 +62,7 @@ fs.writeFileSync(filepathOne, 'hello'); assert.doesNotThrow( function() { - var watcher = fs.watch(filepathOne) + var watcher = fs.watch(filepathOne); watcher.on('change', function(event, filename) { assert.equal('change', event); @@ -144,7 +144,7 @@ assert.throws(function() { oldhandle.close(); // clean up assert.throws(function() { - var w = fs.watchFile(__filename, {persistent:false}, function(){}); + var w = fs.watchFile(__filename, {persistent: false}, function() {}); oldhandle = w._handle; w._handle = { stop: w._handle.stop }; w.stop(); diff --git a/test/simple/test-fs-write-stream-change-open.js b/test/simple/test-fs-write-stream-change-open.js index d025e8da35ae..e7b7ef4440a4 100644 --- a/test/simple/test-fs-write-stream-change-open.js +++ b/test/simple/test-fs-write-stream-change-open.js @@ -42,7 +42,7 @@ fs.close = function(fd) { assert.ok(fd, 'fs.close must not be called with an undefined fd.'); fs.close = _fs_close; fs.open = _fs_open; -} +}; stream.write('foo'); stream.end(); diff --git a/test/simple/test-http-1.0-keep-alive.js b/test/simple/test-http-1.0-keep-alive.js index 851409d28bbf..e69be9bcfe45 100644 --- a/test/simple/test-http-1.0-keep-alive.js +++ b/test/simple/test-http-1.0-keep-alive.js @@ -30,13 +30,13 @@ check([{ requests: [{ expectClose: true, data: 'POST / HTTP/1.0\r\n' + - 'Connection: keep-alive\r\n' + - '\r\n' + 'Connection: keep-alive\r\n' + + '\r\n' }, { expectClose: true, data: 'POST / HTTP/1.0\r\n' + - 'Connection: keep-alive\r\n' + - '\r\n' + 'Connection: keep-alive\r\n' + + '\r\n' }], responses: [{ headers: {'Connection': 'keep-alive'}, @@ -49,13 +49,13 @@ check([{ requests: [{ expectClose: false, data: 'POST / HTTP/1.0\r\n' + - 'Connection: keep-alive\r\n' + - 'TE: chunked\r\n' + - '\r\n' + 'Connection: keep-alive\r\n' + + 'TE: chunked\r\n' + + '\r\n' }, { expectClose: true, data: 'POST / HTTP/1.0\r\n' + - '\r\n' + '\r\n' }], responses: [{ headers: {'Connection': 'keep-alive'}, @@ -68,16 +68,16 @@ check([{ requests: [{ expectClose: false, data: 'POST / HTTP/1.0\r\n' + - 'Connection: keep-alive\r\n' + - '\r\n' + 'Connection: keep-alive\r\n' + + '\r\n' }, { expectClose: true, data: 'POST / HTTP/1.0\r\n' + - '\r\n' + '\r\n' }], responses: [{ headers: {'Connection': 'keep-alive', - 'Transfer-Encoding': 'chunked'}, + 'Transfer-Encoding': 'chunked'}, chunks: ['OK'] }, { chunks: [] @@ -87,16 +87,16 @@ check([{ requests: [{ expectClose: false, data: 'POST / HTTP/1.0\r\n' + - 'Connection: keep-alive\r\n' + - '\r\n' + 'Connection: keep-alive\r\n' + + '\r\n' }, { expectClose: true, data: 'POST / HTTP/1.0\r\n' + - '\r\n' + '\r\n' }], responses: [{ headers: {'Connection': 'keep-alive', - 'Content-Length': '2'}, + 'Content-Length': '2'}, chunks: ['OK'] }, { chunks: [] @@ -143,7 +143,7 @@ function check(tests) { current++; if (ctx.expectClose) return; conn.removeListener('close', onclose); - conn.removeListener('data', ondata);; + conn.removeListener('data', ondata); connected(); } conn.on('data', ondata); diff --git a/test/simple/test-http-abort-client.js b/test/simple/test-http-abort-client.js index f15238af1601..51c1a3e9c692 100644 --- a/test/simple/test-http-abort-client.js +++ b/test/simple/test-http-abort-client.js @@ -59,7 +59,7 @@ server.listen(common.PORT, function() { res.socket.on('close', function() { console.log('socket closed, but not res'); - }) + }); // it would be nice if this worked: res.on('close', function() { diff --git a/test/simple/test-http-abort-queued.js b/test/simple/test-http-abort-queued.js index d3ec5a14d5c4..ae2410d1c93d 100644 --- a/test/simple/test-http-abort-queued.js +++ b/test/simple/test-http-abort-queued.js @@ -24,7 +24,7 @@ var assert = require('assert'), var complete; -var server = http.createServer(function (req, res) { +var server = http.createServer(function(req, res) { // We should not see the queued /thatotherone request within the server // as it should be aborted before it is sent. assert.equal(req.url, '/'); @@ -32,13 +32,13 @@ var server = http.createServer(function (req, res) { res.writeHead(200); res.write('foo'); - complete = complete || function () { + complete = complete || function() { res.end(); }; }); -server.listen(0, function () { +server.listen(0, function() { console.log('listen', server.address().port); var agent = new http.Agent({maxSockets: 1}); diff --git a/test/simple/test-http-agent-false.js b/test/simple/test-http-agent-false.js index d897ab603c00..c48cc22f8937 100644 --- a/test/simple/test-http-agent-false.js +++ b/test/simple/test-http-agent-false.js @@ -23,9 +23,10 @@ var common = require('../common'); var assert = require('assert'); var http = require('http'); -// sending `agent: false` when `port: null` is also passed in (i.e. the result of -// a `url.parse()` call with the default port used, 80 or 443), should not result -// in an assertion error... +// sending `agent: false` when `port: null` +//is also passed in (i.e. the result of +// a `url.parse()` call with the default port used, 80 or 443), +//should not result in an assertion error... var opts = { host: '127.0.0.1', port: null, @@ -40,8 +41,8 @@ process.on('exit', function() { }); // we just want an "error" (no local HTTP server on port 80) or "response" -// to happen (user happens ot have HTTP server running on port 80). As long as the -// process doesn't crash from a C++ assertion then we're good. +// to happen (user happens ot have HTTP server running on port 80). +//As long as the process doesn't crash from a C++ assertion then we're good. var req = http.request(opts); req.on('response', function(res) { good = true; diff --git a/test/simple/test-http-agent-keepalive.js b/test/simple/test-http-agent-keepalive.js index f56027a721ca..729085eee0ab 100644 --- a/test/simple/test-http-agent-keepalive.js +++ b/test/simple/test-http-agent-keepalive.js @@ -32,14 +32,14 @@ var agent = new Agent({ maxFreeSockets: 5 }); -var server = http.createServer(function (req, res) { +var server = http.createServer(function(req, res) { if (req.url === '/error') { res.destroy(); return; } else if (req.url === '/remote_close') { // cache the socket, close it after 100ms var socket = res.connection; - setTimeout(function () { + setTimeout(function() { socket.end(); }, 100); } @@ -65,13 +65,13 @@ function checkDataAndSockets(body) { function second() { // request second, use the same socket - get('/second', function (res) { + get('/second', function(res) { assert.equal(res.statusCode, 200); res.on('data', checkDataAndSockets); - res.on('end', function () { + res.on('end', function() { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.freeSockets[name], undefined); - process.nextTick(function () { + process.nextTick(function() { assert.equal(agent.sockets[name], undefined); assert.equal(agent.freeSockets[name].length, 1); remoteClose(); @@ -82,20 +82,20 @@ function second() { function remoteClose() { // mock remote server close the socket - get('/remote_close', function (res) { + get('/remote_close', function(res) { assert.deepEqual(res.statusCode, 200); res.on('data', checkDataAndSockets); - res.on('end', function () { + res.on('end', function() { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.freeSockets[name], undefined); - process.nextTick(function () { + process.nextTick(function() { assert.equal(agent.sockets[name], undefined); assert.equal(agent.freeSockets[name].length, 1); // waitting remote server close the socket - setTimeout(function () { + setTimeout(function() { assert.equal(agent.sockets[name], undefined); assert.equal(agent.freeSockets[name], undefined, - 'freeSockets is not empty'); + 'freeSockets is not empty'); remoteError(); }, 200); }); @@ -105,16 +105,16 @@ function remoteClose() { function remoteError() { // remove server will destroy ths socket - var req = get('/error', function (res) { + var req = get('/error', function(res) { throw new Error('should not call this function'); }); - req.on('error', function (err) { + req.on('error', function(err) { assert.ok(err); assert.equal(err.message, 'socket hang up'); assert.equal(agent.sockets[name].length, 1); assert.equal(agent.freeSockets[name], undefined); // Wait socket 'close' event emit - setTimeout(function () { + setTimeout(function() { assert.equal(agent.sockets[name], undefined); assert.equal(agent.freeSockets[name], undefined); done(); @@ -129,13 +129,13 @@ function done() { server.listen(common.PORT, function() { // request first, and keep alive - get('/first', function (res) { + get('/first', function(res) { assert.equal(res.statusCode, 200); res.on('data', checkDataAndSockets); - res.on('end', function () { + res.on('end', function() { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.freeSockets[name], undefined); - process.nextTick(function () { + process.nextTick(function() { assert.equal(agent.sockets[name], undefined); assert.equal(agent.freeSockets[name].length, 1); second(); diff --git a/test/simple/test-http-agent-no-protocol.js b/test/simple/test-http-agent-no-protocol.js index fa224c5a7c12..b5c0cedcaa15 100644 --- a/test/simple/test-http-agent-no-protocol.js +++ b/test/simple/test-http-agent-no-protocol.js @@ -42,7 +42,7 @@ var server = http.createServer(function(req, res) { opts.agent = new http.Agent(); opts.agent.protocol = null; - http.get(opts, function (res) { + http.get(opts, function(res) { response++; res.resume(); server.close(); diff --git a/test/simple/test-http-client-pipe-end.js b/test/simple/test-http-client-pipe-end.js index 51edebbe1a78..dfcca2ec4e07 100644 --- a/test/simple/test-http-client-pipe-end.js +++ b/test/simple/test-http-client-pipe-end.js @@ -37,7 +37,7 @@ var server = http.createServer(function(req, res) { server.listen(common.PIPE, function() { var req = http.request({ socketPath: common.PIPE, - headers: {'Content-Length':'1'}, + headers: {'Content-Length': '1'}, method: 'POST', path: '/' }); diff --git a/test/simple/test-http-client-response-domain.js b/test/simple/test-http-client-response-domain.js index e5a39913f410..dbf889aa2f29 100644 --- a/test/simple/test-http-client-response-domain.js +++ b/test/simple/test-http-client-response-domain.js @@ -52,7 +52,7 @@ function test() { var req = http.get({ socketPath: common.PIPE, - headers: {'Content-Length':'1'}, + headers: {'Content-Length': '1'}, method: 'POST', path: '/' }); diff --git a/test/simple/test-http-client-timeout-agent.js b/test/simple/test-http-client-timeout-agent.js index 79d0a2424243..78c4a287a238 100644 --- a/test/simple/test-http-client-timeout-agent.js +++ b/test/simple/test-http-client-timeout-agent.js @@ -29,7 +29,7 @@ var requests_done = 0; var options = { method: 'GET', port: common.PORT, - host: '127.0.0.1', + host: '127.0.0.1' }; //http.globalAgent.maxSockets = 15; @@ -37,42 +37,42 @@ var options = { var server = http.createServer(function(req, res) { var m = /\/(.*)/.exec(req.url), reqid = parseInt(m[1], 10); - if ( reqid % 2 ) { + if (reqid % 2) { // do not reply the request } else { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write(reqid.toString()); res.end(); } - request_number+=1; + request_number += 1; }); server.listen(options.port, options.host, function() { var req; - for (requests_sent = 0; requests_sent < 30; requests_sent+=1) { + for (requests_sent = 0; requests_sent < 30; requests_sent += 1) { options.path = '/' + requests_sent; req = http.request(options); req.id = requests_sent; req.on('response', function(res) { res.on('data', function(data) { - console.log('res#'+this.req.id+' data:'+data); + console.log('res#' + this.req.id + ' data:' + data); }); res.on('end', function(data) { - console.log('res#'+this.req.id+' end'); + console.log('res#' + this.req.id + ' end'); requests_done += 1; }); }); req.on('close', function() { - console.log('req#'+this.id+' close'); + console.log('req#' + this.id + ' close'); }); req.on('error', function() { - console.log('req#'+this.id+' error'); + console.log('req#' + this.id + ' error'); this.destroy(); }); - req.setTimeout(50, function () { + req.setTimeout(50, function() { var req = this; - console.log('req#'+this.id + ' timeout'); + console.log('req#' + this.id + ' timeout'); req.abort(); requests_done += 1; }); @@ -92,5 +92,6 @@ server.listen(options.port, options.host, function() { process.on('exit', function() { console.error('done=%j sent=%j', requests_done, requests_sent); - assert.ok(requests_done == requests_sent, 'timeout on http request called too much'); + assert.ok(requests_done == requests_sent, + 'timeout on http request called too much'); }); diff --git a/test/simple/test-http-client-timeout-event.js b/test/simple/test-http-client-timeout-event.js index e3e37f6993f9..79a7ddd52979 100644 --- a/test/simple/test-http-client-timeout-event.js +++ b/test/simple/test-http-client-timeout-event.js @@ -47,14 +47,14 @@ server.listen(options.port, options.host, function() { var timeout_events = 0; req.setTimeout(1); - req.on('timeout', function () { + req.on('timeout', function() { timeout_events += 1; }); - setTimeout(function () { + setTimeout(function() { req.destroy(); assert.equal(timeout_events, 1); }, 100); - setTimeout(function () { + setTimeout(function() { req.end(); }, 50); }); diff --git a/test/simple/test-http-client-timeout-with-data.js b/test/simple/test-http-client-timeout-with-data.js index 4e1aae6ff86a..ca6e7ec23bc6 100644 --- a/test/simple/test-http-client-timeout-with-data.js +++ b/test/simple/test-http-client-timeout-with-data.js @@ -39,7 +39,7 @@ var options = { }; var server = http.createServer(function(req, res) { - res.writeHead(200, {'Content-Length':'2'}); + res.writeHead(200, {'Content-Length': '2'}); res.write('*'); setTimeout(function() { res.end('*') }, 100); }); diff --git a/test/simple/test-http-createConnection.js b/test/simple/test-http-createConnection.js index bc29d9aee486..7e4333356f9f 100644 --- a/test/simple/test-http-createConnection.js +++ b/test/simple/test-http-createConnection.js @@ -35,7 +35,7 @@ var server = http.createServer(function(req, res) { res.end(); response++; }).listen(common.PORT, '127.0.0.1', function() { - http.get({ createConnection: createConnection }, function (res) { + http.get({ createConnection: createConnection }, function(res) { res.resume(); server.close(); }); diff --git a/test/simple/test-http-destroyed-socket-write2.js b/test/simple/test-http-destroyed-socket-write2.js index ebb80c9a25ba..51e3498ad43e 100644 --- a/test/simple/test-http-destroyed-socket-write2.js +++ b/test/simple/test-http-destroyed-socket-write2.js @@ -70,8 +70,8 @@ server.listen(common.PORT, function() { break; default: assert.strictEqual(er.code, - 'ECONNRESET', - 'Writing to a torn down client should RESET or ABORT'); + 'ECONNRESET', + 'Writing to a torn down client should RESET or ABORT'); break; } clearTimeout(timer); diff --git a/test/simple/test-http-end-throw-socket-handling.js b/test/simple/test-http-end-throw-socket-handling.js index 50aa97ff18e2..d3fb99cf2cc9 100644 --- a/test/simple/test-http-end-throw-socket-handling.js +++ b/test/simple/test-http-end-throw-socket-handling.js @@ -40,8 +40,8 @@ server.listen(common.PORT, function() { for (var i = 0; i < 10; i++) { var options = { port: common.PORT }; - var req = http.request(options, function (res) { - res.resume() + var req = http.request(options, function(res) { + res.resume(); res.on('end', function() { throw new Error('gleep glorp'); }); diff --git a/test/simple/test-http-flush.js b/test/simple/test-http-flush.js index 08dd1477220d..509bc2a3cc97 100644 --- a/test/simple/test-http-flush.js +++ b/test/simple/test-http-flush.js @@ -30,7 +30,7 @@ http.createServer(function(req, res) { var req = http.request({ method: 'POST', host: '127.0.0.1', - port: common.PORT, + port: common.PORT }); req.flushHeaders(); // Flush the request headers. req.flushHeaders(); // Should be idempotent. diff --git a/test/simple/test-http-incoming-pipelined-socket-destroy.js b/test/simple/test-http-incoming-pipelined-socket-destroy.js index 3a2f531a75c6..092d84fe33f2 100644 --- a/test/simple/test-http-incoming-pipelined-socket-destroy.js +++ b/test/simple/test-http-incoming-pipelined-socket-destroy.js @@ -63,13 +63,13 @@ function generator(seeds) { return 'GET /' + r + ' HTTP/1.1\r\n' + 'Host: localhost:' + common.PORT + '\r\n' + '\r\n' + - '\r\n' + '\r\n'; }).join(''); } server.listen(common.PORT, function() { - var seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ]; + var seeds = [3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]; var client = net.connect({ port: common.PORT }); var done = 0; server.on('requestDone', function() { diff --git a/test/simple/test-http-keepalive-client.js b/test/simple/test-http-keepalive-client.js index 177a8ed7a9e8..c6ba0b3fee57 100644 --- a/test/simple/test-http-keepalive-client.js +++ b/test/simple/test-http-keepalive-client.js @@ -87,6 +87,6 @@ function makeRequest(n) { } process.on('exit', function() { - assert.equal(actualRequests, expectRequests) + assert.equal(actualRequests, expectRequests); console.log('ok'); }); diff --git a/test/simple/test-http-keepalive-request.js b/test/simple/test-http-keepalive-request.js index 3b87375408d2..c4c0b2f88575 100644 --- a/test/simple/test-http-keepalive-request.js +++ b/test/simple/test-http-keepalive-request.js @@ -87,6 +87,6 @@ function makeRequest(n) { } process.on('exit', function() { - assert.equal(actualRequests, expectRequests) + assert.equal(actualRequests, expectRequests); console.log('ok'); }); diff --git a/test/simple/test-http-localaddress-bind-error.js b/test/simple/test-http-localaddress-bind-error.js index 719525cc6122..71b7947b3056 100644 --- a/test/simple/test-http-localaddress-bind-error.js +++ b/test/simple/test-http-localaddress-bind-error.js @@ -27,7 +27,7 @@ var invalidLocalAddress = '1.2.3.4'; var gotError = false; var server = http.createServer(function(req, res) { - console.log("Connect from: " + req.connection.remoteAddress); + console.log('Connect from: ' + req.connection.remoteAddress); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -36,7 +36,7 @@ var server = http.createServer(function(req, res) { req.resume(); }); -server.listen(common.PORT, "127.0.0.1", function() { +server.listen(common.PORT, '127.0.0.1', function() { var req = http.request({ host: 'localhost', port: common.PORT, diff --git a/test/simple/test-http-localaddress.js b/test/simple/test-http-localaddress.js index 27172e33a95d..275895a49827 100644 --- a/test/simple/test-http-localaddress.js +++ b/test/simple/test-http-localaddress.js @@ -28,8 +28,8 @@ if (!common.hasMultiLocalhost()) { process.exit(); } -var server = http.createServer(function (req, res) { - console.log("Connect from: " + req.connection.remoteAddress); +var server = http.createServer(function(req, res) { + console.log('Connect from: ' + req.connection.remoteAddress); assert.equal('127.0.0.2', req.connection.remoteAddress); req.on('end', function() { @@ -39,7 +39,7 @@ var server = http.createServer(function (req, res) { req.resume(); }); -server.listen(common.PORT, "127.0.0.1", function() { +server.listen(common.PORT, '127.0.0.1', function() { var options = { host: 'localhost', port: common.PORT, path: '/', diff --git a/test/simple/test-http-many-ended-pipelines.js b/test/simple/test-http-many-ended-pipelines.js index dffde722f2ac..43ecb3a2ce24 100644 --- a/test/simple/test-http-many-ended-pipelines.js +++ b/test/simple/test-http-many-ended-pipelines.js @@ -49,7 +49,7 @@ server.listen(common.PORT); var client = net.connect({ port: common.PORT, allowHalfOpen: true }); for (var i = 0; i < numRequests; i++) { client.write('GET / HTTP/1.1\r\n' + - 'Host: some.host.name\r\n'+ + 'Host: some.host.name\r\n' + '\r\n\r\n'); } client.end(); diff --git a/test/simple/test-http-parser.js b/test/simple/test-http-parser.js index c61dc9911653..cdc5aa52372a 100644 --- a/test/simple/test-http-parser.js +++ b/test/simple/test-http-parser.js @@ -143,7 +143,7 @@ function expectBody(expected) { assert.equal(info.versionMajor, 1); assert.equal(info.versionMinor, 1); assert.equal(info.statusCode, 200); - assert.equal(info.statusMessage, "OK"); + assert.equal(info.statusMessage, 'OK'); }); parser[kOnBody] = mustCall(function(buf, start, len) { @@ -170,7 +170,7 @@ function expectBody(expected) { assert.equal(info.versionMajor, 1); assert.equal(info.versionMinor, 0); assert.equal(info.statusCode, 200); - assert.equal(info.statusMessage, "Connection established"); + assert.equal(info.statusMessage, 'Connection established'); assert.deepEqual(info.headers || parser.headers, []); }); diff --git a/test/simple/test-http-remove-header-stays-removed.js b/test/simple/test-http-remove-header-stays-removed.js index a15c7750c504..f9c6b024e0bd 100644 --- a/test/simple/test-http-remove-header-stays-removed.js +++ b/test/simple/test-http-remove-header-stays-removed.js @@ -49,7 +49,7 @@ process.on('exit', function() { server.listen(common.PORT, function() { http.get({ port: common.PORT }, function(res) { assert.equal(200, res.statusCode); - assert.deepEqual(res.headers, { date : 'coffee o clock' }); + assert.deepEqual(res.headers, { date: 'coffee o clock' }); res.setEncoding('ascii'); res.on('data', function(chunk) { diff --git a/test/simple/test-http-response-status-message.js b/test/simple/test-http-response-status-message.js index 3b3911010d35..6daa87ddee34 100644 --- a/test/simple/test-http-response-status-message.js +++ b/test/simple/test-http-response-status-message.js @@ -27,15 +27,22 @@ var net = require('net'); var testsComplete = 0; var testCases = [ - { path: "/200", statusMessage: "OK", response: 'HTTP/1.1 200 OK\r\n\r\n' }, - { path: "/500", statusMessage: "Internal Server Error", response: 'HTTP/1.1 500 Internal Server Error\r\n\r\n' }, - { path: "/302", statusMessage: "Moved Temporarily", response: 'HTTP/1.1 302 Moved Temporarily\r\n\r\n' }, - { path: "/missing", statusMessage: "", response: 'HTTP/1.1 200 \r\n\r\n' }, - { path: "/missing-no-space", statusMessage: "", response: 'HTTP/1.1 200\r\n\r\n' } + { path: '/200', statusMessage: 'OK', response: 'HTTP/1.1 200 OK\r\n\r\n' }, + { path: '/500', statusMessage: 'Internal Server Error', + response: 'HTTP/1.1 500 Internal Server Error\r\n\r\n' }, + { path: '/302', statusMessage: 'Moved Temporarily', + response: 'HTTP/1.1 302 Moved Temporarily\r\n\r\n' }, + { path: '/missing', statusMessage: '', response: 'HTTP/1.1 200 \r\n\r\n' }, + { path: '/missing-no-space', statusMessage: '', + response: 'HTTP/1.1 200\r\n\r\n' } ]; testCases.findByPath = function(path) { - var matching = this.filter(function(testCase) { return testCase.path === path; }); - if (matching.length === 0) { throw "failed to find test case with path " + path; } + var matching = this.filter(function(testCase) { + return testCase.path === path; + }); + if (matching.length === 0) { + throw 'failed to find test case with path ' + path; + } return matching[0]; }; diff --git a/test/simple/test-http-server-multiheaders.js b/test/simple/test-http-server-multiheaders.js index b287169bdab9..7a688088b4d4 100644 --- a/test/simple/test-http-server-multiheaders.js +++ b/test/simple/test-http-server-multiheaders.js @@ -58,9 +58,9 @@ srv.listen(common.PORT, function() { ['www-authenticate', 'foo'], ['WWW-Authenticate', 'bar'], ['WWW-AUTHENTICATE', 'baz'], - ['proxy-authenticate','foo'], - ['Proxy-Authenticate','bar'], - ['PROXY-AUTHENTICATE','baz'], + ['proxy-authenticate', 'foo'], + ['Proxy-Authenticate', 'bar'], + ['PROXY-AUTHENTICATE', 'baz'], ['x-foo', 'bingo'], ['x-bar', 'banjo'], ['x-bar', 'bango'], diff --git a/test/simple/test-http-server-multiheaders2.js b/test/simple/test-http-server-multiheaders2.js index 40674c0fc2e7..0b9f955beb09 100644 --- a/test/simple/test-http-server-multiheaders2.js +++ b/test/simple/test-http-server-multiheaders2.js @@ -48,7 +48,7 @@ var multipleAllowed = [ // make sure that unspecified headers is treated as multiple 'Some-Random-Header', - 'X-Some-Random-Header', + 'X-Some-Random-Header' ]; var multipleForbidden = [ @@ -62,7 +62,7 @@ var multipleForbidden = [ 'If-Unmodified-Since', 'From', 'Location', - 'Max-Forwards', + 'Max-Forwards' // special case, tested differently //'Content-Length', @@ -70,10 +70,12 @@ var multipleForbidden = [ var srv = http.createServer(function(req, res) { multipleForbidden.forEach(function(header) { - assert.equal(req.headers[header.toLowerCase()], 'foo', 'header parsed incorrectly: ' + header); + assert.equal(req.headers[header.toLowerCase()], + 'foo', 'header parsed incorrectly: ' + header); }); multipleAllowed.forEach(function(header) { - assert.equal(req.headers[header.toLowerCase()], 'foo, bar', 'header parsed incorrectly: ' + header); + assert.equal(req.headers[header.toLowerCase()], + 'foo, bar', 'header parsed incorrectly: ' + header); }); assert.equal(req.headers['content-length'], 0); @@ -94,8 +96,8 @@ var headers = [] .concat(multipleForbidden.map(makeHeader('foo'))) .concat(multipleAllowed.map(makeHeader('bar'))) .concat(multipleForbidden.map(makeHeader('bar'))) - // content-length is a special case since node.js - // is dropping connetions with non-numeric headers + // content-length is a special case since node.js + // is dropping connetions with non-numeric headers .concat([['content-length', 0], ['content-length', 123]]); srv.listen(common.PORT, function() { @@ -103,6 +105,6 @@ srv.listen(common.PORT, function() { host: 'localhost', port: common.PORT, path: '/', - headers: headers, + headers: headers }); }); diff --git a/test/simple/test-http-server-stale-close.js b/test/simple/test-http-server-stale-close.js index aa42a049bb85..37b447c82feb 100644 --- a/test/simple/test-http-server-stale-close.js +++ b/test/simple/test-http-server-stale-close.js @@ -30,7 +30,7 @@ if (process.env.NODE_TEST_FORK) { headers: {'Content-Length': '42'}, method: 'POST', host: '127.0.0.1', - port: common.PORT, + port: common.PORT }, process.exit); req.write('BAM'); req.end(); diff --git a/test/simple/test-http-timeout-overflow.js b/test/simple/test-http-timeout-overflow.js index 3e62612b38ec..04177f396b95 100644 --- a/test/simple/test-http-timeout-overflow.js +++ b/test/simple/test-http-timeout-overflow.js @@ -36,7 +36,7 @@ var server = http.createServer(function(req, res) { }); server.listen(port, function() { - function callback(){} + function callback() {} var req = http.request({ port: port, @@ -48,7 +48,7 @@ server.listen(port, function() { res.on('end', function() { clientRequests++; server.close(); - }) + }); res.resume(); }); diff --git a/test/simple/test-http-timeout.js b/test/simple/test-http-timeout.js index ddd01c8a8f58..a56acb4ebe2d 100644 --- a/test/simple/test-http-timeout.js +++ b/test/simple/test-http-timeout.js @@ -28,8 +28,8 @@ var http = require('http'); var port = common.PORT; var server = http.createServer(function(req, res) { - res.writeHead(200, {'Content-Type': 'text/plain'}); - res.end('OK'); + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.end('OK'); }); var agent = new http.Agent({maxSockets: 1}); @@ -40,26 +40,22 @@ server.listen(port, function() { createRequest().end(); } - function callback(){} + function callback() {} var count = 0; function createRequest() { - var req = http.request({port: port, path: '/', agent: agent}, function(res) { - - req.clearTimeout(callback); - - res.on('end', function() { - count++; - - if (count == 11) { - server.close(); - } - }) - - res.resume(); - }); - + var req = http.request({port: port, path: '/', agent: agent}, + function(res) { + req.clearTimeout(callback); + res.on('end', function() { + count++; + if (count == 11) { + server.close(); + } + }); + res.resume(); + }); req.setTimeout(1000, callback); return req; } diff --git a/test/simple/test-http-url.parse-only-support-http-https-protocol.js b/test/simple/test-http-url.parse-only-support-http-https-protocol.js index 0f57126419d7..89bb48a7e6ce 100644 --- a/test/simple/test-http-url.parse-only-support-http-https-protocol.js +++ b/test/simple/test-http-url.parse-only-support-http-https-protocol.js @@ -29,7 +29,8 @@ assert.throws(function() { http.request(url.parse('file:///whatever')); }, function(err) { if (err instanceof Error) { - assert.strictEqual(err.message, 'Protocol "file:" not supported. Expected "http:".'); + assert.strictEqual(err.message, + 'Protocol "file:" not supported. Expected "http:".'); return true; } }); @@ -38,7 +39,8 @@ assert.throws(function() { http.request(url.parse('mailto:asdf@asdf.com')); }, function(err) { if (err instanceof Error) { - assert.strictEqual(err.message, 'Protocol "mailto:" not supported. Expected "http:".'); + assert.strictEqual(err.message, + 'Protocol "mailto:" not supported. Expected "http:".'); return true; } }); @@ -47,7 +49,8 @@ assert.throws(function() { http.request(url.parse('ftp://www.example.com')); }, function(err) { if (err instanceof Error) { - assert.strictEqual(err.message, 'Protocol "ftp:" not supported. Expected "http:".'); + assert.strictEqual(err.message, + 'Protocol "ftp:" not supported. Expected "http:".'); return true; } }); @@ -56,7 +59,8 @@ assert.throws(function() { http.request(url.parse('javascript:alert(\'hello\');')); }, function(err) { if (err instanceof Error) { - assert.strictEqual(err.message, 'Protocol "javascript:" not supported. Expected "http:".'); + assert.strictEqual(err.message, + 'Protocol "javascript:" not supported. Expected "http:".'); return true; } }); @@ -65,7 +69,8 @@ assert.throws(function() { http.request(url.parse('xmpp:isaacschlueter@jabber.org')); }, function(err) { if (err instanceof Error) { - assert.strictEqual(err.message, 'Protocol "xmpp:" not supported. Expected "http:".'); + assert.strictEqual(err.message, + 'Protocol "xmpp:" not supported. Expected "http:".'); return true; } }); @@ -74,7 +79,8 @@ assert.throws(function() { http.request(url.parse('f://some.host/path')); }, function(err) { if (err instanceof Error) { - assert.strictEqual(err.message, 'Protocol "f:" not supported. Expected "http:".'); + assert.strictEqual(err.message, + 'Protocol "f:" not supported. Expected "http:".'); return true; } }); diff --git a/test/simple/test-http-zero-length-write.js b/test/simple/test-http-zero-length-write.js index e68f947c32cc..3c461b86d9ef 100644 --- a/test/simple/test-http-zero-length-write.js +++ b/test/simple/test-http-zero-length-write.js @@ -40,10 +40,10 @@ function getSrc() { paused = false; }; - var chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ]; + var chunks = ['', 'asdf', '', 'foo', '', 'bar', '']; var interval = setInterval(function() { if (paused) - return + return; var chunk = chunks.shift(); if (chunk !== undefined) { diff --git a/test/simple/test-https-client-checkServerIdentity.js b/test/simple/test-https-client-checkServerIdentity.js index a985d23e58ef..d75091377cd4 100644 --- a/test/simple/test-https-client-checkServerIdentity.js +++ b/test/simple/test-https-client-checkServerIdentity.js @@ -37,12 +37,12 @@ var options = { var reqCount = 0; -var server = https.createServer(options, function (req, res) { +var server = https.createServer(options, function(req, res) { ++reqCount; res.writeHead(200); res.end(); req.resume(); -}).listen(common.PORT, function () { +}).listen(common.PORT, function() { authorized(); }); @@ -51,10 +51,10 @@ function authorized() { port: common.PORT, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))] - }, function (res) { + }, function(res) { assert(false); }); - req.on('error', function (err) { + req.on('error', function(err) { override(); }); req.end(); @@ -65,21 +65,21 @@ function override() { port: common.PORT, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))], - checkServerIdentity: function (host, cert) { + checkServerIdentity: function(host, cert) { return false; } }; options.agent = new https.Agent(options); - var req = https.request(options, function (res) { + var req = https.request(options, function(res) { assert(req.socket.authorized); server.close(); }); - req.on('error', function (err) { + req.on('error', function(err) { throw err; }); req.end(); } -process.on('exit', function () { +process.on('exit', function() { assert.equal(reqCount, 1); }); diff --git a/test/simple/test-https-localaddress-bind-error.js b/test/simple/test-https-localaddress-bind-error.js index 0c4f8da4c4da..6a997e1692b5 100644 --- a/test/simple/test-https-localaddress-bind-error.js +++ b/test/simple/test-https-localaddress-bind-error.js @@ -33,7 +33,7 @@ var invalidLocalAddress = '1.2.3.4'; var gotError = false; var server = https.createServer(options, function(req, res) { - console.log("Connect from: " + req.connection.remoteAddress); + console.log('Connect from: ' + req.connection.remoteAddress); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -42,7 +42,7 @@ var server = https.createServer(options, function(req, res) { req.resume(); }); -server.listen(common.PORT, "127.0.0.1", function() { +server.listen(common.PORT, '127.0.0.1', function() { var req = https.request({ host: 'localhost', port: common.PORT, diff --git a/test/simple/test-https-localaddress.js b/test/simple/test-https-localaddress.js index 4d3b8ab02056..ee5e9ecbcbb1 100644 --- a/test/simple/test-https-localaddress.js +++ b/test/simple/test-https-localaddress.js @@ -34,8 +34,8 @@ var options = { cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = https.createServer(options, function (req, res) { - console.log("Connect from: " + req.connection.remoteAddress); +var server = https.createServer(options, function(req, res) { + console.log('Connect from: ' + req.connection.remoteAddress); assert.equal('127.0.0.2', req.connection.remoteAddress); req.on('end', function() { @@ -45,7 +45,7 @@ var server = https.createServer(options, function (req, res) { req.resume(); }); -server.listen(common.PORT, "127.0.0.1", function() { +server.listen(common.PORT, '127.0.0.1', function() { var options = { host: 'localhost', port: common.PORT, diff --git a/test/simple/test-https-socket-options.js b/test/simple/test-https-socket-options.js index 21b1118f7d4c..e2c0b7d17c61 100644 --- a/test/simple/test-https-socket-options.js +++ b/test/simple/test-https-socket-options.js @@ -64,7 +64,8 @@ server_http.listen(common.PORT, function() { req.end(); }); -// Then try https server (requires functions to be mirroed in tls.js's CryptoStream) +// Then try https server (requires functions to +// be mirroed in tls.js's CryptoStream) var server_https = https.createServer(options, function(req, res) { console.log('got HTTPS request'); @@ -72,7 +73,7 @@ var server_https = https.createServer(options, function(req, res) { res.end(body); }); -server_https.listen(common.PORT+1, function() { +server_https.listen(common.PORT + 1, function() { var req = https.request({ port: common.PORT + 1, rejectUnauthorized: false diff --git a/test/simple/test-https-strict.js b/test/simple/test-https-strict.js index 9cd763f7ae3b..35936cc85924 100644 --- a/test/simple/test-https-strict.js +++ b/test/simple/test-https-strict.js @@ -121,7 +121,7 @@ function listening() { if (listenWait === 0) { allListening(); } - } + }; } function makeReq(path, port, error, host, ca) { @@ -148,16 +148,15 @@ function makeReq(path, port, error, host, ca) { } if (host) { - options.headers = { host: host } + options.headers = { host: host }; } var req = https.get(options); expectResponseCount++; - var server = port === port1 ? server1 - : port === port2 ? server2 - : port === port3 ? server3 - : null; + var server = port === port1 ? server1 : + port === port2 ? server2 : + port === port3 ? server3 : null; - if (!server) throw new Error('invalid port: '+port); + if (!server) throw new Error('invalid port: ' + port); server.expectCount++; req.on('response', function(res) { @@ -171,7 +170,7 @@ function makeReq(path, port, error, host, ca) { server3.close(); } res.resume(); - }) + }); } function allListening() { diff --git a/test/simple/test-intl.js b/test/simple/test-intl.js index 841239a8d94c..6d709653d148 100644 --- a/test/simple/test-intl.js +++ b/test/simple/test-intl.js @@ -25,7 +25,7 @@ var assert = require('assert'); // does node think that i18n was enabled? var enablei18n = process.config.variables.v8_enable_i18n_support; if (enablei18n === undefined) { - enablei18n = false; + enablei18n = false; } // is the Intl object present? @@ -48,9 +48,9 @@ if (!haveIntl) { } else { var erMsg = - '"Intl" object is present but v8_enable_i18n_support is ' + - enablei18n + - '. Is this test out of date?'; + '"Intl" object is present but v8_enable_i18n_support is ' + + enablei18n + + '. Is this test out of date?'; assert.equal(enablei18n, true, erMsg); // Construct a new date at the beginning of Unix time diff --git a/test/simple/test-listen-fd-cluster.js b/test/simple/test-listen-fd-cluster.js index 0d6d7748aa1c..0374440b4a12 100644 --- a/test/simple/test-listen-fd-cluster.js +++ b/test/simple/test-listen-fd-cluster.js @@ -49,7 +49,7 @@ switch (process.argv[2]) { // a more low-level approach, use child process IPC manually. function test() { var parent = spawn(process.execPath, [__filename, 'parent'], { - stdio: [ 0, 'pipe', 2 ] + stdio: [0, 'pipe', 2] }); var json = ''; parent.stdout.on('data', function(c) { @@ -63,8 +63,8 @@ function test() { http.get({ server: 'localhost', port: PORT, - path: '/', - }).on('response', function (res) { + path: '/' + }).on('response', function(res) { var s = ''; res.on('data', function(c) { s += c.toString(); @@ -79,7 +79,7 @@ function test() { assert.equal(res.statusCode, 200); console.log('ok'); }); - }) + }); } } @@ -93,7 +93,7 @@ function parent() { var spawn = require('child_process').spawn; var master = spawn(process.execPath, [__filename, 'master'], { - stdio: [ 0, 1, 2, server._handle ], + stdio: [0, 1, 2, server._handle], detached: true }); @@ -116,7 +116,7 @@ function parent() { function master() { console.error('in master, spawning worker'); cluster.setupMaster({ - args: [ 'worker' ] + args: ['worker'] }); var worker = cluster.fork(); console.log('%j\n', { master: process.pid, worker: worker.pid }); diff --git a/test/simple/test-listen-fd-detached-inherit.js b/test/simple/test-listen-fd-detached-inherit.js index dabc46cd313c..c35f2e454254 100644 --- a/test/simple/test-listen-fd-detached-inherit.js +++ b/test/simple/test-listen-fd-detached-inherit.js @@ -45,7 +45,7 @@ switch (process.argv[2]) { // a more low-level approach, use child process IPC manually. function test() { var parent = spawn(process.execPath, [__filename, 'parent'], { - stdio: [ 0, 'pipe', 2 ] + stdio: [0, 'pipe', 2] }); var json = ''; parent.stdout.on('data', function(c) { @@ -59,8 +59,8 @@ function test() { http.get({ server: 'localhost', port: PORT, - path: '/', - }).on('response', function (res) { + path: '/' + }).on('response', function(res) { var s = ''; res.on('data', function(c) { s += c.toString(); @@ -76,7 +76,7 @@ function test() { assert.equal(s, 'hello from child\n'); assert.equal(res.statusCode, 200); }); - }) + }); } } @@ -90,7 +90,7 @@ function parent() { console.error('server listening on %d', PORT); var child = spawn(process.execPath, [__filename, 'child'], { - stdio: [ 0, 1, 2, server._handle ], + stdio: [0, 1, 2, server._handle], detached: true }); diff --git a/test/simple/test-listen-fd-detached.js b/test/simple/test-listen-fd-detached.js index 3d98abeacda6..711f584d1746 100644 --- a/test/simple/test-listen-fd-detached.js +++ b/test/simple/test-listen-fd-detached.js @@ -45,7 +45,7 @@ switch (process.argv[2]) { // a more low-level approach, use child process IPC manually. function test() { var parent = spawn(process.execPath, [__filename, 'parent'], { - stdio: [ 0, 'pipe', 2 ] + stdio: [0, 'pipe', 2] }); var json = ''; parent.stdout.on('data', function(c) { @@ -59,8 +59,8 @@ function test() { http.get({ server: 'localhost', port: PORT, - path: '/', - }).on('response', function (res) { + path: '/' + }).on('response', function(res) { var s = ''; res.on('data', function(c) { s += c.toString(); @@ -76,7 +76,7 @@ function test() { assert.equal(s, 'hello from child\n'); assert.equal(res.statusCode, 200); }); - }) + }); } } @@ -89,7 +89,7 @@ function parent() { var spawn = require('child_process').spawn; var child = spawn(process.execPath, [__filename, 'child'], { - stdio: [ 'ignore', 'ignore', 'ignore', server._handle ], + stdio: ['ignore', 'ignore', 'ignore', server._handle], detached: true }); diff --git a/test/simple/test-listen-fd-ebadf.js b/test/simple/test-listen-fd-ebadf.js index 6c0f20ae4364..37c373c75a6d 100644 --- a/test/simple/test-listen-fd-ebadf.js +++ b/test/simple/test-listen-fd-ebadf.js @@ -29,8 +29,8 @@ process.on('exit', function() { assert.equal(gotError, 2); }); -net.createServer(assert.fail).listen({fd:2}).on('error', onError); -net.createServer(assert.fail).listen({fd:42}).on('error', onError); +net.createServer(assert.fail).listen({fd: 2}).on('error', onError); +net.createServer(assert.fail).listen({fd: 42}).on('error', onError); function onError(ex) { assert.equal(ex.code, 'EINVAL'); diff --git a/test/simple/test-listen-fd-server.js b/test/simple/test-listen-fd-server.js index 8f3454fbbd63..4827e4be7637 100644 --- a/test/simple/test-listen-fd-server.js +++ b/test/simple/test-listen-fd-server.js @@ -45,7 +45,7 @@ switch (process.argv[2]) { // a more low-level approach, use child process IPC manually. function test() { var parent = spawn(process.execPath, [__filename, 'parent'], { - stdio: [ 0, 'pipe', 2 ] + stdio: [0, 'pipe', 2] }); var json = ''; parent.stdout.on('data', function(c) { @@ -59,8 +59,8 @@ function test() { http.get({ server: 'localhost', port: PORT, - path: '/', - }).on('response', function (res) { + path: '/' + }).on('response', function(res) { var s = ''; res.on('data', function(c) { s += c.toString(); @@ -76,7 +76,7 @@ function test() { assert.equal(s, 'hello from child\n'); assert.equal(res.statusCode, 200); }); - }) + }); } } @@ -100,7 +100,7 @@ function parent() { var spawn = require('child_process').spawn; var child = spawn(process.execPath, [__filename, 'child'], { - stdio: [ 0, 1, 2, server._handle ] + stdio: [0, 1, 2, server._handle] }); console.log('%j\n', { pid: child.pid }); diff --git a/test/simple/test-microtask-queue-integration-domain.js b/test/simple/test-microtask-queue-integration-domain.js index 2197bf9212e8..b2917b5edc66 100644 --- a/test/simple/test-microtask-queue-integration-domain.js +++ b/test/simple/test-microtask-queue-integration-domain.js @@ -24,10 +24,10 @@ var assert = require('assert'); var domain = require('domain'); var implementations = [ - function (fn) { + function(fn) { Promise.resolve().then(fn); }, - function (fn) { + function(fn) { var obj = {}; Object.observe(obj, fn); @@ -39,20 +39,20 @@ var implementations = [ var expected = 0; var done = 0; -process.on('exit', function () { +process.on('exit', function() { assert.equal(done, expected); }); -function test (scheduleMicrotask) { +function test(scheduleMicrotask) { var nextTickCalled = false; expected++; - scheduleMicrotask(function () { - process.nextTick(function () { + scheduleMicrotask(function() { + process.nextTick(function() { nextTickCalled = true; }); - setTimeout(function () { + setTimeout(function() { assert(nextTickCalled); done++; }, 0); @@ -63,8 +63,8 @@ function test (scheduleMicrotask) { implementations.forEach(test); // tick callback case -setTimeout(function () { - implementations.forEach(function (impl) { +setTimeout(function() { + implementations.forEach(function(impl) { process.nextTick(test.bind(null, impl)); }); }, 0); diff --git a/test/simple/test-microtask-queue-integration.js b/test/simple/test-microtask-queue-integration.js index af01548477f6..95fd91092869 100644 --- a/test/simple/test-microtask-queue-integration.js +++ b/test/simple/test-microtask-queue-integration.js @@ -23,10 +23,10 @@ var common = require('../common'); var assert = require('assert'); var implementations = [ - function (fn) { + function(fn) { Promise.resolve().then(fn); }, - function (fn) { + function(fn) { var obj = {}; Object.observe(obj, fn); @@ -38,20 +38,20 @@ var implementations = [ var expected = 0; var done = 0; -process.on('exit', function () { +process.on('exit', function() { assert.equal(done, expected); }); -function test (scheduleMicrotask) { +function test(scheduleMicrotask) { var nextTickCalled = false; expected++; - scheduleMicrotask(function () { - process.nextTick(function () { + scheduleMicrotask(function() { + process.nextTick(function() { nextTickCalled = true; }); - setTimeout(function () { + setTimeout(function() { assert(nextTickCalled); done++; }, 0); @@ -62,8 +62,8 @@ function test (scheduleMicrotask) { implementations.forEach(test); // tick callback case -setTimeout(function () { - implementations.forEach(function (impl) { +setTimeout(function() { + implementations.forEach(function(impl) { process.nextTick(test.bind(null, impl)); }); }, 0); diff --git a/test/simple/test-module-globalpaths-nodepath.js b/test/simple/test-module-globalpaths-nodepath.js index c99b6763b4ea..0e98529eaf5a 100644 --- a/test/simple/test-module-globalpaths-nodepath.js +++ b/test/simple/test-module-globalpaths-nodepath.js @@ -43,4 +43,4 @@ module._initPaths(); assert.ok(module.globalPaths.indexOf(partA) !== -1); assert.ok(module.globalPaths.indexOf(partB) !== -1); -assert.ok(Array.isArray(module.globalPaths)); \ No newline at end of file +assert.ok(Array.isArray(module.globalPaths)); diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js index 8687c3b98647..36d1501a93fb 100644 --- a/test/simple/test-module-loading.js +++ b/test/simple/test-module-loading.js @@ -211,7 +211,7 @@ assert.deepEqual(json, { // the appropriate children, and so on. var children = module.children.reduce(function red(set, child) { - var id = path.relative(path.dirname(__dirname), child.id) + var id = path.relative(path.dirname(__dirname), child.id); id = id.replace(/\\/g, '/'); set[id] = child.children.reduce(red, {}); return set; diff --git a/test/simple/test-module-nodemodulepaths.js b/test/simple/test-module-nodemodulepaths.js index cf0229d541e8..f8b42f4ee3e3 100644 --- a/test/simple/test-module-nodemodulepaths.js +++ b/test/simple/test-module-nodemodulepaths.js @@ -30,10 +30,10 @@ var file, delimiter, paths; if (isWindows) { file = 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo'; - delimiter = '\\' + delimiter = '\\'; } else { file = '/usr/test/lib/node_modules/npm/foo'; - delimiter = '/' + delimiter = '/'; } paths = module._nodeModulePaths(file); diff --git a/test/simple/test-net-GH-5504.js b/test/simple/test-net-GH-5504.js index e135581e218d..8d2324000e47 100644 --- a/test/simple/test-net-GH-5504.js +++ b/test/simple/test-net-GH-5504.js @@ -77,7 +77,7 @@ function parent() { var opt = { env: util._extend(process.env, { NODE_DEBUG: 'net', - NODE_COMMON_PORT: process.env.NODE_COMMON_PORT, + NODE_COMMON_PORT: process.env.NODE_COMMON_PORT }) }; diff --git a/test/simple/test-net-create-connection.js b/test/simple/test-net-create-connection.js index 2dee0296659d..f3b6c6a48d77 100644 --- a/test/simple/test-net-create-connection.js +++ b/test/simple/test-net-create-connection.js @@ -43,7 +43,7 @@ server.listen(tcpPort, 'localhost', function() { function fail(opts, errtype, msg) { assert.throws(function() { var client = net.createConnection(opts, cb); - }, function (err) { + }, function(err) { return err instanceof errtype && msg === err.message; }); } diff --git a/test/simple/test-net-error-twice.js b/test/simple/test-net-error-twice.js index 955eea6c09e1..19c92e6f11bf 100644 --- a/test/simple/test-net-error-twice.js +++ b/test/simple/test-net-error-twice.js @@ -31,18 +31,18 @@ var errs = []; var srv = net.createServer(function onConnection(conn) { conn.write(buf); - conn.on('error', function (err) { + conn.on('error', function(err) { errs.push(err); if (errs.length > 1 && errs[0] === errs[1]) - assert(false, "We should not be emitting the same error twice"); + assert(false, 'We should not be emitting the same error twice'); }); conn.on('close', function() { srv.unref(); }); -}).listen(common.PORT, function () { +}).listen(common.PORT, function() { var client = net.connect({ port: common.PORT }); - client.on('connect', function () { + client.on('connect', function() { client.destroy(); }); }); diff --git a/test/simple/test-net-isip.js b/test/simple/test-net-isip.js index 0d324007f221..18b89f1a9a8f 100644 --- a/test/simple/test-net-isip.js +++ b/test/simple/test-net-isip.js @@ -50,7 +50,7 @@ assert.equal(net.isIP('::'), 6); assert.equal(net.isIP('0000:0000:0000:0000:0000:0000:12345:0000'), 0); assert.equal(net.isIP('0'), 0); assert.equal(net.isIP(), 0); -assert.equal(net.isIP(""), 0); +assert.equal(net.isIP(''), 0); assert.equal(net.isIPv4('127.0.0.1'), true); assert.equal(net.isIPv4('example.com'), false); diff --git a/test/simple/test-net-listen-fd0.js b/test/simple/test-net-listen-fd0.js index ac5896ee8f99..a7dec6ee1d4f 100644 --- a/test/simple/test-net-listen-fd0.js +++ b/test/simple/test-net-listen-fd0.js @@ -30,11 +30,11 @@ process.on('exit', function() { }); // this should fail with an async EINVAL error, not throw an exception -net.createServer(assert.fail).listen({fd:0}).on('error', function(e) { - switch(e.code) { +net.createServer(assert.fail).listen({fd: 0}).on('error', function(e) { + switch (e.code) { case 'EINVAL': case 'ENOTSOCK': gotError = e; - break + break; } }); diff --git a/test/simple/test-net-localerror.js b/test/simple/test-net-localerror.js index cf113d499a8e..78c9168b56df 100644 --- a/test/simple/test-net-localerror.js +++ b/test/simple/test-net-localerror.js @@ -26,13 +26,13 @@ var net = require('net'); connect({ host: 'localhost', port: common.PORT, - localPort: 'foobar', + localPort: 'foobar' }, 'localPort should be a number: foobar'); connect({ host: 'localhost', port: common.PORT, - localAddress: 'foobar', + localAddress: 'foobar' }, 'localAddress should be a valid IP: foobar'); function connect(opts, msg) { diff --git a/test/simple/test-net-localport.js b/test/simple/test-net-localport.js index 34fa377dc8e0..0661da8fce5a 100644 --- a/test/simple/test-net-localport.js +++ b/test/simple/test-net-localport.js @@ -34,8 +34,8 @@ var server = net.createServer(function(socket) { var client = net.connect({ host: '127.0.0.1', port: common.PORT, - localPort: common.PORT + 1, + localPort: common.PORT + 1 }).on('connect', function() { assert.strictEqual(client.localPort, common.PORT + 1); }); -}) +}); diff --git a/test/simple/test-net-remote-address-port.js b/test/simple/test-net-remote-address-port.js index 9fc53ffe3898..fbb277f3539b 100644 --- a/test/simple/test-net-remote-address-port.js +++ b/test/simple/test-net-remote-address-port.js @@ -26,7 +26,7 @@ var net = require('net'); var conns = 0, conns_closed = 0; -var remoteAddrCandidates = [ '127.0.0.1']; +var remoteAddrCandidates = ['127.0.0.1']; if (common.hasIPv6) remoteAddrCandidates.push('::ffff:127.0.0.1'); var remoteFamilyCandidates = ['IPv4']; diff --git a/test/simple/test-net-server-address.js b/test/simple/test-net-server-address.js index cc8fbd211aa5..f7781f58ae83 100644 --- a/test/simple/test-net-server-address.js +++ b/test/simple/test-net-server-address.js @@ -82,12 +82,12 @@ server1.listen(common.PORT, function() { // Test without hostname or port var server2 = net.createServer(); -server2.on('error', function (e) { +server2.on('error', function(e) { console.log('Error on ip socket: ' + e.toString()); }); // Don't specify the port number -server2.listen(function () { +server2.listen(function() { var address = server2.address(); assert.strictEqual(address.address, anycast_ipv6); assert.strictEqual(address.family, family_ipv6); @@ -97,12 +97,12 @@ server2.listen(function () { // Test without hostname, but with a false-y port var server3 = net.createServer(); -server3.on('error', function (e) { +server3.on('error', function(e) { console.log('Error on ip socket: ' + e.toString()); }); // Specify a false-y port number -server3.listen(0, function () { +server3.listen(0, function() { var address = server3.address(); assert.strictEqual(address.address, anycast_ipv6); assert.strictEqual(address.family, family_ipv6); @@ -112,12 +112,12 @@ server3.listen(0, function () { // Test without hostname, but with port -1 var server4 = net.createServer(); -server4.on('error', function (e) { +server4.on('error', function(e) { console.log('Error on ip socket: ' + e.toString()); }); // Specify -1 as port number -server4.listen(-1, function () { +server4.listen(-1, function() { var address = server4.address(); assert.strictEqual(address.address, anycast_ipv6); assert.strictEqual(address.family, family_ipv6); diff --git a/test/simple/test-net-socket-timeout-unref.js b/test/simple/test-net-socket-timeout-unref.js index 32aef444a9b0..9ead5338864c 100644 --- a/test/simple/test-net-socket-timeout-unref.js +++ b/test/simple/test-net-socket-timeout-unref.js @@ -23,7 +23,7 @@ var common = require('../common'); var assert = require('assert'); var net = require('net'); -var server = net.createServer(function (c) { +var server = net.createServer(function(c) { c.write('hello'); c.unref(); }); @@ -32,9 +32,9 @@ server.unref(); var timedout = false; -[8, 5, 3, 6, 2, 4].forEach(function (T) { +[8, 5, 3, 6, 2, 4].forEach(function(T) { var socket = net.createConnection(common.PORT, 'localhost'); - socket.setTimeout(T * 1000, function () { + socket.setTimeout(T * 1000, function() { console.log(process._getActiveHandles()); timedout = true; socket.destroy(); @@ -42,6 +42,7 @@ var timedout = false; socket.unref(); }); -process.on('exit', function () { - assert.strictEqual(timedout, false, 'Socket timeout should not hold loop open'); +process.on('exit', function() { + assert.strictEqual(timedout, false, + 'Socket timeout should not hold loop open'); }); diff --git a/test/simple/test-net-stream.js b/test/simple/test-net-stream.js index 9f2db51be82b..beb74a3b3a02 100644 --- a/test/simple/test-net-stream.js +++ b/test/simple/test-net-stream.js @@ -50,7 +50,7 @@ var server = net.createServer(function(socket) { socket.destroy(); }).on('close', function() { server.close(); - }) + }); for (var i = 0; i < N; ++i) { socket.write(buf, function() { }); @@ -58,14 +58,14 @@ var server = net.createServer(function(socket) { socket.end(); }).listen(common.PORT, function() { - var conn = net.connect(common.PORT); - conn.on('data', function(buf) { - conn.pause(); - setTimeout(function() { - conn.destroy(); - }, 20); - }); + var conn = net.connect(common.PORT); + conn.on('data', function(buf) { + conn.pause(); + setTimeout(function() { + conn.destroy(); + }, 20); }); +}); process.on('exit', function() { assert.equal(server.connections, 0); diff --git a/test/simple/test-next-tick-domain.js b/test/simple/test-next-tick-domain.js index 16f77ed94d53..532e2d3fa954 100644 --- a/test/simple/test-next-tick-domain.js +++ b/test/simple/test-next-tick-domain.js @@ -26,4 +26,5 @@ var origNextTick = process.nextTick; require('domain'); -assert.strictEqual(origNextTick, process.nextTick, 'Requiring domain should not change nextTick'); +assert.strictEqual(origNextTick, process.nextTick, + 'Requiring domain should not change nextTick'); diff --git a/test/simple/test-next-tick-error-spin.js b/test/simple/test-next-tick-error-spin.js index e0d47a2147b2..2d74f6fe010e 100644 --- a/test/simple/test-next-tick-error-spin.js +++ b/test/simple/test-next-tick-error-spin.js @@ -43,24 +43,24 @@ if (process.argv[2] !== 'child') { // in the error handler, we trigger several MakeCallback events d.on('error', function(e) { - console.log('a') - console.log('b') - console.log('c') - console.log('d') - console.log('e') + console.log('a'); + console.log('b'); + console.log('c'); + console.log('d'); + console.log('e'); f(); }); function f() { process.nextTick(function() { d.run(function() { - throw(new Error('x')); + throw (new Error('x')); }); }); } f(); - setTimeout(function () { + setTimeout(function() { console.error('broke in!'); //process.stdout.close(); //process.stderr.close(); diff --git a/test/simple/test-path-parse-format.js b/test/simple/test-path-parse-format.js index 8fab0fc33cfa..920034a780b7 100644 --- a/test/simple/test-path-parse-format.js +++ b/test/simple/test-path-parse-format.js @@ -62,18 +62,30 @@ var unixSpecialCaseFormatTests = [ ]; var errors = [ - {method: 'parse', input: [null], message: /Parameter 'pathString' must be a string, not/}, - {method: 'parse', input: [{}], message: /Parameter 'pathString' must be a string, not object/}, - {method: 'parse', input: [true], message: /Parameter 'pathString' must be a string, not boolean/}, - {method: 'parse', input: [1], message: /Parameter 'pathString' must be a string, not number/}, - {method: 'parse', input: [], message: /Parameter 'pathString' must be a string, not undefined/}, - // {method: 'parse', input: [''], message: /Invalid path/}, // omitted because it's hard to trigger! - {method: 'format', input: [null], message: /Parameter 'pathObject' must be an object, not/}, - {method: 'format', input: [''], message: /Parameter 'pathObject' must be an object, not string/}, - {method: 'format', input: [true], message: /Parameter 'pathObject' must be an object, not boolean/}, - {method: 'format', input: [1], message: /Parameter 'pathObject' must be an object, not number/}, - {method: 'format', input: [{root: true}], message: /'pathObject.root' must be a string or undefined, not boolean/}, - {method: 'format', input: [{root: 12}], message: /'pathObject.root' must be a string or undefined, not number/}, + {method: 'parse', input: [null], + message: /Parameter 'pathString' must be a string, not/}, + {method: 'parse', input: [{}], + message: /Parameter 'pathString' must be a string, not object/}, + {method: 'parse', input: [true], + message: /Parameter 'pathString' must be a string, not boolean/}, + {method: 'parse', input: [1], + message: /Parameter 'pathString' must be a string, not number/}, + {method: 'parse', input: [], + message: /Parameter 'pathString' must be a string, not undefined/}, + // {method: 'parse', input: [''], + //message: /Invalid path/}, // omitted because it's hard to trigger! + {method: 'format', input: [null], + message: /Parameter 'pathObject' must be an object, not/}, + {method: 'format', input: [''], + message: /Parameter 'pathObject' must be an object, not string/}, + {method: 'format', input: [true], + message: /Parameter 'pathObject' must be an object, not boolean/}, + {method: 'format', input: [1], + message: /Parameter 'pathObject' must be an object, not number/}, + {method: 'format', input: [{root: true}], + message: /'pathObject.root' must be a string or undefined, not boolean/}, + {method: 'format', input: [{root: 12}], + message: /'pathObject.root' must be a string or undefined, not number/} ]; checkParseFormat(path.win32, winPaths); @@ -87,11 +99,11 @@ function checkErrors(path) { errors.forEach(function(errorCase) { try { path[errorCase.method].apply(path, errorCase.input); - } catch(err) { + } catch (err) { assert.ok(err instanceof TypeError); assert.ok( - errorCase.message.test(err.message), - 'expected ' + errorCase.message + ' to match ' + err.message + errorCase.message.test(err.message), + 'expected ' + errorCase.message + ' to match ' + err.message ); return; } diff --git a/test/simple/test-path.js b/test/simple/test-path.js index 7a8a1b14a904..03f877953366 100644 --- a/test/simple/test-path.js +++ b/test/simple/test-path.js @@ -216,51 +216,52 @@ var joinTests = // Windows-specific join tests if (isWindows) { joinTests = joinTests.concat( - [// UNC path expected - [['//foo/bar'], '//foo/bar/'], - [['\\/foo/bar'], '//foo/bar/'], - [['\\\\foo/bar'], '//foo/bar/'], - // UNC path expected - server and share separate - [['//foo', 'bar'], '//foo/bar/'], - [['//foo/', 'bar'], '//foo/bar/'], - [['//foo', '/bar'], '//foo/bar/'], - // UNC path expected - questionable - [['//foo', '', 'bar'], '//foo/bar/'], - [['//foo/', '', 'bar'], '//foo/bar/'], - [['//foo/', '', '/bar'], '//foo/bar/'], - // UNC path expected - even more questionable - [['', '//foo', 'bar'], '//foo/bar/'], - [['', '//foo/', 'bar'], '//foo/bar/'], - [['', '//foo/', '/bar'], '//foo/bar/'], - // No UNC path expected (no double slash in first component) - [['\\', 'foo/bar'], '/foo/bar'], - [['\\', '/foo/bar'], '/foo/bar'], - [['', '/', '/foo/bar'], '/foo/bar'], - // No UNC path expected (no non-slashes in first component - questionable) - [['//', 'foo/bar'], '/foo/bar'], - [['//', '/foo/bar'], '/foo/bar'], - [['\\\\', '/', '/foo/bar'], '/foo/bar'], - [['//'], '/'], - // No UNC path expected (share name missing - questionable). - [['//foo'], '/foo'], - [['//foo/'], '/foo/'], - [['//foo', '/'], '/foo/'], - [['//foo', '', '/'], '/foo/'], - // No UNC path expected (too many leading slashes - questionable) - [['///foo/bar'], '/foo/bar'], - [['////foo', 'bar'], '/foo/bar'], - [['\\\\\\/foo/bar'], '/foo/bar'], - // Drive-relative vs drive-absolute paths. This merely describes the - // status quo, rather than being obviously right - [['c:'], 'c:.'], - [['c:.'], 'c:.'], - [['c:', ''], 'c:.'], - [['', 'c:'], 'c:.'], - [['c:.', '/'], 'c:./'], - [['c:.', 'file'], 'c:file'], - [['c:', '/'], 'c:/'], - [['c:', 'file'], 'c:/file'] - ]); + [// UNC path expected + [['//foo/bar'], '//foo/bar/'], + [['\\/foo/bar'], '//foo/bar/'], + [['\\\\foo/bar'], '//foo/bar/'], + // UNC path expected - server and share separate + [['//foo', 'bar'], '//foo/bar/'], + [['//foo/', 'bar'], '//foo/bar/'], + [['//foo', '/bar'], '//foo/bar/'], + // UNC path expected - questionable + [['//foo', '', 'bar'], '//foo/bar/'], + [['//foo/', '', 'bar'], '//foo/bar/'], + [['//foo/', '', '/bar'], '//foo/bar/'], + // UNC path expected - even more questionable + [['', '//foo', 'bar'], '//foo/bar/'], + [['', '//foo/', 'bar'], '//foo/bar/'], + [['', '//foo/', '/bar'], '//foo/bar/'], + // No UNC path expected (no double slash in first component) + [['\\', 'foo/bar'], '/foo/bar'], + [['\\', '/foo/bar'], '/foo/bar'], + [['', '/', '/foo/bar'], '/foo/bar'], + // No UNC path expected + //(no non-slashes in first component - questionable) + [['//', 'foo/bar'], '/foo/bar'], + [['//', '/foo/bar'], '/foo/bar'], + [['\\\\', '/', '/foo/bar'], '/foo/bar'], + [['//'], '/'], + // No UNC path expected (share name missing - questionable). + [['//foo'], '/foo'], + [['//foo/'], '/foo/'], + [['//foo', '/'], '/foo/'], + [['//foo', '', '/'], '/foo/'], + // No UNC path expected (too many leading slashes - questionable) + [['///foo/bar'], '/foo/bar'], + [['////foo', 'bar'], '/foo/bar'], + [['\\\\\\/foo/bar'], '/foo/bar'], + // Drive-relative vs drive-absolute paths. This merely describes the + // status quo, rather than being obviously right + [['c:'], 'c:.'], + [['c:.'], 'c:.'], + [['c:', ''], 'c:.'], + [['', 'c:'], 'c:.'], + [['c:.', '/'], 'c:./'], + [['c:.', 'file'], 'c:file'], + [['c:', '/'], 'c:/'], + [['c:', 'file'], 'c:/file'] + ]); } // Run the join tests. diff --git a/test/simple/test-process-argv-0.js b/test/simple/test-process-argv-0.js index 0c38f6ac7bbf..2e38bbcb5325 100644 --- a/test/simple/test-process-argv-0.js +++ b/test/simple/test-process-argv-0.js @@ -27,8 +27,8 @@ var common = require('../common'); console.error('argv=%j', process.argv); console.error('exec=%j', process.execPath); -if (process.argv[2] !== "child") { - var child = spawn('./node', [__filename, "child"], { +if (process.argv[2] !== 'child') { + var child = spawn('./node', [__filename, 'child'], { cwd: path.dirname(process.execPath) }); @@ -40,7 +40,7 @@ if (process.argv[2] !== "child") { child.stderr.on('data', function(chunk) { childErr += chunk; }); - child.on('exit', function () { + child.on('exit', function() { console.error('CHILD: %s', childErr.trim().split('\n').join('\nCHILD: ')); if (process.platform === 'win32') { // On Windows argv[0] is not expanded into full path diff --git a/test/simple/test-process-binding.js b/test/simple/test-process-binding.js index c803a8083f22..d3fd1574b8b3 100644 --- a/test/simple/test-process-binding.js +++ b/test/simple/test-process-binding.js @@ -1,16 +1,16 @@ var assert = require('assert'); assert.throws( - function() { - process.binding('test'); - }, - /No such module: test/ + function() { + process.binding('test'); + }, + /No such module: test/ ); -assert.doesNotThrow(function () { +assert.doesNotThrow(function() { process.binding('buffer'); }, function(err) { - if ( (err instanceof Error) ) { + if ((err instanceof Error)) { return true; } -}, "unexpected error"); +}, 'unexpected error'); diff --git a/test/simple/test-process-exec-argv.js b/test/simple/test-process-exec-argv.js index 3d8450389571..7cf4aa88b62f 100644 --- a/test/simple/test-process-exec-argv.js +++ b/test/simple/test-process-exec-argv.js @@ -30,11 +30,11 @@ if (process.argv[2] === 'child') { var child = spawn(process.execPath, execArgv.concat(args)); var out = ''; - child.stdout.on('data', function (chunk) { + child.stdout.on('data', function(chunk) { out += chunk; }); - child.on('exit', function () { + child.on('exit', function() { assert.deepEqual(JSON.parse(out), execArgv); }); } diff --git a/test/simple/test-process-exit-code.js b/test/simple/test-process-exit-code.js index 2488175d3d2d..a58aa7903d4d 100644 --- a/test/simple/test-process-exit-code.js +++ b/test/simple/test-process-exit-code.js @@ -93,7 +93,7 @@ function test(arg, exit) { var spawn = require('child_process').spawn; var node = process.execPath; var f = __filename; - var option = { stdio: [ 0, 1, 'ignore' ] }; + var option = { stdio: [0, 1, 'ignore'] }; spawn(node, [f, arg], option).on('exit', function(code) { assert.equal(code, exit, 'wrong exit for ' + arg + '\nexpected:' + exit + diff --git a/test/simple/test-process-hrtime.js b/test/simple/test-process-hrtime.js index d8ffcafa9cc5..ed97a58cf861 100644 --- a/test/simple/test-process-hrtime.js +++ b/test/simple/test-process-hrtime.js @@ -39,7 +39,7 @@ assert.throws(function() { function validateTuple(tuple) { assert(Array.isArray(tuple)); assert.equal(2, tuple.length); - tuple.forEach(function (v) { + tuple.forEach(function(v) { assert.equal('number', typeof v); assert(isFinite(v)); }); diff --git a/test/simple/test-process-kill-pid.js b/test/simple/test-process-kill-pid.js index 6e4e7d83a7da..724e7a04fdf1 100644 --- a/test/simple/test-process-kill-pid.js +++ b/test/simple/test-process-kill-pid.js @@ -42,8 +42,8 @@ assert.throws(function() { process.kill('SIGTERM'); }, TypeError); assert.throws(function() { process.kill(null); }, TypeError); assert.throws(function() { process.kill(undefined); }, TypeError); assert.throws(function() { process.kill(+'not a number'); }, TypeError); -assert.throws(function() { process.kill(1/0); }, TypeError); -assert.throws(function() { process.kill(-1/0); }, TypeError); +assert.throws(function() { process.kill(1 / 0); }, TypeError); +assert.throws(function() { process.kill(-1 / 0); }, TypeError); // Test kill argument processing in valid cases. // diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js index 6bb3fe7c6913..68ce7acee172 100644 --- a/test/simple/test-querystring.js +++ b/test/simple/test-querystring.js @@ -238,8 +238,8 @@ function demoDecode(str) { return str + str; } assert.deepEqual( - qs.parse('a=a&b=b&c=c', null, null, { decodeURIComponent: demoDecode }), - { aa: 'aa', bb: 'bb', cc: 'cc' }); + qs.parse('a=a&b=b&c=c', null, null, { decodeURIComponent: demoDecode }), + { aa: 'aa', bb: 'bb', cc: 'cc' }); // Test custom encode @@ -248,12 +248,12 @@ function demoEncode(str) { } var obj = { aa: 'aa', bb: 'bb', cc: 'cc' }; assert.equal( - qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }), - 'a=a&b=b&c=c'); + qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }), + 'a=a&b=b&c=c'); // test overriding .unescape var prevUnescape = qs.unescape; -qs.unescape = function (str) { +qs.unescape = function(str) { return str.replace(/o/g, '_'); }; assert.deepEqual(qs.parse('foo=bor'), {f__: 'b_r'}); diff --git a/test/simple/test-readline-interface.js b/test/simple/test-readline-interface.js index b86dd5a8a9bd..7b75e371dbbc 100644 --- a/test/simple/test-readline-interface.js +++ b/test/simple/test-readline-interface.js @@ -43,7 +43,8 @@ function isWarned(emitter) { return false; } -[ true, false ].forEach(function(terminal) { +var temp = [true, false]; +temp.forEach(function(terminal) { var fi; var rli; var called; @@ -121,7 +122,7 @@ function isWarned(emitter) { assert.equal(callCount, expectedLines.length - 1); rli.close(); - // sending multiple newlines at once that does not end with a new(empty) + // sending multiple newlines at once that does not end with a new(empty) // line and a `end` event fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: terminal }); @@ -133,7 +134,7 @@ function isWarned(emitter) { }); rli.on('close', function() { callCount++; - }) + }); fi.emit('data', expectedLines.join('\n')); fi.emit('end'); assert.equal(callCount, expectedLines.length); @@ -187,7 +188,7 @@ function isWarned(emitter) { // \r at start of input should output blank line fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: true }); - expectedLines = ['', 'foo' ]; + expectedLines = ['', 'foo']; callCount = 0; rli.on('line', function(line) { assert.equal(line, expectedLines[callCount]); @@ -221,11 +222,11 @@ function isWarned(emitter) { ['\x1b[31m'], ['\x1b[31m', '\x1b[39m'], ['\x1b[31m', 'a', '\x1b[39m', 'a'] - ].forEach(function (keypresses) { + ].forEach(function(keypresses) { fi = new FakeInput(); callCount = 0; var remainingKeypresses = keypresses.slice(); - function keypressListener (ch, key) { + function keypressListener(ch, key) { callCount++; if (ch) assert(!key.code); assert.equal(key.sequence, remainingKeypresses.shift()); @@ -285,9 +286,12 @@ function isWarned(emitter) { assert.equal(readline.getStringWidth('A\ud83c\ude00BC'), 5); // surrogate // check if vt control chars are stripped - assert.equal(readline.stripVTControlCharacters('\u001b[31m> \u001b[39m'), '> '); - assert.equal(readline.stripVTControlCharacters('\u001b[31m> \u001b[39m> '), '> > '); - assert.equal(readline.stripVTControlCharacters('\u001b[31m\u001b[39m'), ''); + assert.equal(readline. + stripVTControlCharacters('\u001b[31m> \u001b[39m'), '> '); + assert.equal(readline. + stripVTControlCharacters('\u001b[31m> \u001b[39m> '), '> > '); + assert.equal(readline. + stripVTControlCharacters('\u001b[31m\u001b[39m'), ''); assert.equal(readline.stripVTControlCharacters('> '), '> '); assert.equal(readline.getStringWidth('\u001b[31m> \u001b[39m'), 2); assert.equal(readline.getStringWidth('\u001b[31m> \u001b[39m> '), 4); @@ -297,7 +301,7 @@ function isWarned(emitter) { assert.deepEqual(fi.listeners(terminal ? 'keypress' : 'data'), []); // check EventEmitter memory leak - for (var i=0; i<12; i++) { + for (var i = 0; i < 12; i++) { var rl = readline.createInterface({ input: process.stdin, output: process.stdout @@ -320,7 +324,7 @@ function isWarned(emitter) { assert.ok(called); assert.doesNotThrow(function() { - rli.setPrompt("ddd> "); + rli.setPrompt('ddd> '); }); assert.doesNotThrow(function() { @@ -332,10 +336,10 @@ function isWarned(emitter) { }); assert.doesNotThrow(function() { - rli.question("What do you think of node.js? ", function(answer) { - console.log("Thank you for your valuable feedback:", answer); + rli.question('What do you think of node.js? ', function(answer) { + console.log('Thank you for your valuable feedback:', answer); rli.close(); - }) + }); }); }); diff --git a/test/simple/test-regress-GH-1726.js b/test/simple/test-regress-GH-1726.js index f65e63d10ba9..0e1e16b2c3fa 100644 --- a/test/simple/test-regress-GH-1726.js +++ b/test/simple/test-regress-GH-1726.js @@ -38,7 +38,7 @@ if (gen === maxGen) { } var child = ch.spawn(process.execPath, [__filename, gen + 1], { - stdio: [ 'ignore', 'pipe', 'ignore' ] + stdio: ['ignore', 'pipe', 'ignore'] }); assert.ok(!child.stdin); assert.ok(child.stdout); diff --git a/test/simple/test-regress-GH-3542.js b/test/simple/test-regress-GH-3542.js index 90e0b78501a6..6db495a9c65e 100644 --- a/test/simple/test-regress-GH-3542.js +++ b/test/simple/test-regress-GH-3542.js @@ -43,12 +43,12 @@ function test(p) { test('//localhost/c$/windows/system32'); test('//localhost/c$/windows'); -test('//localhost/c$/') -test('\\\\localhost\\c$') +test('//localhost/c$/'); +test('\\\\localhost\\c$'); test('c:\\'); test('c:'); test(process.env.windir); process.on('exit', function() { assert.strictEqual(succeeded, 7); -}); \ No newline at end of file +}); diff --git a/test/simple/test-regress-GH-4015.js b/test/simple/test-regress-GH-4015.js index b66584f80488..48d8035eec98 100644 --- a/test/simple/test-regress-GH-4015.js +++ b/test/simple/test-regress-GH-4015.js @@ -23,10 +23,8 @@ var common = require('../common'); var assert = require('assert'); var exec = require('child_process').exec; -var cmd = process.execPath - + ' ' - + common.fixturesDir - + '/test-regress-GH-4015.js'; +var cmd = process.execPath + ' ' + + common.fixturesDir + '/test-regress-GH-4015.js'; exec(cmd, function(err, stdout, stderr) { assert(/RangeError: Maximum call stack size exceeded/.test(stderr)); diff --git a/test/simple/test-regress-GH-4256.js b/test/simple/test-regress-GH-4256.js index 9f937cc099a6..2f33b3f542fb 100644 --- a/test/simple/test-regress-GH-4256.js +++ b/test/simple/test-regress-GH-4256.js @@ -21,5 +21,5 @@ process.domain = null; timer = setTimeout(function() { - console.log("this console.log statement should not make node crash"); + console.log('this console.log statement should not make node crash'); }, 1); diff --git a/test/simple/test-regress-GH-4948.js b/test/simple/test-regress-GH-4948.js index 5e717fad56fd..631bf7f61da7 100644 --- a/test/simple/test-regress-GH-4948.js +++ b/test/simple/test-regress-GH-4948.js @@ -25,7 +25,7 @@ var common = require('../common'); var http = require('http'); var reqCount = 0; -var server = http.createServer(function(serverReq, serverRes){ +var server = http.createServer(function(serverReq, serverRes) { if (reqCount) { serverRes.end(); server.close(); @@ -36,14 +36,14 @@ var server = http.createServer(function(serverReq, serverRes){ // normally the use case would be to call an external site // does not require connecting locally or to itself to fail - var r = http.request({hostname: 'localhost', port: common.PORT}, function(res) { - // required, just needs to be in the client response somewhere - serverRes.end(); - - // required for test to fail - res.on('data', function(data) { }); - - }); + var r = http.request({hostname: 'localhost', port: common.PORT}, + function(res) { + // required, just needs to be in the client response somewhere + serverRes.end(); + + // required for test to fail + res.on('data', function(data) { }); + }); r.on('error', function(e) {}); r.end(); @@ -59,4 +59,4 @@ sock.connect(common.PORT, 'localhost'); sock.on('connect', function() { sock.write('GET / HTTP/1.1\r\n\r\n'); sock.end(); -}); \ No newline at end of file +}); diff --git a/test/simple/test-regress-GH-5927.js b/test/simple/test-regress-GH-5927.js index 5f8f276616c6..6eaed63ea45b 100644 --- a/test/simple/test-regress-GH-5927.js +++ b/test/simple/test-regress-GH-5927.js @@ -31,12 +31,12 @@ var origPause = rl.pause; rl.pause = function() { hasPaused = true; origPause.apply(this, arguments); -} +}; var origSetRawMode = rl._setRawMode; rl._setRawMode = function(mode) { assert.ok(hasPaused); origSetRawMode.apply(this, arguments); -} +}; rl.close(); diff --git a/test/simple/test-regress-GH-7511.js b/test/simple/test-regress-GH-7511.js index 9694f0499e29..5fc0b2e69e7f 100644 --- a/test/simple/test-regress-GH-7511.js +++ b/test/simple/test-regress-GH-7511.js @@ -21,10 +21,10 @@ var common = require('../common'), assert = require('assert'), - vm = require('vm'); + vm = require('vm'); assert.doesNotThrow(function() { var context = vm.createContext({ process: process }); - var result = vm.runInContext('process.env["PATH"]', context); + var result = vm.runInContext('process.env["PATH"]', context); assert.notEqual(undefined, result); }); diff --git a/test/simple/test-regress-GH-9161.js b/test/simple/test-regress-GH-9161.js index 126ad8294175..cb33a52085b2 100644 --- a/test/simple/test-regress-GH-9161.js +++ b/test/simple/test-regress-GH-9161.js @@ -24,7 +24,7 @@ var assert = require('assert'); var path = require('path'); var fs = require('fs'); var tmp = common.tmpDir; -if (!fs.existsSync(tmp)) +if (!fs.existsSync(tmp)) fs.mkdirSync(tmp); var filename = path.resolve(tmp, 'truncate-file.txt'); diff --git a/test/simple/test-repl-autolibs.js b/test/simple/test-repl-autolibs.js index b6f9294711da..481cb7ef7554 100644 --- a/test/simple/test-repl-autolibs.js +++ b/test/simple/test-repl-autolibs.js @@ -25,9 +25,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 + '\n'); }); } @@ -35,17 +35,17 @@ 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 putIn = new ArrayStream; var testMe = repl.start('', putIn, null, true); test1(); -function test1(){ +function test1() { var gotWrite = false; - putIn.write = function (data) { + putIn.write = function(data) { gotWrite = true; if (data.length) { @@ -61,7 +61,7 @@ function test1(){ assert(gotWrite); } -function test2(){ +function test2() { var gotWrite = false; putIn.write = function(data) { gotWrite = true; diff --git a/test/simple/test-repl-console.js b/test/simple/test-repl-console.js index 3dca14b7f3f5..107627d097e3 100644 --- a/test/simple/test-repl-console.js +++ b/test/simple/test-repl-console.js @@ -26,7 +26,7 @@ var common = require('../common'), // create a dummy stream that does nothing var stream = new Stream(); -stream.write = stream.pause = stream.resume = function(){}; +stream.write = stream.pause = stream.resume = function() {}; stream.readable = stream.writable = true; var r = repl.start({ diff --git a/test/simple/test-repl-domain.js b/test/simple/test-repl-domain.js index 55b7dc475efb..8bd0c50ceb1b 100644 --- a/test/simple/test-repl-domain.js +++ b/test/simple/test-repl-domain.js @@ -22,8 +22,8 @@ var assert = require('assert'); var common = require('../common.js'); -var util = require('util'); -var repl = require('repl'); +var util = require('util'); +var repl = require('repl'); // A stream to push an array into a REPL function ArrayStream() { @@ -47,15 +47,15 @@ putIn.write = function(data) { // Don't use assert for this because the domain might catch it, and // give a false negative. Don't throw, just print and exit. if (data === 'OK\n') { - console.log('ok'); + console.log('ok'); } else { - console.error(data); - process.exit(1); + console.error(data); + process.exit(1); } }; putIn.run([ - 'require("domain").create().on("error", function () { console.log("OK") })' - + '.run(function () { throw new Error("threw") })' + 'require("domain").create().on("error", function () { console.log("OK") })' + + '.run(function () { throw new Error("threw") })' ]); diff --git a/test/simple/test-repl-end-emits-exit.js b/test/simple/test-repl-end-emits-exit.js index 46eca2efbf6a..b21bab443642 100644 --- a/test/simple/test-repl-end-emits-exit.js +++ b/test/simple/test-repl-end-emits-exit.js @@ -28,7 +28,7 @@ var common = require('../common'), // create a dummy stream that does nothing var stream = new Stream(); -stream.write = stream.pause = stream.resume = function(){}; +stream.write = stream.pause = stream.resume = function() {}; stream.readable = stream.writable = true; function testTerminalMode() { diff --git a/test/simple/test-repl-options.js b/test/simple/test-repl-options.js index 94a622da2609..c179bdce7aca 100644 --- a/test/simple/test-repl-options.js +++ b/test/simple/test-repl-options.js @@ -28,7 +28,7 @@ common.globalCheck = false; // create a dummy stream that does nothing var stream = new Stream(); -stream.write = stream.pause = stream.resume = function(){}; +stream.write = stream.pause = stream.resume = function() {}; stream.readable = stream.writable = true; // 1, mostly defaults diff --git a/test/simple/test-repl-reset-event.js b/test/simple/test-repl-reset-event.js index 3554d17b9e4c..14ce1dc06ba7 100644 --- a/test/simple/test-repl-reset-event.js +++ b/test/simple/test-repl-reset-event.js @@ -28,7 +28,7 @@ var Stream = require('stream'); // create a dummy stream that does nothing var dummy = new Stream(); -dummy.write = dummy.pause = dummy.resume = function(){}; +dummy.write = dummy.pause = dummy.resume = function() {}; dummy.readable = dummy.writable = true; function testReset(cb) { @@ -41,7 +41,9 @@ function testReset(cb) { r.on('reset', function(context) { assert(!!context, 'REPL did not emit a context with reset event'); assert.equal(context, r.context, 'REPL emitted incorrect context'); - assert.equal(context.foo, undefined, 'REPL emitted the previous context, and is not using global as context'); + assert.equal(context.foo, undefined, + 'REPL emitted the previous context,' + + 'and is not using global as context'); context.foo = 42; cb(); }); @@ -56,7 +58,8 @@ function testResetGlobal(cb) { }); r.context.foo = 42; r.on('reset', function(context) { - assert.equal(context.foo, 42, '"foo" property is missing from REPL using global as context'); + assert.equal(context.foo, 42, + '"foo" property is missing from REPL using global as context'); cb(); }); r.resetContext(); diff --git a/test/simple/test-repl-setprompt.js b/test/simple/test-repl-setprompt.js index e5021c2356c1..8870115f135e 100644 --- a/test/simple/test-repl-setprompt.js +++ b/test/simple/test-repl-setprompt.js @@ -27,10 +27,10 @@ var common = require('../common'), var args = [ '-e', - 'var e = new (require("repl")).REPLServer("foo.. "); e.context.e = e;', + 'var e = new (require("repl")).REPLServer("foo.. "); e.context.e = e;' ]; -var p = "bar.. "; +var p = 'bar.. '; var child = spawn(process.execPath, args); diff --git a/test/simple/test-repl-tab-complete.js b/test/simple/test-repl-tab-complete.js index 684063831b5b..3dc1278fcfe9 100644 --- a/test/simple/test-repl-tab-complete.js +++ b/test/simple/test-repl-tab-complete.js @@ -202,7 +202,7 @@ var spaceTimeout = setTimeout(function() { }, 1000); testMe.complete(' ', function(error, data) { - assert.deepEqual(data, [[],undefined]); + assert.deepEqual(data, [[], undefined]); clearTimeout(spaceTimeout); }); diff --git a/test/simple/test-repl-timeout-throw.js b/test/simple/test-repl-timeout-throw.js index 28f370909b28..d47c9535adb5 100644 --- a/test/simple/test-repl-timeout-throw.js +++ b/test/simple/test-repl-timeout-throw.js @@ -24,7 +24,7 @@ var common = require('../common.js'); var spawn = require('child_process').spawn; -var child = spawn(process.execPath, [ '-i' ], { +var child = spawn(process.execPath, ['-i'], { stdio: [null, null, 2] }); diff --git a/test/simple/test-repl.js b/test/simple/test-repl.js index 69b9b54d1e9e..9550e08e9a92 100644 --- a/test/simple/test-repl.js +++ b/test/simple/test-repl.js @@ -75,7 +75,7 @@ function error_test() { client_unix.on('data', function(data) { read_buffer += data.toString('ascii', 0, data.length); console.error('Unix data: ' + JSON.stringify(read_buffer) + ', expecting ' + - (client_unix.expect.exec ? + (client_unix.expect.exec ? client_unix.expect : JSON.stringify(client_unix.expect))); @@ -112,6 +112,17 @@ function error_test() { } }); + var dupDataPropertyRegExp = new RegExp('^SyntaxError: Duplicate' + + 'data property in object literal not allowed in strict mode'); + var dupParamNameRegExp = new RegExp('^SyntaxError: Strict mode' + + 'function may not have duplicate parameter names'); + var includeWithStmtRegExp = new RegExp('^SyntaxError: Strict mode' + + 'code may not include a with statement'); + var delUnqualifiedIdentifierStrictRegExp = new RegExp('^SyntaxError: Delete' + + 'of an unqualified identifier in strict mode'); + var immediateWithinFuncRegExp = new RegExp('^SyntaxError: In strict' + + 'mode code, functions can only be declared at top level or' + + 'immediately within another function'); send_expect([ // Uncaught error throws and prints out { client: client_unix, send: 'throw new Error(\'test error\');', @@ -154,20 +165,26 @@ function error_test() { { client: client_unix, send: 'new RegExp("foo", "wrong modifier");', expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ }, // strict mode syntax errors should be caught (GH-5178) - { client: client_unix, send: '(function() { "use strict"; return 0755; })()', + { client: client_unix, send: + '(function() { "use strict"; return 0755; })()', expect: /^SyntaxError: Octal literals are not allowed in strict mode/ }, - { client: client_unix, send: '(function() { "use strict"; return { p: 1, p: 2 }; })()', - expect: /^SyntaxError: Duplicate data property in object literal not allowed in strict mode/ }, - { client: client_unix, send: '(function(a, a, b) { "use strict"; return a + b + c; })()', - expect: /^SyntaxError: Strict mode function may not have duplicate parameter names/ }, - { client: client_unix, send: '(function() { "use strict"; with (this) {} })()', - expect: /^SyntaxError: Strict mode code may not include a with statement/ }, - { client: client_unix, send: '(function() { "use strict"; var x; delete x; })()', - expect: /^SyntaxError: Delete of an unqualified identifier in strict mode/ }, + { client: client_unix, send: + '(function() { "use strict"; return { p: 1, p: 2 }; })()', + expect: dupDataPropertyRegExp}, + { client: client_unix, + send: '(function(a, a, b) { "use strict"; return a + b + c; })()', + expect: dupParamNameRegExp}, + { client: client_unix, + send: '(function() { "use strict"; with (this) {} })()', + expect: includeWithStmtRegExp}, + { client: client_unix, + send: '(function() { "use strict"; var x; delete x; })()', + expect: delUnqualifiedIdentifierStrictRegExp}, { client: client_unix, send: '(function() { "use strict"; eval = 17; })()', expect: /^SyntaxError: Unexpected eval or arguments in strict mode/ }, - { client: client_unix, send: '(function() { "use strict"; if (true){ function f() { } } })()', - expect: /^SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function/ }, + { client: client_unix, + send: '(function() { "use strict"; if (true){ function f() { } } })()', + expect: immediateWithinFuncRegExp}, // Named functions can be used: { client: client_unix, send: 'function blah() { return 1; }', expect: prompt_unix }, @@ -240,7 +257,7 @@ function tcp_test() { client_tcp.on('data', function(data) { read_buffer += data.toString('ascii', 0, data.length); console.error('TCP data: ' + JSON.stringify(read_buffer) + - ', expecting ' + JSON.stringify(client_tcp.expect)); + ', expecting ' + JSON.stringify(client_tcp.expect)); if (read_buffer.indexOf(prompt_tcp) !== -1) { assert.strictEqual(client_tcp.expect, read_buffer); console.error('match'); @@ -309,7 +326,7 @@ function unix_test() { client_unix.on('data', function(data) { read_buffer += data.toString('ascii', 0, data.length); console.error('Unix data: ' + JSON.stringify(read_buffer) + - ', expecting ' + JSON.stringify(client_unix.expect)); + ', expecting ' + JSON.stringify(client_unix.expect)); if (read_buffer.indexOf(prompt_unix) !== -1) { assert.strictEqual(client_unix.expect, read_buffer); console.error('match'); diff --git a/test/simple/test-socket-write-after-fin-error.js b/test/simple/test-socket-write-after-fin-error.js index 123557417ccc..3208d52c3a72 100644 --- a/test/simple/test-socket-write-after-fin-error.js +++ b/test/simple/test-socket-write-after-fin-error.js @@ -45,7 +45,7 @@ var server = net.createServer(function(sock) { serverData += c; }); sock.on('end', function() { - gotServerEnd = true + gotServerEnd = true; sock.write(serverData); sock.end(); }); diff --git a/test/simple/test-socket-write-after-fin.js b/test/simple/test-socket-write-after-fin.js index 88d780b81e87..d04bdfd148b9 100644 --- a/test/simple/test-socket-write-after-fin.js +++ b/test/simple/test-socket-write-after-fin.js @@ -33,7 +33,7 @@ var server = net.createServer({ allowHalfOpen: true }, function(sock) { serverData += c; }); sock.on('end', function() { - gotServerEnd = true + gotServerEnd = true; sock.end(serverData); server.close(); }); diff --git a/test/simple/test-stream-big-packet.js b/test/simple/test-stream-big-packet.js index 9ec29ca0dcc6..7da536ce6124 100644 --- a/test/simple/test-stream-big-packet.js +++ b/test/simple/test-stream-big-packet.js @@ -26,20 +26,20 @@ var stream = require('stream'); var passed = false; -function PassThrough () { +function PassThrough() { stream.Transform.call(this); -}; +} util.inherits(PassThrough, stream.Transform); -PassThrough.prototype._transform = function (chunk, encoding, done) { +PassThrough.prototype._transform = function(chunk, encoding, done) { this.push(chunk); done(); }; -function TestStream () { +function TestStream() { stream.Transform.call(this); -}; +} util.inherits(TestStream, stream.Transform); -TestStream.prototype._transform = function (chunk, encoding, done) { +TestStream.prototype._transform = function(chunk, encoding, done) { if (!passed) { // Char 'a' only exists in the last write passed = chunk.toString().indexOf('a') >= 0; @@ -68,6 +68,6 @@ assert(s2.write('tiny')); setImmediate(s1.write.bind(s1), 'later'); // Assert after two IO loops when all operations have been done. -process.on('exit', function () { +process.on('exit', function() { assert(passed, 'Large buffer is not handled properly by Writable Stream'); }); diff --git a/test/simple/test-stream-duplex.js b/test/simple/test-stream-duplex.js index 61f314939b0e..9bddc3e8ca66 100644 --- a/test/simple/test-stream-duplex.js +++ b/test/simple/test-stream-duplex.js @@ -32,21 +32,21 @@ assert(stream._writableState.objectMode); var written; var read; -stream._write = function (obj, _, cb) { +stream._write = function(obj, _, cb) { written = obj; cb(); }; -stream._read = function () {}; +stream._read = function() {}; -stream.on('data', function (obj) { +stream.on('data', function(obj) { read = obj; }); stream.push({ val: 1 }); stream.end({ val: 2 }); -process.on('exit', function () { +process.on('exit', function() { assert(read.val === 1); assert(written.val === 2); }); diff --git a/test/simple/test-stream-push-order.js b/test/simple/test-stream-push-order.js index f2e6ec29ce34..6236519b5e68 100644 --- a/test/simple/test-stream-push-order.js +++ b/test/simple/test-stream-push-order.js @@ -30,7 +30,7 @@ var s = new Readable({ var list = ['1', '2', '3', '4', '5', '6']; -s._read = function (n) { +s._read = function(n) { var one = list.shift(); if (!one) { s.push(null); @@ -45,8 +45,8 @@ var v = s.read(0); // ACTUALLY [1, 3, 5, 6, 4, 2] -process.on("exit", function () { +process.on('exit', function() { assert.deepEqual(s._readableState.buffer, ['1', '2', '3', '4', '5', '6']); - console.log("ok"); + console.log('ok'); }); diff --git a/test/simple/test-stream-push-strings.js b/test/simple/test-stream-push-strings.js index 06f43dc1c86e..2e69eeca5b4a 100644 --- a/test/simple/test-stream-push-strings.js +++ b/test/simple/test-stream-push-strings.js @@ -58,7 +58,7 @@ ms.on('readable', function() { results.push(chunk + ''); }); -var expect = [ 'first chunksecond to last chunk', 'last chunk' ]; +var expect = ['first chunksecond to last chunk', 'last chunk']; process.on('exit', function() { assert.equal(ms._chunks, -1); assert.deepEqual(results, expect); diff --git a/test/simple/test-stream-transform-objectmode-falsey-value.js b/test/simple/test-stream-transform-objectmode-falsey-value.js index 31b5bbaaf5b6..f30000cd3f3e 100644 --- a/test/simple/test-stream-transform-objectmode-falsey-value.js +++ b/test/simple/test-stream-transform-objectmode-falsey-value.js @@ -29,7 +29,7 @@ var src = new PassThrough({ objectMode: true }); var tx = new PassThrough({ objectMode: true }); var dest = new PassThrough({ objectMode: true }); -var expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; +var expect = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var results = []; process.on('exit', function() { assert.deepEqual(results, expect); diff --git a/test/simple/test-stream-transform-split-objectmode.js b/test/simple/test-stream-transform-split-objectmode.js index 72a2f0acecbc..49c86ec7e833 100644 --- a/test/simple/test-stream-transform-split-objectmode.js +++ b/test/simple/test-stream-transform-split-objectmode.js @@ -24,49 +24,49 @@ var assert = require('assert'); var Transform = require('stream').Transform; -var parser = new Transform({ readableObjectMode : true }); +var parser = new Transform({ readableObjectMode: true }); assert(parser._readableState.objectMode); assert(!parser._writableState.objectMode); assert(parser._readableState.highWaterMark === 16); assert(parser._writableState.highWaterMark === (16 * 1024)); -parser._transform = function (chunk, enc, callback) { - callback(null, { val : chunk[0] }); +parser._transform = function(chunk, enc, callback) { + callback(null, { val: chunk[0] }); }; var parsed; -parser.on('data', function (obj) { +parser.on('data', function(obj) { parsed = obj; }); parser.end(new Buffer([42])); -process.on('exit', function () { +process.on('exit', function() { assert(parsed.val === 42); }); -var serializer = new Transform({ writableObjectMode : true }); +var serializer = new Transform({ writableObjectMode: true }); assert(!serializer._readableState.objectMode); assert(serializer._writableState.objectMode); assert(serializer._readableState.highWaterMark === (16 * 1024)); assert(serializer._writableState.highWaterMark === 16); -serializer._transform = function (obj, _, callback) { +serializer._transform = function(obj, _, callback) { callback(null, new Buffer([obj.val])); }; var serialized; -serializer.on('data', function (chunk) { +serializer.on('data', function(chunk) { serialized = chunk; }); -serializer.write({ val : 42 }); +serializer.write({ val: 42 }); -process.on('exit', function () { +process.on('exit', function() { assert(serialized[0] === 42); }); diff --git a/test/simple/test-stream-unshift-empty-chunk.js b/test/simple/test-stream-unshift-empty-chunk.js index 0c9647650f2b..9a7515a3778d 100644 --- a/test/simple/test-stream-unshift-empty-chunk.js +++ b/test/simple/test-stream-unshift-empty-chunk.js @@ -22,7 +22,7 @@ var common = require('../common'); var assert = require('assert'); -// This test verifies that stream.unshift(Buffer(0)) or +// This test verifies that stream.unshift(Buffer(0)) or // stream.unshift('') does not set state.reading=false. var Readable = require('stream').Readable; @@ -56,24 +56,24 @@ r.on('readable', function() { }); var expect = - [ 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy', - 'xxxxxxxxxx', - 'yyyyy' ]; + ['xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy', + 'xxxxxxxxxx', + 'yyyyy']; r.on('end', function() { assert.deepEqual(seen, expect); diff --git a/test/simple/test-stream-writable-change-default-encoding.js b/test/simple/test-stream-writable-change-default-encoding.js index eb71cf2b4a69..23075232ae5b 100644 --- a/test/simple/test-stream-writable-change-default-encoding.js +++ b/test/simple/test-stream-writable-change-default-encoding.js @@ -28,11 +28,11 @@ var util = require('util'); function MyWritable(fn, options) { stream.Writable.call(this, options); this.fn = fn; -}; +} util.inherits(MyWritable, stream.Writable); -MyWritable.prototype._write = function (chunk, encoding, callback) { +MyWritable.prototype._write = function(chunk, encoding, callback) { this.fn(Buffer.isBuffer(chunk), typeof chunk, encoding); callback(); }; diff --git a/test/simple/test-stream-writable-decoded-encoding.js b/test/simple/test-stream-writable-decoded-encoding.js index 8e2624b259ff..b5c21d777c2a 100644 --- a/test/simple/test-stream-writable-decoded-encoding.js +++ b/test/simple/test-stream-writable-decoded-encoding.js @@ -28,16 +28,16 @@ var util = require('util'); function MyWritable(fn, options) { stream.Writable.call(this, options); this.fn = fn; -}; +} util.inherits(MyWritable, stream.Writable); -MyWritable.prototype._write = function (chunk, encoding, callback) { +MyWritable.prototype._write = function(chunk, encoding, callback) { this.fn(Buffer.isBuffer(chunk), typeof chunk, encoding); callback(); }; -;(function decodeStringsTrue() { +(function decodeStringsTrue() { var m = new MyWritable(function(isBuffer, type, enc) { assert(isBuffer); assert.equal(type, 'object'); @@ -48,7 +48,7 @@ MyWritable.prototype._write = function (chunk, encoding, callback) { m.end(); })(); -;(function decodeStringsFalse() { +(function decodeStringsFalse() { var m = new MyWritable(function(isBuffer, type, enc) { assert(!isBuffer); assert.equal(type, 'string'); diff --git a/test/simple/test-stream-writev.js b/test/simple/test-stream-writev.js index 5b49e6e4163c..a6b10a3947a2 100644 --- a/test/simple/test-stream-writev.js +++ b/test/simple/test-stream-writev.js @@ -73,7 +73,8 @@ function test(decode, uncork, multi, next) { { encoding: 'buffer', chunk: [10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46] }, { encoding: 'buffer', - chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173] }] : + chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173] + }] : [{ encoding: 'ascii', chunk: 'hello, ' }, { encoding: 'utf8', chunk: 'world' }, { encoding: 'buffer', chunk: [33] }, diff --git a/test/simple/test-stream2-base64-single-char-read-end.js b/test/simple/test-stream2-base64-single-char-read-end.js index 5a3834128c67..1dd900f508d8 100644 --- a/test/simple/test-stream2-base64-single-char-read-end.js +++ b/test/simple/test-stream2-base64-single-char-read-end.js @@ -32,13 +32,13 @@ var accum = []; var timeout; src._read = function(n) { - if(!hasRead) { + if (!hasRead) { hasRead = true; process.nextTick(function() { src.push(new Buffer('1')); src.push(null); }); - }; + } }; dst._write = function(chunk, enc, cb) { @@ -49,7 +49,7 @@ dst._write = function(chunk, enc, cb) { src.on('end', function() { assert.equal(Buffer.concat(accum) + '', 'MQ=='); clearTimeout(timeout); -}) +}); src.pipe(dst); diff --git a/test/simple/test-stream2-fs.js b/test/simple/test-stream2-fs.js index e16240628771..4681aa03c5f6 100644 --- a/test/simple/test-stream2-fs.js +++ b/test/simple/test-stream2-fs.js @@ -54,7 +54,7 @@ TestWriter.prototype.write = function(c) { TestWriter.prototype.end = function(c) { if (c) this.buffer.push(c.toString()); this.emit('results', this.buffer); -} +}; var r = new FSReadable(file); var w = new TestWriter(); @@ -63,7 +63,7 @@ w.on('results', function(res) { console.error(res, w.length); assert.equal(w.length, size); var l = 0; - assert.deepEqual(res.map(function (c) { + assert.deepEqual(res.map(function(c) { return c.length; }), expectLengths); console.log('ok'); diff --git a/test/simple/test-stream2-push.js b/test/simple/test-stream2-push.js index b63edc308460..4d0e61ffe70b 100644 --- a/test/simple/test-stream2-push.js +++ b/test/simple/test-stream2-push.js @@ -83,12 +83,12 @@ var writer = new Writable({ var written = []; var expectWritten = - [ 'asdfgasdfgasdfgasdfg', - 'asdfgasdfgasdfgasdfg', - 'asdfgasdfgasdfgasdfg', - 'asdfgasdfgasdfgasdfg', - 'asdfgasdfgasdfgasdfg', - 'asdfgasdfgasdfgasdfg' ]; + ['asdfgasdfgasdfgasdfg', + 'asdfgasdfgasdfgasdfg', + 'asdfgasdfgasdfgasdfg', + 'asdfgasdfgasdfgasdfg', + 'asdfgasdfgasdfgasdfg', + 'asdfgasdfgasdfgasdfg']; writer._write = function(chunk, encoding, cb) { console.error('WRITE %s', chunk); @@ -101,7 +101,7 @@ writer.on('finish', finish); // now emit some chunks. -var chunk = "asdfg"; +var chunk = 'asdfg'; var set = 0; readStart(); diff --git a/test/simple/test-stream2-readable-empty-buffer-no-eof.js b/test/simple/test-stream2-readable-empty-buffer-no-eof.js index d52af5edb80d..97b4b4b1a115 100644 --- a/test/simple/test-stream2-readable-empty-buffer-no-eof.js +++ b/test/simple/test-stream2-readable-empty-buffer-no-eof.js @@ -84,7 +84,7 @@ function test1() { flow(); process.on('exit', function() { - assert.deepEqual(results, [ 'xxxxx', 'xxxxx', 'EOF' ]); + assert.deepEqual(results, ['xxxxx', 'xxxxx', 'EOF']); console.log('ok'); }); } @@ -112,7 +112,7 @@ function test2() { flow(); process.on('exit', function() { - assert.deepEqual(results, [ 'eHh4', 'eHg=', 'EOF' ]); + assert.deepEqual(results, ['eHh4', 'eHg=', 'EOF']); console.log('ok'); }); } diff --git a/test/simple/test-stream2-readable-from-list.js b/test/simple/test-stream2-readable-from-list.js index 7c96ffe00c4e..6a9152882f53 100644 --- a/test/simple/test-stream2-readable-from-list.js +++ b/test/simple/test-stream2-readable-from-list.js @@ -43,7 +43,7 @@ function run() { fn({ same: assert.deepEqual, equal: assert.equal, - end: function () { + end: function() { count--; run(); } @@ -51,7 +51,7 @@ function run() { } // ensure all tests have run -process.on("exit", function () { +process.on('exit', function() { assert.equal(count, 0); }); @@ -62,10 +62,10 @@ process.nextTick(run); test('buffers', function(t) { // have a length var len = 16; - var list = [ new Buffer('foog'), + var list = [new Buffer('foog'), new Buffer('bark'), new Buffer('bazy'), - new Buffer('kuel') ]; + new Buffer('kuel')]; // read more than the first element. var ret = fromList(6, { buffer: list, length: 16 }); @@ -92,10 +92,10 @@ test('buffers', function(t) { test('strings', function(t) { // have a length var len = 16; - var list = [ 'foog', - 'bark', - 'bazy', - 'kuel' ]; + var list = ['foog', + 'bark', + 'bazy', + 'kuel']; // read more than the first element. var ret = fromList(6, { buffer: list, length: 16, decoder: true }); diff --git a/test/simple/test-stream2-readable-non-empty-end.js b/test/simple/test-stream2-readable-non-empty-end.js index 65b7afda57b5..175a5565d289 100644 --- a/test/simple/test-stream2-readable-non-empty-end.js +++ b/test/simple/test-stream2-readable-non-empty-end.js @@ -26,7 +26,7 @@ var Readable = require('_stream_readable'); var len = 0; var chunks = new Array(10); for (var i = 1; i <= 10; i++) { - chunks[i-1] = new Buffer(i); + chunks[i - 1] = new Buffer(i); len += i; } diff --git a/test/simple/test-stream2-readable-wrap-empty.js b/test/simple/test-stream2-readable-wrap-empty.js index 2e5cf25c4474..2520888c4b52 100644 --- a/test/simple/test-stream2-readable-wrap-empty.js +++ b/test/simple/test-stream2-readable-wrap-empty.js @@ -26,18 +26,18 @@ var Readable = require('_stream_readable'); var EE = require('events').EventEmitter; var oldStream = new EE(); -oldStream.pause = function(){}; -oldStream.resume = function(){}; +oldStream.pause = function() {}; +oldStream.resume = function() {}; var newStream = new Readable().wrap(oldStream); var ended = false; newStream - .on('readable', function(){}) - .on('end', function(){ ended = true; }); + .on('readable', function() {}) + .on('end', function() { ended = true; }); oldStream.emit('end'); -process.on('exit', function(){ +process.on('exit', function() { assert.ok(ended); }); diff --git a/test/simple/test-stream2-readable-wrap.js b/test/simple/test-stream2-readable-wrap.js index 293774ca5c86..de1a8f0505ae 100644 --- a/test/simple/test-stream2-readable-wrap.js +++ b/test/simple/test-stream2-readable-wrap.js @@ -31,7 +31,8 @@ function runTest(highWaterMark, objectMode, produce) { testRuns++; var old = new EE; - var r = new Readable({ highWaterMark: highWaterMark, objectMode: objectMode }); + var r = new Readable({ highWaterMark: highWaterMark, + objectMode: objectMode }); assert.equal(r, r.wrap(old)); var ended = false; @@ -71,7 +72,8 @@ function runTest(highWaterMark, objectMode, produce) { } } - var w = new Writable({ highWaterMark: highWaterMark * 2, objectMode: objectMode }); + var w = new Writable({ highWaterMark: highWaterMark * 2, + objectMode: objectMode }); var written = []; w._write = function(chunk, encoding, cb) { console.log('_write', chunk); @@ -88,19 +90,19 @@ function runTest(highWaterMark, objectMode, produce) { flow(); - function performAsserts() { + function performAsserts() { assert(ended); assert(oldEnded); assert.deepEqual(written, expected); } } -runTest(100, false, function(){ return new Buffer(100); }); -runTest(10, false, function(){ return new Buffer('xxxxxxxxxx'); }); -runTest(1, true, function(){ return { foo: 'bar' }; }); +runTest(100, false, function() { return new Buffer(100); }); +runTest(10, false, function() { return new Buffer('xxxxxxxxxx'); }); +runTest(1, true, function() { return { foo: 'bar' }; }); -var objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ]; -runTest(1, true, function(){ return objectChunks.shift() }); +var objectChunks = [5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555]; +runTest(1, true, function() { return objectChunks.shift() }); process.on('exit', function() { assert.equal(testRuns, completedRuns); diff --git a/test/simple/test-stream2-set-encoding.js b/test/simple/test-stream2-set-encoding.js index 9b28e559428f..4388725bc293 100644 --- a/test/simple/test-stream2-set-encoding.js +++ b/test/simple/test-stream2-set-encoding.js @@ -45,7 +45,7 @@ function run() { fn({ same: assert.deepEqual, equal: assert.equal, - end: function () { + end: function() { count--; run(); } @@ -53,7 +53,7 @@ function run() { } // ensure all tests have run -process.on("exit", function () { +process.on('exit', function() { assert.equal(count, 0); }); @@ -90,7 +90,7 @@ TestReader.prototype._read = function(n) { var ret = new Buffer(n); ret.fill('a'); - console.log("this.push(ret)", ret) + console.log('this.push(ret)', ret); return this.push(ret); }.bind(this), 1); @@ -101,16 +101,16 @@ test('setEncoding utf8', function(t) { tr.setEncoding('utf8'); var out = []; var expect = - [ 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa' ]; + ['aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa']; tr.on('readable', function flow() { var chunk; @@ -130,26 +130,26 @@ test('setEncoding hex', function(t) { tr.setEncoding('hex'); var out = []; var expect = - [ '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161' ]; + ['6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161']; tr.on('readable', function flow() { var chunk; @@ -168,32 +168,32 @@ test('setEncoding hex with read(13)', function(t) { tr.setEncoding('hex'); var out = []; var expect = - [ "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "16161" ]; + ['6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '16161']; tr.on('readable', function flow() { - console.log("readable once") + console.log('readable once'); var chunk; while (null !== (chunk = tr.read(13))) out.push(chunk); }); tr.on('end', function() { - console.log("END") + console.log('END'); t.same(out, expect); t.end(); }); @@ -204,20 +204,20 @@ test('setEncoding base64', function(t) { tr.setEncoding('base64'); var out = []; var expect = - [ 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYQ==' ]; + ['YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYQ==']; tr.on('readable', function flow() { var chunk; @@ -235,16 +235,16 @@ test('encoding: utf8', function(t) { var tr = new TestReader(100, { encoding: 'utf8' }); var out = []; var expect = - [ 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa', - 'aaaaaaaaaa' ]; + ['aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa', + 'aaaaaaaaaa']; tr.on('readable', function flow() { var chunk; @@ -263,26 +263,26 @@ test('encoding: hex', function(t) { var tr = new TestReader(100, { encoding: 'hex' }); var out = []; var expect = - [ '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161', - '6161616161' ]; + ['6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161', + '6161616161']; tr.on('readable', function flow() { var chunk; @@ -300,22 +300,22 @@ test('encoding: hex with read(13)', function(t) { var tr = new TestReader(100, { encoding: 'hex' }); var out = []; var expect = - [ "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "1616161616161", - "6161616161616", - "16161" ]; + ['6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '1616161616161', + '6161616161616', + '16161']; tr.on('readable', function flow() { var chunk; @@ -333,20 +333,20 @@ test('encoding: base64', function(t) { var tr = new TestReader(100, { encoding: 'base64' }); var out = []; var expect = - [ 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYWFhYWFh', - 'YWFhYWFhYW', - 'FhYQ==' ]; + ['YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYWFhYWFh', + 'YWFhYWFhYW', + 'FhYQ==']; tr.on('readable', function flow() { var chunk; diff --git a/test/simple/test-stream2-stderr-sync.js b/test/simple/test-stream2-stderr-sync.js index 9e2d3ec223b0..4a6e1bbe7ec6 100644 --- a/test/simple/test-stream2-stderr-sync.js +++ b/test/simple/test-stream2-stderr-sync.js @@ -86,7 +86,7 @@ function child4() { process.stderr.write('child 4\nfoo\nbar\nbaz\n'); } -var children = [ child0, child1, child2, child3, child4 ]; +var children = [child0, child1, child2, child3, child4]; if (!process.argv[2]) { parent(); diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js index 6064565be0a1..036f00711b96 100644 --- a/test/simple/test-stream2-transform.js +++ b/test/simple/test-stream2-transform.js @@ -45,7 +45,7 @@ function run() { same: assert.deepEqual, equal: assert.equal, ok: assert, - end: function () { + end: function() { count--; run(); } @@ -53,7 +53,7 @@ function run() { } // ensure all tests have run -process.on("exit", function () { +process.on('exit', function() { assert.equal(count, 0); }); @@ -104,7 +104,7 @@ test('passthrough', function(t) { t.end(); }); -test('object passthrough', function (t) { +test('object passthrough', function(t) { var pt = new PassThrough({ objectMode: true }); pt.write(1); @@ -208,7 +208,7 @@ test('assymetric transform (expand)', function(t) { setTimeout(function() { pt.push(chunk); cb(); - }, 10) + }, 10); }, 10); }; @@ -288,7 +288,7 @@ test('assymetric transform (compress)', function(t) { test('complex transform', function(t) { var count = 0; var saved = null; - var pt = new Transform({highWaterMark:3}); + var pt = new Transform({highWaterMark: 3}); pt._transform = function(c, e, cb) { if (count++ === 1) saved = c; @@ -372,7 +372,7 @@ test('passthrough event emission reordered', function(t) { var pt = new PassThrough; var emits = 0; pt.on('readable', function() { - console.error('emit readable', emits) + console.error('emit readable', emits); emits++; }); @@ -454,8 +454,8 @@ test('object transform (json parse)', function(t) { var objects = [ { foo: 'bar' }, 100, - "string", - { nested: { things: [ { foo: 'bar' }, 100, "string" ] } } + 'string', + { nested: { things: [{ foo: 'bar' }, 100, 'string'] } } ]; var ended = false; @@ -476,7 +476,7 @@ test('object transform (json parse)', function(t) { process.nextTick(function() { t.ok(ended); t.end(); - }) + }); }); test('object transform (json stringify)', function(t) { @@ -496,8 +496,8 @@ test('object transform (json stringify)', function(t) { var objects = [ { foo: 'bar' }, 100, - "string", - { nested: { things: [ { foo: 'bar' }, 100, "string" ] } } + 'string', + { nested: { things: [{ foo: 'bar' }, 100, 'string'] } } ]; var ended = false; @@ -518,5 +518,5 @@ test('object transform (json stringify)', function(t) { process.nextTick(function() { t.ok(ended); t.end(); - }) + }); }); diff --git a/test/simple/test-stream2-unpipe-drain.js b/test/simple/test-stream2-unpipe-drain.js index d66dc3cbece4..0cd0f1208536 100644 --- a/test/simple/test-stream2-unpipe-drain.js +++ b/test/simple/test-stream2-unpipe-drain.js @@ -28,11 +28,11 @@ var crypto = require('crypto'); var util = require('util'); function TestWriter() { - stream.Writable.call(this); + stream.Writable.call(this); } util.inherits(TestWriter, stream.Writable); -TestWriter.prototype._write = function (buffer, encoding, callback) { +TestWriter.prototype._write = function(buffer, encoding, callback) { console.log('write called'); // super slow write stream (callback never called) }; @@ -40,12 +40,12 @@ TestWriter.prototype._write = function (buffer, encoding, callback) { var dest = new TestWriter(); function TestReader(id) { - stream.Readable.call(this); - this.reads = 0; + stream.Readable.call(this); + this.reads = 0; } util.inherits(TestReader, stream.Readable); -TestReader.prototype._read = function (size) { +TestReader.prototype._read = function(size) { this.reads += 1; this.push(crypto.randomBytes(size)); }; @@ -55,13 +55,13 @@ var src2 = new TestReader(); src1.pipe(dest); -src1.once('readable', function () { - process.nextTick(function () { +src1.once('readable', function() { + process.nextTick(function() { src2.pipe(dest); - src2.once('readable', function () { - process.nextTick(function () { + src2.once('readable', function() { + process.nextTick(function() { src1.unpipe(dest); }); @@ -70,7 +70,7 @@ src1.once('readable', function () { }); -process.on('exit', function () { +process.on('exit', function() { assert.equal(src1.reads, 2); assert.equal(src2.reads, 2); }); diff --git a/test/simple/test-stream2-writable.js b/test/simple/test-stream2-writable.js index 3767ce140e77..9d52f80821c7 100644 --- a/test/simple/test-stream2-writable.js +++ b/test/simple/test-stream2-writable.js @@ -67,7 +67,7 @@ function run() { fn({ same: assert.deepEqual, equal: assert.equal, - end: function () { + end: function() { count--; run(); } @@ -75,7 +75,7 @@ function run() { } // ensure all tests have run -process.on("exit", function () { +process.on('exit', function() { assert.equal(count, 0); }); @@ -156,7 +156,7 @@ test('write bufferize', function(t) { }); var encodings = - [ 'hex', + ['hex', 'utf8', 'utf-8', 'ascii', @@ -166,14 +166,14 @@ test('write bufferize', function(t) { 'ucs-2', 'utf16le', 'utf-16le', - undefined ]; + undefined]; tw.on('finish', function() { t.same(tw.buffer, chunks, 'got the expected chunks'); }); chunks.forEach(function(chunk, i) { - var enc = encodings[ i % encodings.length ]; + var enc = encodings[i % encodings.length]; chunk = new Buffer(chunk); tw.write(chunk.toString(enc), enc); }); @@ -193,7 +193,7 @@ test('write no bufferize', function(t) { }; var encodings = - [ 'hex', + ['hex', 'utf8', 'utf-8', 'ascii', @@ -203,21 +203,21 @@ test('write no bufferize', function(t) { 'ucs-2', 'utf16le', 'utf-16le', - undefined ]; + undefined]; tw.on('finish', function() { t.same(tw.buffer, chunks, 'got the expected chunks'); }); chunks.forEach(function(chunk, i) { - var enc = encodings[ i % encodings.length ]; + var enc = encodings[i % encodings.length]; chunk = new Buffer(chunk); tw.write(chunk.toString(enc), enc); }); t.end(); }); -test('write callbacks', function (t) { +test('write callbacks', function(t) { var callbacks = chunks.map(function(chunk, i) { return [i, function(er) { callbacks._called[i] = chunk; @@ -246,42 +246,42 @@ test('write callbacks', function (t) { tw.end(); }); -test('end callback', function (t) { +test('end callback', function(t) { var tw = new TestWriter(); - tw.end(function () { + tw.end(function() { t.end(); }); }); -test('end callback with chunk', function (t) { +test('end callback with chunk', function(t) { var tw = new TestWriter(); - tw.end(new Buffer('hello world'), function () { + tw.end(new Buffer('hello world'), function() { t.end(); }); }); -test('end callback with chunk and encoding', function (t) { +test('end callback with chunk and encoding', function(t) { var tw = new TestWriter(); - tw.end('hello world', 'ascii', function () { + tw.end('hello world', 'ascii', function() { t.end(); }); }); -test('end callback after .write() call', function (t) { +test('end callback after .write() call', function(t) { var tw = new TestWriter(); tw.write(new Buffer('hello world')); - tw.end(function () { + tw.end(function() { t.end(); }); }); -test('end callback called after write callback', function (t) { +test('end callback called after write callback', function(t) { var tw = new TestWriter(); var writeCalledback = false; - tw.write(new Buffer('hello world'), function() { + tw.write(new Buffer('hello world'), function() { writeCalledback = true; }); - tw.end(function () { + tw.end(function() { t.equal(writeCalledback, true); t.end(); }); diff --git a/test/simple/test-stream3-pause-then-read.js b/test/simple/test-stream3-pause-then-read.js index b91bde3f0ae2..8069a6d4c54b 100644 --- a/test/simple/test-stream3-pause-then-read.js +++ b/test/simple/test-stream3-pause-then-read.js @@ -62,7 +62,7 @@ function read100() { function readn(n, then) { console.error('read %d', n); expectEndingData -= n; - ;(function read() { + (function read() { var c = r.read(n); if (!c) r.once('readable', read); diff --git a/test/simple/test-string-decoder-end.js b/test/simple/test-string-decoder-end.js index fea55d410b75..0a4434373ba6 100644 --- a/test/simple/test-string-decoder-end.js +++ b/test/simple/test-string-decoder-end.js @@ -27,7 +27,7 @@ var assert = require('assert'); var SD = require('string_decoder').StringDecoder; var encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2']; -var bufs = [ '☃💩', 'asdf' ].map(function(b) { +var bufs = ['☃💩', 'asdf'].map(function(b) { return new Buffer(b); }); diff --git a/test/simple/test-string-decoder.js b/test/simple/test-string-decoder.js index 9f47d131bbcb..fe95868cf73d 100644 --- a/test/simple/test-string-decoder.js +++ b/test/simple/test-string-decoder.js @@ -38,9 +38,9 @@ test('utf-8', new Buffer('𤭢', 'utf-8'), '𤭢'); // U+0030 -> 30 // U+3045 -> E3 81 85 test( - 'utf-8', - new Buffer([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, 0xE3, 0x81, 0x85]), - '\u02e4\u0064\u12e4\u0030\u3045' + 'utf-8', + new Buffer([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, 0xE3, 0x81, 0x85]), + '\u02e4\u0064\u12e4\u0030\u3045' ); // CESU-8 @@ -50,7 +50,7 @@ test('utf-8', new Buffer('EDA0BDEDB18D', 'hex'), '\ud83d\udc4d'); // thumbs up test('ucs2', new Buffer('ababc', 'ucs2'), 'ababc'); // UTF-16LE -test('ucs2', new Buffer('3DD84DDC', 'hex'), '\ud83d\udc4d'); // thumbs up +test('ucs2', new Buffer('3DD84DDC', 'hex'), '\ud83d\udc4d'); // thumbs up console.log(' crayon!'); @@ -75,11 +75,11 @@ function test(encoding, input, expected, singleSequence) { process.stdout.write('.'); if (output !== expected) { var message = - 'Expected "'+unicodeEscape(expected)+'", '+ - 'but got "'+unicodeEscape(output)+'"\n'+ - 'Write sequence: '+JSON.stringify(sequence)+'\n'+ - 'Decoder charBuffer: 0x'+decoder.charBuffer.toString('hex')+'\n'+ - 'Full Decoder State: '+JSON.stringify(decoder, null, 2); + 'Expected "' + unicodeEscape(expected) + '", ' + + 'but got "' + unicodeEscape(output) + '"\n' + + 'Write sequence: ' + JSON.stringify(sequence) + '\n' + + 'Decoder charBuffer: 0x' + decoder.charBuffer.toString('hex') + '\n' + + 'Full Decoder State: ' + JSON.stringify(decoder, null, 2); assert.fail(output, expected, message); } }); @@ -89,7 +89,7 @@ function test(encoding, input, expected, singleSequence) { function unicodeEscape(str) { var r = ''; for (var i = 0; i < str.length; i++) { - r += '\\u'+str.charCodeAt(i).toString(16); + r += '\\u' + str.charCodeAt(i).toString(16); } return r; } @@ -107,7 +107,7 @@ function unicodeEscape(str) { function writeSequences(length, start, sequence) { if (start === undefined) { start = 0; - sequence = [] + sequence = []; } else if (start === length) { return [sequence]; } diff --git a/test/simple/test-stringbytes-external.js b/test/simple/test-stringbytes-external.js index c7c716c836b3..f346082c6322 100644 --- a/test/simple/test-stringbytes-external.js +++ b/test/simple/test-stringbytes-external.js @@ -80,7 +80,7 @@ var RADIOS = 2; var PRE_HALF_APEX = Math.ceil(EXTERN_APEX / 2) - RADIOS; var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; -(function () { +(function() { for (var j = 0; j < RADIOS * 2; j += 1) { var datum = b; var slice = datum.slice(0, PRE_HALF_APEX + j); @@ -89,7 +89,7 @@ var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; var pumped_string2 = slice2.toString('hex'); var decoded = new Buffer(pumped_string, 'hex'); - var metadata = "\nEXTERN_APEX=1031913 - pumped_string.length=" + var metadata = '\nEXTERN_APEX=1031913 - pumped_string.length='; metadata += pumped_string.length + '\n'; // the string are the same? @@ -106,7 +106,7 @@ var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; } })(); -(function () { +(function() { for (var j = 0; j < RADIOS * 2; j += 1) { var datum = b; var slice = datum.slice(0, PRE_3OF4_APEX + j); @@ -115,14 +115,14 @@ var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; var pumped_string2 = slice2.toString('base64'); var decoded = new Buffer(pumped_string, 'base64'); - var metadata = "\nEXTERN_APEX=1031913 - data=" + slice.length - metadata += " pumped_string.length=" + pumped_string.length + '\n'; + var metadata = '\nEXTERN_APEX=1031913 - data=' + slice.length; + metadata += ' pumped_string.length=' + pumped_string.length + '\n'; // the string are the same? for (var k = 0; k < pumped_string.length - 3; ++k) { assert.equal(pumped_string[k], pumped_string2[k], - metadata + 'chars should be the same for two slices at ' - + k + ' ' + pumped_string[k] + ' ' + pumped_string2[k]); + metadata + 'chars should be the same for two slices at ' + + k + ' ' + pumped_string[k] + ' ' + pumped_string2[k]); } // the recoded buffer is the same? diff --git a/test/simple/test-timers-immediate.js b/test/simple/test-timers-immediate.js index 0bd8ae9642ee..1116b2c5739d 100644 --- a/test/simple/test-timers-immediate.js +++ b/test/simple/test-timers-immediate.js @@ -30,7 +30,7 @@ var immediateA = false, setImmediate(function() { try { immediateA = process.hrtime(before); - } catch(e) { + } catch (e) { console.log('failed to get hrtime with offset'); } clearImmediate(immediateB); diff --git a/test/simple/test-timers-ordering.js b/test/simple/test-timers-ordering.js index 30cc44e53a6e..19864c898fff 100644 --- a/test/simple/test-timers-ordering.js +++ b/test/simple/test-timers-ordering.js @@ -34,13 +34,15 @@ var start = Timer.now(); var f = function(i) { if (i <= N) { // check order - assert.equal(i, last_i + 1, 'order is broken: ' + i + ' != ' + last_i + ' + 1'); + assert.equal(i, last_i + 1, + 'order is broken: ' + i + ' != ' + last_i + ' + 1'); last_i = i; // check that this iteration is fired at least 1ms later than the previous var now = Timer.now(); console.log(i, now); - assert(now >= last_ts + 1, 'current ts ' + now + ' < prev ts ' + last_ts + ' + 1'); + assert(now >= last_ts + 1, + 'current ts ' + now + ' < prev ts ' + last_ts + ' + 1'); last_ts = now; // schedule next iteration diff --git a/test/simple/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/simple/test-timers-socket-timeout-removes-other-socket-unref-timer.js index 3d7263c63480..40a4dc7b3627 100644 --- a/test/simple/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/simple/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -61,7 +61,7 @@ server.listen(common.PORT, '127.0.0.1', function() { } } - var client1 = net.connect({ port: common.PORT }) + var client1 = net.connect({ port: common.PORT }); client1.on('end', addEndedClient); var client2 = net.connect({ port: common.PORT }); diff --git a/test/simple/test-timers-this.js b/test/simple/test-timers-this.js index 3d23e61dff14..de5e88d50a9e 100644 --- a/test/simple/test-timers-this.js +++ b/test/simple/test-timers-this.js @@ -24,35 +24,35 @@ var assert = require('assert'); var immediateThis, intervalThis, timeoutThis, immediateArgsThis, intervalArgsThis, timeoutArgsThis; -var immediateHandler = setImmediate(function () { +var immediateHandler = setImmediate(function() { immediateThis = this; }); -var immediateArgsHandler = setImmediate(function () { +var immediateArgsHandler = setImmediate(function() { immediateArgsThis = this; -}, "args ..."); +}, 'args ...'); -var intervalHandler = setInterval(function () { +var intervalHandler = setInterval(function() { clearInterval(intervalHandler); intervalThis = this; }); -var intervalArgsHandler = setInterval(function () { +var intervalArgsHandler = setInterval(function() { clearInterval(intervalArgsHandler); intervalArgsThis = this; -}, 0, "args ..."); +}, 0, 'args ...'); -var timeoutHandler = setTimeout(function () { +var timeoutHandler = setTimeout(function() { timeoutThis = this; }); -var timeoutArgsHandler = setTimeout(function () { +var timeoutArgsHandler = setTimeout(function() { timeoutArgsThis = this; -}, 0, "args ..."); +}, 0, 'args ...'); -process.once('exit', function () { +process.once('exit', function() { assert.strictEqual(immediateThis, immediateHandler); assert.strictEqual(immediateArgsThis, immediateArgsHandler); diff --git a/test/simple/test-timers-unref-active.js b/test/simple/test-timers-unref-active.js index ce07c2dee621..2555d12ad75d 100644 --- a/test/simple/test-timers-unref-active.js +++ b/test/simple/test-timers-unref-active.js @@ -60,7 +60,7 @@ someObject._onTimeout = function _onTimeout() { if (nbTimeouts === N) timers.unenroll(someObject); timers._unrefActive(someObject); -} +}; function startTimer() { timers._unrefActive(someObject); } diff --git a/test/simple/test-timers-unref.js b/test/simple/test-timers-unref.js index 17e107326b2b..6b173937bb79 100644 --- a/test/simple/test-timers-unref.js +++ b/test/simple/test-timers-unref.js @@ -66,5 +66,6 @@ process.on('exit', function() { assert.strictEqual(interval_fired, false, 'Interval should not fire'); assert.strictEqual(timeout_fired, false, 'Timeout should not fire'); assert.strictEqual(unref_timer, true, 'An unrefd timeout should still fire'); - assert.strictEqual(unref_interval, true, 'An unrefd interval should still fire'); + assert.strictEqual(unref_interval, true, + 'An unrefd interval should still fire'); }); diff --git a/test/simple/test-tls-alert.js b/test/simple/test-tls-alert.js index f26b496f9dfd..3d230223318d 100644 --- a/test/simple/test-tls-alert.js +++ b/test/simple/test-tls-alert.js @@ -44,9 +44,10 @@ function loadPEM(n) { var server = tls.Server({ secureProtocol: 'TLSv1_2_server_method', key: loadPEM('agent2-key'), - cert:loadPEM('agent2-cert') + cert: loadPEM('agent2-cert') }, null).listen(common.PORT, function() { - var args = ['s_client', '-quiet', '-tls1_1','-connect', '127.0.0.1:' + common.PORT]; + var args = ['s_client', '-quiet', '-tls1_1', '-connect', + '127.0.0.1:' + common.PORT]; var client = spawn(common.opensslCli, args); var out = ''; client.stderr.setEncoding('utf8'); diff --git a/test/simple/test-tls-cert-regression.js b/test/simple/test-tls-cert-regression.js index ec8369ba98ca..cd7e9ea3a06c 100644 --- a/test/simple/test-tls-cert-regression.js +++ b/test/simple/test-tls-cert-regression.js @@ -30,25 +30,25 @@ var assert = require('assert'); var common = require('../common'); var cert = '-----BEGIN CERTIFICATE-----\n' + - 'MIIBfjCCASgCCQDmmNjAojbDQjANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB\n' + - 'VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0\n' + - 'cyBQdHkgTHRkMCAXDTE0MDExNjE3NTMxM1oYDzIyODcxMDMxMTc1MzEzWjBFMQsw\n' + - 'CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu\n' + - 'ZXQgV2lkZ2l0cyBQdHkgTHRkMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPKwlfMX\n' + - '6HGZIt1xm7fna72eWcOYfUfSxSugghvqYgJt2Oi3lH+wsU1O9FzRIVmpeIjDXhbp\n' + - 'Mjsa1HtzSiccPXsCAwEAATANBgkqhkiG9w0BAQUFAANBAHOoKy0NkyfiYH7Ne5ka\n' + - 'uvCyndyeB4d24FlfqEUlkfaWCZlNKRaV9YhLDiEg3BcIreFo4brtKQfZzTRs0GVm\n' + - 'KHg=\n' + - '-----END CERTIFICATE-----'; + 'MIIBfjCCASgCCQDmmNjAojbDQjANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB\n' + + 'VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0\n' + + 'cyBQdHkgTHRkMCAXDTE0MDExNjE3NTMxM1oYDzIyODcxMDMxMTc1MzEzWjBFMQsw\n' + + 'CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu\n' + + 'ZXQgV2lkZ2l0cyBQdHkgTHRkMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAPKwlfMX\n' + + '6HGZIt1xm7fna72eWcOYfUfSxSugghvqYgJt2Oi3lH+wsU1O9FzRIVmpeIjDXhbp\n' + + 'Mjsa1HtzSiccPXsCAwEAATANBgkqhkiG9w0BAQUFAANBAHOoKy0NkyfiYH7Ne5ka\n' + + 'uvCyndyeB4d24FlfqEUlkfaWCZlNKRaV9YhLDiEg3BcIreFo4brtKQfZzTRs0GVm\n' + + 'KHg=\n' + + '-----END CERTIFICATE-----'; var key = '-----BEGIN RSA PRIVATE KEY-----\n' + - 'MIIBPQIBAAJBAPKwlfMX6HGZIt1xm7fna72eWcOYfUfSxSugghvqYgJt2Oi3lH+w\n' + - 'sU1O9FzRIVmpeIjDXhbpMjsa1HtzSiccPXsCAwEAAQJBAM4uU9aJE0OfdE1p/X+K\n' + - 'LrCT3XMdFCJ24GgmHyOURtwDy18upQJecDVdcZp16fjtOPmaW95GoYRyifB3R4I5\n' + - 'RxECIQD7jRM9slCSVV8xp9kOJQNpHjhRQYVGBn+pyllS2sb+RQIhAPb7Y+BIccri\n' + - 'NWnuhwCW8hA7Fkj/kaBdAwyW7L3Tvui/AiEAiqLCovMecre4Yi6GcsQ1b/6mvSmm\n' + - 'IOS+AT6zIfXPTB0CIQCJKGR3ymN/Qw5crL1GQ41cHCQtF9ickOq/lBUW+j976wIh\n' + - 'AOaJnkQrmurlRdePX6LvN/LgGAQoxwovfjcOYNnZsIVY\n' + - '-----END RSA PRIVATE KEY-----'; + 'MIIBPQIBAAJBAPKwlfMX6HGZIt1xm7fna72eWcOYfUfSxSugghvqYgJt2Oi3lH+w\n' + + 'sU1O9FzRIVmpeIjDXhbpMjsa1HtzSiccPXsCAwEAAQJBAM4uU9aJE0OfdE1p/X+K\n' + + 'LrCT3XMdFCJ24GgmHyOURtwDy18upQJecDVdcZp16fjtOPmaW95GoYRyifB3R4I5\n' + + 'RxECIQD7jRM9slCSVV8xp9kOJQNpHjhRQYVGBn+pyllS2sb+RQIhAPb7Y+BIccri\n' + + 'NWnuhwCW8hA7Fkj/kaBdAwyW7L3Tvui/AiEAiqLCovMecre4Yi6GcsQ1b/6mvSmm\n' + + 'IOS+AT6zIfXPTB0CIQCJKGR3ymN/Qw5crL1GQ41cHCQtF9ickOq/lBUW+j976wIh\n' + + 'AOaJnkQrmurlRdePX6LvN/LgGAQoxwovfjcOYNnZsIVY\n' + + '-----END RSA PRIVATE KEY-----'; function test(cert, key, cb) { var server = tls.createServer({ diff --git a/test/simple/test-tls-check-server-identity.js b/test/simple/test-tls-check-server-identity.js index 598dac0e00bb..31f2559eaac7 100644 --- a/test/simple/test-tls-check-server-identity.js +++ b/test/simple/test-tls-check-server-identity.js @@ -40,8 +40,8 @@ var tests = [ { host: 'b.a.com', cert: { subjectaltname: 'DNS:omg.com', subject: { CN: '*.a.com' } }, - error: 'Host: b.a.com. is not in the cert\'s altnames: ' + - 'DNS:omg.com' + error: 'Host: b.a.com. is not in the cert\'s altnames: ' + + 'DNS:omg.com' }, // Multiple CN fields @@ -58,7 +58,7 @@ var tests = [ subject: { CN: 'b.com' } }, error: 'Host: a.com. is not in the cert\'s altnames: ' + - 'DNS:*' + 'DNS:*' }, { host: 'a.com', cert: { @@ -66,7 +66,7 @@ var tests = [ subject: { CN: 'b.com' } }, error: 'Host: a.com. is not in the cert\'s altnames: ' + - 'DNS:*.com' + 'DNS:*.com' }, { host: 'a.co.uk', cert: { @@ -80,7 +80,7 @@ var tests = [ subject: { CN: 'a.com' } }, error: 'Host: a.com. is not in the cert\'s altnames: ' + - 'DNS:*.a.com' + 'DNS:*.a.com' }, { host: 'a.com', cert: { @@ -88,7 +88,7 @@ var tests = [ subject: { CN: 'b.com' } }, error: 'Host: a.com. is not in the cert\'s altnames: ' + - 'DNS:*.a.com' + 'DNS:*.a.com' }, { host: 'a.com', cert: { @@ -110,7 +110,7 @@ var tests = [ subject: {} }, error: 'Host: a.com. is not in the cert\'s altnames: ' + - 'DNS:*.a.com' + 'DNS:*.a.com' }, { host: 'b.a.com', cert: { @@ -124,7 +124,7 @@ var tests = [ subject: {} }, error: 'Host: c.b.a.com. is not in the cert\'s altnames: ' + - 'DNS:*.a.com' + 'DNS:*.a.com' }, { host: 'b.a.com', cert: { @@ -144,7 +144,7 @@ var tests = [ subject: {} }, error: 'Host: a.b.a.com. is not in the cert\'s altnames: ' + - 'DNS:*b.a.com' + 'DNS:*b.a.com' }, // Mutliple DNS names { @@ -166,7 +166,7 @@ var tests = [ subject: {} }, error: 'Host: a.b.a.com. is not in the cert\'s altnames: ' + - 'URI:http://*.b.a.com/' + 'URI:http://*.b.a.com/' }, // IP addresses { @@ -175,7 +175,7 @@ var tests = [ subject: {} }, error: 'Host: a.b.a.com. is not in the cert\'s altnames: ' + - 'IP Address:127.0.0.1' + 'IP Address:127.0.0.1' }, { host: '127.0.0.1', cert: { @@ -189,7 +189,7 @@ var tests = [ subject: {} }, error: 'IP: 127.0.0.2 is not in the cert\'s list: ' + - '127.0.0.1' + '127.0.0.1' }, { host: '127.0.0.1', cert: { @@ -204,8 +204,8 @@ var tests = [ subject: { CN: 'localhost' } }, error: 'Host: localhost. is not in the cert\'s altnames: ' + - 'DNS:a.com' - }, + 'DNS:a.com' + } ]; tests.forEach(function(test, i) { diff --git a/test/simple/test-tls-cipher-list.js b/test/simple/test-tls-cipher-list.js index 8e54d8d36a41..65fc95df1b68 100644 --- a/test/simple/test-tls-cipher-list.js +++ b/test/simple/test-tls-cipher-list.js @@ -27,7 +27,7 @@ function doTest(checklist, env, useswitch) { var options; var args = ['-e', 'console.log(require(\'tls\').DEFAULT_CIPHERS)']; - switch(useswitch) { + switch (useswitch) { case 1: // Test --cipher-list args.unshift('--cipher-list=' + env); @@ -38,16 +38,16 @@ function doTest(checklist, env, useswitch) { break; case 3: // Test NODE_LEGACY_CIPHER_LIST - if (env) options = {env:{"NODE_LEGACY_CIPHER_LIST": env}}; + if (env) options = {env: {'NODE_LEGACY_CIPHER_LIST': env}}; break; default: // Test NODE_CIPHER_LIST - if (env) options = {env:env}; + if (env) options = {env: env}; } var out = ''; spawn(process.execPath, args, options). - stdout. + stdout. on('data', function(data) { out += data; }). @@ -57,7 +57,7 @@ function doTest(checklist, env, useswitch) { } doTest(tls.DEFAULT_CIPHERS); // test the default -doTest('ABC', {'NODE_CIPHER_LIST':'ABC'}); // test the envar +doTest('ABC', {'NODE_CIPHER_LIST': 'ABC'}); // test the envar doTest('ABC', 'ABC', 1); // test the --cipher-list switch ['v0.10.38', 'v0.10.39', 'v0.12.2', 'v0.12.3'].forEach(function(ver) { diff --git a/test/simple/test-tls-client-default-ciphers.js b/test/simple/test-tls-client-default-ciphers.js index 0a3c470292ae..46ff43f01913 100644 --- a/test/simple/test-tls-client-default-ciphers.js +++ b/test/simple/test-tls-client-default-ciphers.js @@ -26,7 +26,7 @@ var tls = require('tls'); function test1() { var ciphers = ''; tls.createSecureContext = function(options) { - ciphers = options.ciphers + ciphers = options.ciphers; } var s = tls.connect(common.PORT); s.destroy(); diff --git a/test/simple/test-tls-dhe.js b/test/simple/test-tls-dhe.js index 8844f8527998..c8665b7458ca 100644 --- a/test/simple/test-tls-dhe.js +++ b/test/simple/test-tls-dhe.js @@ -30,7 +30,7 @@ var assert = require('assert'); var spawn = require('child_process').spawn; var tls = require('tls'); var fs = require('fs'); -var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); +var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'); var nsuccess = 0; var ntests = 0; diff --git a/test/simple/test-tls-econnreset.js b/test/simple/test-tls-econnreset.js index fcadf13f0c30..c28c78ab29f0 100644 --- a/test/simple/test-tls-econnreset.js +++ b/test/simple/test-tls-econnreset.js @@ -29,39 +29,39 @@ var assert = require('assert'); var tls = require('tls'); var cacert = '-----BEGIN CERTIFICATE-----\n' + - 'MIIBxTCCAX8CAnXnMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD\n' + - 'VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n\n' + - 'TG9vcCwgSW5jLjESMBAGA1UECxMJU3Ryb25nT3BzMRowGAYDVQQDExFjYS5zdHJv\n' + - 'bmdsb29wLmNvbTAeFw0xNDAxMTcyMjE1MDdaFw00MTA2MDMyMjE1MDdaMH0xCzAJ\n' + - 'BgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZ\n' + - 'MBcGA1UEChMQU3Ryb25nTG9vcCwgSW5jLjESMBAGA1UECxMJU3Ryb25nT3BzMRow\n' + - 'GAYDVQQDExFjYS5zdHJvbmdsb29wLmNvbTBMMA0GCSqGSIb3DQEBAQUAAzsAMDgC\n' + - 'MQDKbQ6rIR5t1q1v4Ha36jrq0IkyUohy9EYNvLnXUly1PGqxby0ILlAVJ8JawpY9\n' + - 'AVkCAwEAATANBgkqhkiG9w0BAQUFAAMxALA1uS4CqQXRSAyYTfio5oyLGz71a+NM\n' + - '+0AFLBwh5AQjhGd0FcenU4OfHxyDEOJT/Q==\n' + - '-----END CERTIFICATE-----\n'; + 'MIIBxTCCAX8CAnXnMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD\n' + + 'VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n\n' + + 'TG9vcCwgSW5jLjESMBAGA1UECxMJU3Ryb25nT3BzMRowGAYDVQQDExFjYS5zdHJv\n' + + 'bmdsb29wLmNvbTAeFw0xNDAxMTcyMjE1MDdaFw00MTA2MDMyMjE1MDdaMH0xCzAJ\n' + + 'BgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZ\n' + + 'MBcGA1UEChMQU3Ryb25nTG9vcCwgSW5jLjESMBAGA1UECxMJU3Ryb25nT3BzMRow\n' + + 'GAYDVQQDExFjYS5zdHJvbmdsb29wLmNvbTBMMA0GCSqGSIb3DQEBAQUAAzsAMDgC\n' + + 'MQDKbQ6rIR5t1q1v4Ha36jrq0IkyUohy9EYNvLnXUly1PGqxby0ILlAVJ8JawpY9\n' + + 'AVkCAwEAATANBgkqhkiG9w0BAQUFAAMxALA1uS4CqQXRSAyYTfio5oyLGz71a+NM\n' + + '+0AFLBwh5AQjhGd0FcenU4OfHxyDEOJT/Q==\n' + + '-----END CERTIFICATE-----\n'; var cert = '-----BEGIN CERTIFICATE-----\n' + - 'MIIBfDCCATYCAgQaMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD\n' + - 'VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n\n' + - 'TG9vcCwgSW5jLjESMBAGA1UECxMJU3Ryb25nT3BzMRowGAYDVQQDExFjYS5zdHJv\n' + - 'bmdsb29wLmNvbTAeFw0xNDAxMTcyMjE1MDdaFw00MTA2MDMyMjE1MDdaMBkxFzAV\n' + - 'BgNVBAMTDnN0cm9uZ2xvb3AuY29tMEwwDQYJKoZIhvcNAQEBBQADOwAwOAIxAMfk\n' + - 'I0LWU15pPUwIQNMnRVhhOibi0TQmAau8FBtgwEfGK01WpfGUaJr1a41K8Uq7xwID\n' + - 'AQABoxkwFzAVBgNVHREEDjAMhwQAAAAAhwR/AAABMA0GCSqGSIb3DQEBBQUAAzEA\n' + - 'cGpYrhkrb7mIh9DNhV0qp7pGjqBzlHqB7KQXw2luLDp//6dyHBMexDCQznkhZKRU\n' + - '-----END CERTIFICATE-----\n'; + 'MIIBfDCCATYCAgQaMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD\n' + + 'VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n\n' + + 'TG9vcCwgSW5jLjESMBAGA1UECxMJU3Ryb25nT3BzMRowGAYDVQQDExFjYS5zdHJv\n' + + 'bmdsb29wLmNvbTAeFw0xNDAxMTcyMjE1MDdaFw00MTA2MDMyMjE1MDdaMBkxFzAV\n' + + 'BgNVBAMTDnN0cm9uZ2xvb3AuY29tMEwwDQYJKoZIhvcNAQEBBQADOwAwOAIxAMfk\n' + + 'I0LWU15pPUwIQNMnRVhhOibi0TQmAau8FBtgwEfGK01WpfGUaJr1a41K8Uq7xwID\n' + + 'AQABoxkwFzAVBgNVHREEDjAMhwQAAAAAhwR/AAABMA0GCSqGSIb3DQEBBQUAAzEA\n' + + 'cGpYrhkrb7mIh9DNhV0qp7pGjqBzlHqB7KQXw2luLDp//6dyHBMexDCQznkhZKRU\n' + + '-----END CERTIFICATE-----\n'; var key = '-----BEGIN RSA PRIVATE KEY-----\n' + - 'MIH0AgEAAjEAx+QjQtZTXmk9TAhA0ydFWGE6JuLRNCYBq7wUG2DAR8YrTVal8ZRo\n' + - 'mvVrjUrxSrvHAgMBAAECMBCGccvSwC2r8Z9Zh1JtirQVxaL1WWpAQfmVwLe0bAgg\n' + - '/JWMU/6hS36TsYyZMxwswQIZAPTAfht/zDLb7Hwgu2twsS1Ra9w/yyvtlwIZANET\n' + - '26votwJAHK1yUrZGA5nnp5qcmQ/JUQIZAII5YV/UUZvF9D/fUplJ7puENPWNY9bN\n' + - 'pQIZAMMwxuS3XiO7two2sQF6W+JTYyX1DPCwAQIZAOYg1TvEGT38k8e8jygv8E8w\n' + - 'YqrWTeQFNQ==\n' + - '-----END RSA PRIVATE KEY-----\n'; + 'MIH0AgEAAjEAx+QjQtZTXmk9TAhA0ydFWGE6JuLRNCYBq7wUG2DAR8YrTVal8ZRo\n' + + 'mvVrjUrxSrvHAgMBAAECMBCGccvSwC2r8Z9Zh1JtirQVxaL1WWpAQfmVwLe0bAgg\n' + + '/JWMU/6hS36TsYyZMxwswQIZAPTAfht/zDLb7Hwgu2twsS1Ra9w/yyvtlwIZANET\n' + + '26votwJAHK1yUrZGA5nnp5qcmQ/JUQIZAII5YV/UUZvF9D/fUplJ7puENPWNY9bN\n' + + 'pQIZAMMwxuS3XiO7two2sQF6W+JTYyX1DPCwAQIZAOYg1TvEGT38k8e8jygv8E8w\n' + + 'YqrWTeQFNQ==\n' + + '-----END RSA PRIVATE KEY-----\n'; -var ca = [ cert, cacert ]; +var ca = [cert, cacert]; var clientError = null; var connectError = null; diff --git a/test/simple/test-tls-fast-writing.js b/test/simple/test-tls-fast-writing.js index 894ec346a5c1..fdcd4b8167fe 100644 --- a/test/simple/test-tls-fast-writing.js +++ b/test/simple/test-tls-fast-writing.js @@ -28,8 +28,8 @@ var fs = require('fs'); var PORT = common.PORT; var dir = common.fixturesDir; var options = { key: fs.readFileSync(dir + '/test_key.pem'), - cert: fs.readFileSync(dir + '/test_cert.pem'), - ca: [ fs.readFileSync(dir + '/test_ca.pem') ] }; + cert: fs.readFileSync(dir + '/test_cert.pem'), + ca: [fs.readFileSync(dir + '/test_ca.pem')] }; var server = tls.createServer(options, onconnection); var gotChunk = false; diff --git a/test/simple/test-tls-hello-parser-failure.js b/test/simple/test-tls-hello-parser-failure.js index b6c0ac228393..38c27814811e 100644 --- a/test/simple/test-tls-hello-parser-failure.js +++ b/test/simple/test-tls-hello-parser-failure.js @@ -55,7 +55,7 @@ var server = tls.createServer(options, function(c) { } }); - client.on('close', function (hadError) { + client.on('close', function(hadError) { assert.strictEqual(hadError, true, 'Client never errored'); }); }); diff --git a/test/simple/test-tls-honorcipherorder-secureOptions.js b/test/simple/test-tls-honorcipherorder-secureOptions.js index e70cfb1ef4a4..7c37721be985 100644 --- a/test/simple/test-tls-honorcipherorder-secureOptions.js +++ b/test/simple/test-tls-honorcipherorder-secureOptions.js @@ -44,7 +44,8 @@ process.on('exit', function() { assert.equal(nconns, 6); }); -function test(honorCipherOrder, clientCipher, expectedCipher, secureOptions, cb) { +function test(honorCipherOrder, clientCipher, + expectedCipher, secureOptions, cb) { var soptions = { secureProtocol: SSL_Method, key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), @@ -59,7 +60,8 @@ function test(honorCipherOrder, clientCipher, expectedCipher, secureOptions, cb) }); if (!!honorCipherOrder) { - assert.strictEqual(server.secureOptions & opCipher, opCipher, 'we should preserve cipher preference'); + assert.strictEqual(server.secureOptions & opCipher, opCipher, + 'we should preserve cipher preference'); } if (secureOptions) { @@ -67,10 +69,10 @@ function test(honorCipherOrder, clientCipher, expectedCipher, secureOptions, cb) if (!!honorCipherOrder) expectedSecureOpts |= opCipher; assert.strictEqual(server.secureOptions & expectedSecureOpts, - expectedSecureOpts, 'we should preserve secureOptions'); + expectedSecureOpts, 'we should preserve secureOptions'); assert.strictEqual(server.secureOptions & ~expectedSecureOpts, - 0, - 'we should not add extra options'); + 0, + 'we should not add extra options'); } server.listen(common.PORT, localhost, function() { @@ -95,7 +97,7 @@ test1(); function test1() { // Client has the preference of cipher suites by default - test(false, 'DES-CBC-SHA:RC4-SHA:AES256-SHA','DES-CBC-SHA', 0, test2); + test(false, 'DES-CBC-SHA:RC4-SHA:AES256-SHA', 'DES-CBC-SHA', 0, test2); } function test2() { diff --git a/test/simple/test-tls-honorcipherorder.js b/test/simple/test-tls-honorcipherorder.js index 6b24d75146e2..d11d09656cc1 100644 --- a/test/simple/test-tls-honorcipherorder.js +++ b/test/simple/test-tls-honorcipherorder.js @@ -71,7 +71,7 @@ test1(); function test1() { // Client has the preference of cipher suites by default - test(false, 'AES256-SHA:DES-CBC-SHA:RC4-SHA','AES256-SHA', test2); + test(false, 'AES256-SHA:DES-CBC-SHA:RC4-SHA', 'AES256-SHA', test2); } function test2() { diff --git a/test/simple/test-tls-inception.js b/test/simple/test-tls-inception.js index d15d1ebd43a7..c177085db2c6 100644 --- a/test/simple/test-tls-inception.js +++ b/test/simple/test-tls-inception.js @@ -40,7 +40,7 @@ options = { }; // the "proxy" server -a = tls.createServer(options, function (socket) { +a = tls.createServer(options, function(socket) { var options = { host: '127.0.0.1', port: b.address().port, @@ -52,16 +52,16 @@ a = tls.createServer(options, function (socket) { }); // the "target" server -b = tls.createServer(options, function (socket) { +b = tls.createServer(options, function(socket) { socket.end('hello'); }); -process.on('exit', function () { +process.on('exit', function() { assert(gotHello); }); -a.listen(common.PORT, function () { - b.listen(common.PORT + 1, function () { +a.listen(common.PORT, function() { + b.listen(common.PORT + 1, function() { options = { host: '127.0.0.1', port: a.address().port, @@ -74,11 +74,11 @@ a.listen(common.PORT, function () { rejectUnauthorized: false }); ssl.setEncoding('utf8'); - ssl.once('data', function (data) { + ssl.once('data', function(data) { assert.equal('hello', data); gotHello = true; }); - ssl.on('end', function () { + ssl.on('end', function() { ssl.end(); a.close(); b.close(); diff --git a/test/simple/test-tls-interleave.js b/test/simple/test-tls-interleave.js index 8bebb807e548..69319477ed5a 100644 --- a/test/simple/test-tls-interleave.js +++ b/test/simple/test-tls-interleave.js @@ -28,13 +28,13 @@ var fs = require('fs'); var PORT = common.PORT; var dir = common.fixturesDir; var options = { key: fs.readFileSync(dir + '/test_key.pem'), - cert: fs.readFileSync(dir + '/test_cert.pem'), - ca: [ fs.readFileSync(dir + '/test_ca.pem') ] }; + cert: fs.readFileSync(dir + '/test_cert.pem'), + ca: [fs.readFileSync(dir + '/test_ca.pem')] }; var writes = [ 'some server data', 'and a separate packet', - 'and one more', + 'and one more' ]; var receivedWrites = 0; diff --git a/test/simple/test-tls-npn-server-client.js b/test/simple/test-tls-npn-server-client.js index 0849cc8d2e75..53dcc3415643 100644 --- a/test/simple/test-tls-npn-server-client.js +++ b/test/simple/test-tls-npn-server-client.js @@ -46,7 +46,7 @@ var serverOptions = { cb(null, tls.createSecureContext({ key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert'), - crl: loadPEM('ca2-crl'), + crl: loadPEM('ca2-crl') })); }, NPNProtocols: ['a', 'b', 'c'] diff --git a/test/simple/test-tls-peer-certificate-encoding.js b/test/simple/test-tls-peer-certificate-encoding.js index 288236a93c9d..d5d1135fd90f 100644 --- a/test/simple/test-tls-peer-certificate-encoding.js +++ b/test/simple/test-tls-peer-certificate-encoding.js @@ -35,7 +35,7 @@ var spawn = require('child_process').spawn; var options = { key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-key.pem')), cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-cert.pem')), - ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca2-cert.pem')) ] + ca: [fs.readFileSync(join(common.fixturesDir, 'keys', 'ca2-cert.pem'))] }; var verified = false; diff --git a/test/simple/test-tls-peer-certificate.js b/test/simple/test-tls-peer-certificate.js index f1d0a7f1971d..6d5a728f7845 100644 --- a/test/simple/test-tls-peer-certificate.js +++ b/test/simple/test-tls-peer-certificate.js @@ -35,7 +35,7 @@ var spawn = require('child_process').spawn; var options = { key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-key.pem')), cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-cert.pem')), - ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca1-cert.pem')) ] + ca: [fs.readFileSync(join(common.fixturesDir, 'keys', 'ca1-cert.pem'))] }; var verified = false; @@ -58,7 +58,7 @@ server.listen(common.PORT, function() { assert.equal(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); assert.equal(peerCert.serialNumber, '9A84ABCFB8A72ABE'); assert.deepEqual(peerCert.infoAccess['OCSP - URI'], - [ 'http://ocsp.nodejs.org/' ]); + ['http://ocsp.nodejs.org/']); var issuer = peerCert.issuerCertificate; assert.ok(issuer.issuerCertificate === issuer); diff --git a/test/simple/test-tls-session-cache.js b/test/simple/test-tls-session-cache.js index d5db30ce1104..a754ee960a7d 100644 --- a/test/simple/test-tls-session-cache.js +++ b/test/simple/test-tls-session-cache.js @@ -95,7 +95,7 @@ function doTest(testOptions, callback) { '-cert', join(common.fixturesDir, 'agent.crt'), '-reconnect' ].concat(testOptions.tickets ? [] : '-no_ticket'), { - stdio: [ 0, 1, 'pipe' ] + stdio: [0, 1, 'pipe'] }); var err = ''; client.stderr.setEncoding('utf8'); diff --git a/test/simple/test-tls-sni-option.js b/test/simple/test-tls-sni-option.js index 57c17163a749..0744289fc29c 100644 --- a/test/simple/test-tls-sni-option.js +++ b/test/simple/test-tls-sni-option.js @@ -162,6 +162,6 @@ process.on('exit', function() { assert.deepEqual(serverResults, ['a.example.com', 'b.example.com', 'c.wrong.com', null]); assert.deepEqual(clientResults, [true, true, false, false]); - assert.deepEqual(clientErrors, [null, null, null, "socket hang up"]); - assert.deepEqual(serverErrors, [null, null, null, "Invalid SNI context"]); + assert.deepEqual(clientErrors, [null, null, null, 'socket hang up']); + assert.deepEqual(serverErrors, [null, null, null, 'Invalid SNI context']); }); diff --git a/test/simple/test-tls-sni-server-client.js b/test/simple/test-tls-sni-server-client.js index 31fc4194284d..4b1c37fe2016 100644 --- a/test/simple/test-tls-sni-server-client.js +++ b/test/simple/test-tls-sni-server-client.js @@ -111,8 +111,8 @@ function startTest() { var options = clientsOptions[i++]; var client = tls.connect(options, function() { clientResults.push( - client.authorizationError && - /Hostname\/IP doesn't/.test(client.authorizationError)); + client.authorizationError && + /Hostname\/IP doesn't/.test(client.authorizationError)); client.destroy(); // Continue diff --git a/test/simple/test-tls-ticket.js b/test/simple/test-tls-ticket.js index 471d8c3ce805..b304341b61e9 100644 --- a/test/simple/test-tls-ticket.js +++ b/test/simple/test-tls-ticket.js @@ -52,7 +52,8 @@ function createServer() { return server; } -var servers = [ createServer(), createServer(), createServer(), createServer(), createServer(), createServer() ]; +var servers = [createServer(), createServer(), createServer(), + createServer(), createServer(), createServer()]; // Create one TCP server and balance sockets to multiple TLS server instances var shared = net.createServer(function(c) { diff --git a/test/simple/test-url.js b/test/simple/test-url.js index d0ddaf203187..567d8e6501aa 100644 --- a/test/simple/test-url.js +++ b/test/simple/test-url.js @@ -55,7 +55,8 @@ var parseTests = { query: 'json=%22%5C%22foo%5C%22%22', path: '/foo.html?json=%22%5C%22foo%5C%22%22', hash: '#h%5Ca%5Cs%5Ch', - href: 'http://evil-phisher/foo.html?json=%22%5C%22foo%5C%22%22#h%5Ca%5Cs%5Ch' + href: 'http://evil-phisher/foo.html?json=' + + '%22%5C%22foo%5C%22%22#h%5Ca%5Cs%5Ch' }, 'http:\\\\evil-phisher\\foo.html#h\\a\\s\\h?blarg': { @@ -728,7 +729,7 @@ var parseTests = { 'hostname': '-lovemonsterz.tumblr.com', 'href': 'http://-lovemonsterz.tumblr.com/rss', 'pathname': '/rss', - 'path': '/rss', + 'path': '/rss' }, 'http://-lovemonsterz.tumblr.com:80/rss': { @@ -739,7 +740,7 @@ var parseTests = { 'hostname': '-lovemonsterz.tumblr.com', 'href': 'http://-lovemonsterz.tumblr.com:80/rss', 'pathname': '/rss', - 'path': '/rss', + 'path': '/rss' }, 'http://user:pass@-lovemonsterz.tumblr.com/rss': { @@ -750,7 +751,7 @@ var parseTests = { 'hostname': '-lovemonsterz.tumblr.com', 'href': 'http://user:pass@-lovemonsterz.tumblr.com/rss', 'pathname': '/rss', - 'path': '/rss', + 'path': '/rss' }, 'http://user:pass@-lovemonsterz.tumblr.com:80/rss': { @@ -762,7 +763,7 @@ var parseTests = { 'hostname': '-lovemonsterz.tumblr.com', 'href': 'http://user:pass@-lovemonsterz.tumblr.com:80/rss', 'pathname': '/rss', - 'path': '/rss', + 'path': '/rss' }, 'http://_jabber._tcp.google.com/test': { @@ -772,7 +773,7 @@ var parseTests = { 'hostname': '_jabber._tcp.google.com', 'href': 'http://_jabber._tcp.google.com/test', 'pathname': '/test', - 'path': '/test', + 'path': '/test' }, 'http://user:pass@_jabber._tcp.google.com/test': { @@ -783,7 +784,7 @@ var parseTests = { 'hostname': '_jabber._tcp.google.com', 'href': 'http://user:pass@_jabber._tcp.google.com/test', 'pathname': '/test', - 'path': '/test', + 'path': '/test' }, 'http://_jabber._tcp.google.com:80/test': { @@ -794,7 +795,7 @@ var parseTests = { 'hostname': '_jabber._tcp.google.com', 'href': 'http://_jabber._tcp.google.com:80/test', 'pathname': '/test', - 'path': '/test', + 'path': '/test' }, 'http://user:pass@_jabber._tcp.google.com:80/test': { @@ -806,7 +807,7 @@ var parseTests = { 'hostname': '_jabber._tcp.google.com', 'href': 'http://user:pass@_jabber._tcp.google.com:80/test', 'pathname': '/test', - 'path': '/test', + 'path': '/test' }, 'http://x:1/\' <>"`/{}|\\^~`/': { @@ -844,7 +845,7 @@ var parseTests = { query: '@c' }, - 'http://a\r" \t\n<\'b:b@c\r\nd/e?f':{ + 'http://a\r" \t\n<\'b:b@c\r\nd/e?f': { protocol: 'http:', slashes: true, auth: 'a\r" \t\n<\'b:b', @@ -880,9 +881,9 @@ var parseTests = { for (var u in parseTests) { var actual = url.parse(u), spaced = url.parse(' \t ' + u + '\n\t'); - expected = parseTests[u]; + expected = parseTests[u]; - Object.keys(actual).forEach(function (i) { + Object.keys(actual).forEach(function(i) { if (expected[i] === undefined && actual[i] === null) { expected[i] = null; } @@ -934,7 +935,7 @@ var parseTestsWithQueryString = { path: '/example', href: '/example' }, - '/example?query=value':{ + '/example?query=value': { protocol: null, slashes: null, auth: null, @@ -1113,22 +1114,22 @@ var formatTests = { // `#`,`?` in path '/path/to/%%23%3F+=&.txt?foo=theA1#bar' : { - href : '/path/to/%%23%3F+=&.txt?foo=theA1#bar', + href: '/path/to/%%23%3F+=&.txt?foo=theA1#bar', pathname: '/path/to/%#?+=&.txt', query: { foo: 'theA1' }, - hash: "#bar" + hash: '#bar' }, // `#`,`?` in path + `#` in query '/path/to/%%23%3F+=&.txt?foo=the%231#bar' : { - href : '/path/to/%%23%3F+=&.txt?foo=the%231#bar', + href: '/path/to/%%23%3F+=&.txt?foo=the%231#bar', pathname: '/path/to/%#?+=&.txt', query: { foo: 'the#1' }, - hash: "#bar" + hash: '#bar' }, // `?` and `#` in path and search @@ -1138,7 +1139,7 @@ var formatTests = { hostname: 'ex.com', hash: '#frag', search: '?abc=the#1?&foo=bar', - pathname: '/foo?100%m#r', + pathname: '/foo?100%m#r' }, // `?` and `#` in search only @@ -1148,7 +1149,7 @@ var formatTests = { hostname: 'ex.com', hash: '#frag', search: '?abc=the#1?&foo=bar', - pathname: '/fooA100%mBr', + pathname: '/fooA100%mBr' } }; for (var u in formatTests) { diff --git a/test/simple/test-util-format.js b/test/simple/test-util-format.js index 1bea1bf211e0..071a90afbc82 100644 --- a/test/simple/test-util-format.js +++ b/test/simple/test-util-format.js @@ -72,7 +72,8 @@ assert.equal(util.format(new Error('foo')), '[Error: foo]'); function CustomError(msg) { Error.call(this); Object.defineProperty(this, 'message', { value: msg, enumerable: false }); - Object.defineProperty(this, 'name', { value: 'CustomError', enumerable: false }); + Object.defineProperty(this, 'name', + { value: 'CustomError', enumerable: false }); } util.inherits(CustomError, Error); assert.equal(util.format(new CustomError('bar')), '[CustomError: bar]'); diff --git a/test/simple/test-util-inspect.js b/test/simple/test-util-inspect.js index 2a7c2c4fcb5b..9e658b78c192 100644 --- a/test/simple/test-util-inspect.js +++ b/test/simple/test-util-inspect.js @@ -115,8 +115,8 @@ var w = { '\\': 1, '\\\\': 2, '\\\\\\': 3, - '\\\\\\\\': 4, -} + '\\\\\\\\': 4 +}; var y = ['a', 'b', 'c']; y['\\\\\\'] = 'd'; @@ -129,17 +129,17 @@ assert.ok(util.inspect(y), '[ \'a\', \'b\', \'c\', \'\\\\\\\': \'d\' ]'); function test_color_style(style, input, implicit) { var color_name = util.inspect.styles[style]; var color = ['', '']; - if(util.inspect.colors[color_name]) + if (util.inspect.colors[color_name]) color = util.inspect.colors[color_name]; var without_color = util.inspect(input, false, 0, false); var with_color = util.inspect(input, false, 0, true); var expect = '\u001b[' + color[0] + 'm' + without_color + '\u001b[' + color[1] + 'm'; - assert.equal(with_color, expect, 'util.inspect color for style '+style); + assert.equal(with_color, expect, 'util.inspect color for style ' + style); } -test_color_style('special', function(){}); +test_color_style('special', function() {}); test_color_style('number', 123.456); test_color_style('boolean', true); test_color_style('undefined', undefined); @@ -171,9 +171,11 @@ assert(util.inspect(subject, { depth: null }).indexOf('{ d: 0 }') !== -1); subject = { inspect: function() { return 123; } }; assert(util.inspect(subject, { customInspect: true }).indexOf('123') !== -1); -assert(util.inspect(subject, { customInspect: true }).indexOf('inspect') === -1); +assert(util.inspect(subject, { customInspect: true }). + indexOf('inspect') === -1); assert(util.inspect(subject, { customInspect: false }).indexOf('123') === -1); -assert(util.inspect(subject, { customInspect: false }).indexOf('inspect') !== -1); +assert(util.inspect(subject, { customInspect: false }). + indexOf('inspect') !== -1); // custom inspect() functions should be able to return other Objects subject.inspect = function() { return { foo: 'bar' }; }; diff --git a/test/simple/test-util-log.js b/test/simple/test-util-log.js index 1912c69f87fa..2dd55695daad 100644 --- a/test/simple/test-util-log.js +++ b/test/simple/test-util-log.js @@ -39,10 +39,10 @@ var tests = [ {input: null, output: 'null'}, {input: false, output: 'false'}, {input: 42, output: '42'}, - {input: function(){}, output: '[Function]'}, + {input: function() {}, output: '[Function]'}, {input: parseInt('not a number', 10), output: 'NaN'}, {input: {answer: 42}, output: '{ answer: 42 }'}, - {input: [1,2,3], output: '[ 1, 2, 3 ]'} + {input: [1, 2, 3], output: '[ 1, 2, 3 ]'} ]; // test util.log() diff --git a/test/simple/test-util.js b/test/simple/test-util.js index 4e75d512c25f..4370cfb8e9b2 100644 --- a/test/simple/test-util.js +++ b/test/simple/test-util.js @@ -74,10 +74,10 @@ assert.equal(true, util.isError(Object.create(Error.prototype))); assert.ok(util.isObject({}) === true); // _extend -assert.deepEqual(util._extend({a:1}), {a:1}); -assert.deepEqual(util._extend({a:1}, []), {a:1}); -assert.deepEqual(util._extend({a:1}, null), {a:1}); -assert.deepEqual(util._extend({a:1}, true), {a:1}); -assert.deepEqual(util._extend({a:1}, false), {a:1}); -assert.deepEqual(util._extend({a:1}, {b:2}), {a:1, b:2}); -assert.deepEqual(util._extend({a:1, b:2}, {b:3}), {a:1, b:3}); +assert.deepEqual(util._extend({a: 1}), {a: 1}); +assert.deepEqual(util._extend({a: 1}, []), {a: 1}); +assert.deepEqual(util._extend({a: 1}, null), {a: 1}); +assert.deepEqual(util._extend({a: 1}, true), {a: 1}); +assert.deepEqual(util._extend({a: 1}, false), {a: 1}); +assert.deepEqual(util._extend({a: 1}, {b: 2}), {a: 1, b: 2}); +assert.deepEqual(util._extend({a: 1, b: 2}, {b: 3}), {a: 1, b: 3}); diff --git a/test/simple/test-vm-basic.js b/test/simple/test-vm-basic.js index 680a81a4bc9a..4e2c2b4459e0 100644 --- a/test/simple/test-vm-basic.js +++ b/test/simple/test-vm-basic.js @@ -26,12 +26,12 @@ var vm = require('vm'); // Test 1: vm.runInNewContext var sandbox = {}; var result = vm.runInNewContext( - 'foo = "bar"; this.typeofProcess = typeof process; typeof Object;', - sandbox -); + 'foo = "bar"; this.typeofProcess = typeof process; typeof Object;', + sandbox + ); assert.deepEqual(sandbox, { foo: 'bar', - typeofProcess: 'undefined', + typeofProcess: 'undefined' }); assert.strictEqual(result, 'function'); @@ -39,9 +39,9 @@ assert.strictEqual(result, 'function'); var sandbox2 = { foo: 'bar' }; var context = vm.createContext(sandbox2); var result = vm.runInContext( - 'baz = foo; this.typeofProcess = typeof process; typeof Object;', - context -); + 'baz = foo; this.typeofProcess = typeof process; typeof Object;', + context + ); assert.deepEqual(sandbox2, { foo: 'bar', baz: 'bar', @@ -51,16 +51,16 @@ assert.strictEqual(result, 'function'); // Test 3: vm.runInThisContext var result = vm.runInThisContext( - 'vmResult = "foo"; Object.prototype.toString.call(process);' -); + 'vmResult = "foo"; Object.prototype.toString.call(process);' + ); assert.strictEqual(global.vmResult, 'foo'); assert.strictEqual(result, '[object process]'); delete global.vmResult; // Test 4: vm.runInNewContext var result = vm.runInNewContext( - 'vmResult = "foo"; typeof process;' -); + 'vmResult = "foo"; typeof process;' + ); assert.strictEqual(global.vmResult, undefined); assert.strictEqual(result, 'undefined'); diff --git a/test/simple/test-vm-context-async-script.js b/test/simple/test-vm-context-async-script.js index d201e98eb239..806e99840151 100644 --- a/test/simple/test-vm-context-async-script.js +++ b/test/simple/test-vm-context-async-script.js @@ -28,7 +28,7 @@ var sandbox = { setTimeout: setTimeout }; var ctx = vm.createContext(sandbox); vm.runInContext('setTimeout(function() { x = 3; }, 0);', ctx); -setTimeout(function () { +setTimeout(function() { assert.strictEqual(sandbox.x, 3); assert.strictEqual(ctx.x, 3); }, 1); diff --git a/test/simple/test-vm-context.js b/test/simple/test-vm-context.js index c843addc6957..2a7f9b0e1a1b 100644 --- a/test/simple/test-vm-context.js +++ b/test/simple/test-vm-context.js @@ -43,7 +43,7 @@ assert.equal(3, context.foo); assert.equal('lala', context.thing); // Issue GH-227: -assert.throws(function () { +assert.throws(function() { vm.runInNewContext('', null, 'some.js'); }, TypeError); @@ -72,7 +72,7 @@ console.error('test RegExp as argument to assert.throws'); script = vm.createScript('var assert = require(\'assert\'); assert.throws(' + 'function() { throw "hello world"; }, /hello/);', 'some.js'); -script.runInNewContext({ require : require }); +script.runInNewContext({ require: require }); // Issue GH-7529 script = vm.createScript('delete b'); diff --git a/test/simple/test-vm-create-context-arg.js b/test/simple/test-vm-create-context-arg.js index 8c49a3736345..0d0768ab3d54 100644 --- a/test/simple/test-vm-create-context-arg.js +++ b/test/simple/test-vm-create-context-arg.js @@ -33,7 +33,7 @@ assert.doesNotThrow(function() { }); assert.doesNotThrow(function() { - var sandbox = {}; - vm.createContext(sandbox); - vm.createContext(sandbox); + var sandbox = {}; + vm.createContext(sandbox); + vm.createContext(sandbox); }); diff --git a/test/simple/test-vm-cross-context.js b/test/simple/test-vm-cross-context.js index 6f5d501fe026..d35b7014e2af 100644 --- a/test/simple/test-vm-cross-context.js +++ b/test/simple/test-vm-cross-context.js @@ -26,5 +26,5 @@ var vm = require('vm'); var ctx = vm.createContext(global); assert.doesNotThrow(function() { - vm.runInContext("!function() { var x = console.log; }()", ctx); + vm.runInContext('!function() { var x = console.log; }()', ctx); }); diff --git a/test/simple/test-vm-function-declaration.js b/test/simple/test-vm-function-declaration.js index 58772ba2f5ad..b54f9f0693eb 100644 --- a/test/simple/test-vm-function-declaration.js +++ b/test/simple/test-vm-function-declaration.js @@ -34,7 +34,7 @@ code += 'function b(){}\n'; // Grab the global b function as the completion value, to ensure that // we are getting the global function, and not some other thing -code += '(function(){return this})().b;\n' +code += '(function(){return this})().b;\n'; var res = vm.runInContext(code, o, 'test'); diff --git a/test/simple/test-vm-new-script-new-context.js b/test/simple/test-vm-new-script-new-context.js index 139d8542915c..8d9b99fa184b 100644 --- a/test/simple/test-vm-new-script-new-context.js +++ b/test/simple/test-vm-new-script-new-context.js @@ -44,7 +44,7 @@ assert.throws(function() { console.error('undefined reference'); var error; script = new Script('foo.bar = 5;'); -assert.throws(function () { +assert.throws(function() { script.runInNewContext(); }, /not defined/); diff --git a/test/simple/test-vm-run-in-new-context.js b/test/simple/test-vm-run-in-new-context.js index ecb80bdbc05d..1ed45543bfb0 100644 --- a/test/simple/test-vm-run-in-new-context.js +++ b/test/simple/test-vm-run-in-new-context.js @@ -65,7 +65,7 @@ vm.runInNewContext('f.a = 2', { f: f }); assert.equal(f.a, 2); console.error('use function in context without referencing context'); -var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} }) +var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} }); gc(); fn(); // Should not crash diff --git a/test/simple/test-vm-timeout-rethrow.js b/test/simple/test-vm-timeout-rethrow.js index c2158a135091..9cd9d897ca7a 100644 --- a/test/simple/test-vm-timeout-rethrow.js +++ b/test/simple/test-vm-timeout-rethrow.js @@ -25,8 +25,8 @@ var spawn = require('child_process').spawn; if (process.argv[2] === 'child') { var code = 'var j = 0;\n' + - 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' - 'j;'; + 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n'; + 'j;'; var ctx = vm.createContext({ add: function(x, y) { diff --git a/test/simple/test-zlib-convenience-methods.js b/test/simple/test-zlib-convenience-methods.js index 88cf82f04c8d..6b8924ddff87 100644 --- a/test/simple/test-zlib-convenience-methods.js +++ b/test/simple/test-zlib-convenience-methods.js @@ -30,21 +30,21 @@ var hadRun = 0; var expect = 'blahblahblahblahblahblah'; var opts = { level: 9, - chunkSize: 1024, + chunkSize: 1024 }; [ ['gzip', 'gunzip'], ['gzip', 'unzip'], ['deflate', 'inflate'], - ['deflateRaw', 'inflateRaw'], + ['deflateRaw', 'inflateRaw'] ].forEach(function(method) { zlib[method[0]](expect, opts, function(err, result) { zlib[method[1]](result, opts, function(err, result) { assert.equal(result, expect, - 'Should get original string after ' + - method[0] + '/' + method[1] + ' with options.'); + 'Should get original string after ' + + method[0] + '/' + method[1] + ' with options.'); hadRun++; }); }); @@ -52,8 +52,8 @@ var opts = { zlib[method[0]](expect, function(err, result) { zlib[method[1]](result, function(err, result) { assert.equal(result, expect, - 'Should get original string after ' + - method[0] + '/' + method[1] + ' without options.'); + 'Should get original string after ' + + method[0] + '/' + method[1] + ' without options.'); hadRun++; }); }); @@ -61,15 +61,15 @@ var opts = { var result = zlib[method[0] + 'Sync'](expect, opts); result = zlib[method[1] + 'Sync'](result, opts); assert.equal(result, expect, - 'Should get original string after ' + - method[0] + '/' + method[1] + ' with options.'); + 'Should get original string after ' + + method[0] + '/' + method[1] + ' with options.'); hadRun++; result = zlib[method[0] + 'Sync'](expect); result = zlib[method[1] + 'Sync'](result); assert.equal(result, expect, - 'Should get original string after ' + - method[0] + '/' + method[1] + ' without options.'); + 'Should get original string after ' + + method[0] + '/' + method[1] + ' without options.'); hadRun++; }); diff --git a/test/simple/test-zlib-dictionary-fail.js b/test/simple/test-zlib-dictionary-fail.js index fd35a0192aec..663d3bec6abc 100644 --- a/test/simple/test-zlib-dictionary-fail.js +++ b/test/simple/test-zlib-dictionary-fail.js @@ -32,7 +32,7 @@ var zlib = require('zlib'); })); // String "test" encoded with dictionary "dict". - stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5])); + stream.write(Buffer([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5])); })(); // Should raise an error, not trigger an assertion in src/node_zlib.cc @@ -44,5 +44,5 @@ var zlib = require('zlib'); })); // String "test" encoded with dictionary "dict". - stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5])); + stream.write(Buffer([0x78, 0xBB, 0x04, 0x09, 0x01, 0xA5])); })(); diff --git a/test/simple/test-zlib-invalid-input.js b/test/simple/test-zlib-invalid-input.js index c3d8b5b47a5f..2bb4aa40f5e7 100644 --- a/test/simple/test-zlib-invalid-input.js +++ b/test/simple/test-zlib-invalid-input.js @@ -40,20 +40,20 @@ nonStringInputs.forEach(function(input) { console.error('Doing the unzips'); // zlib.Unzip classes need to get valid data, or else they'll throw. -var unzips = [ zlib.Unzip(), +var unzips = [zlib.Unzip(), zlib.Gunzip(), zlib.Inflate(), - zlib.InflateRaw() ]; + zlib.InflateRaw()]; var hadError = []; -unzips.forEach(function (uz, i) { - console.error('Error for '+uz.constructor.name); +unzips.forEach(function(uz, i) { + console.error('Error for ' + uz.constructor.name); uz.on('error', function(er) { console.error('Error event', er); hadError[i] = true; }); uz.on('end', function(er) { - throw new Error('end event should not be emitted '+uz.constructor.name); + throw new Error('end event should not be emitted ' + uz.constructor.name); }); // this will trigger error event diff --git a/test/simple/test-zlib-zero-byte.js b/test/simple/test-zlib-zero-byte.js index 31ac86bd6ab1..50b2c4e31803 100644 --- a/test/simple/test-zlib-zero-byte.js +++ b/test/simple/test-zlib-zero-byte.js @@ -23,7 +23,7 @@ var common = require('../common'); var assert = require('assert'); var zlib = require('zlib'); -var gz = zlib.Gzip() +var gz = zlib.Gzip(); var emptyBuffer = new Buffer(0); var received = 0; gz.on('data', function(c) { diff --git a/test/timers/test-timers-reliability.js b/test/timers/test-timers-reliability.js index c240a44685ac..10894b74401a 100644 --- a/test/timers/test-timers-reliability.js +++ b/test/timers/test-timers-reliability.js @@ -2,10 +2,10 @@ var common = require('../common'); -var Timer = process.binding('timer_wrap').Timer; +var Timer = process.binding('timer_wrap').Timer; var assert = require('assert'); -var timerFired = false; +var timerFired = false; var intervalFired = false; /* @@ -31,23 +31,23 @@ var intervalFired = false; */ var monoTimer = new Timer(); -monoTimer.ontimeout = function () { - /* +monoTimer.ontimeout = function() { + /* * Make sure that setTimeout's and setInterval's callbacks have * already fired, otherwise it means that they are vulnerable to * time drifting or inconsistent time changes. */ - assert(timerFired); - assert(intervalFired); + assert(timerFired); + assert(intervalFired); }; monoTimer.start(300, 0); -var timer = setTimeout(function () { - timerFired = true; +var timer = setTimeout(function() { + timerFired = true; }, 200); -var interval = setInterval(function () { - intervalFired = true; - clearInterval(interval); +var interval = setInterval(function() { + intervalFired = true; + clearInterval(interval); }, 200);