From 892056bf97842b1bfe6a2e328df67d5a0043b79e Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 17 Jan 2012 20:16:49 +0100 Subject: [PATCH] tests: fix more lint issues --- test/common.js | 2 +- test/simple/test-child-process-double-pipe.js | 15 ++-- test/simple/test-executable-path.js | 16 ++-- test/simple/test-http-1.0.js | 6 +- test/simple/test-path-makelong.js | 8 +- test/simple/test-repl-tab-complete.js | 101 ++++++++++++++------------ test/simple/test-script-context.js | 6 +- test/simple/test-stdin-child-proc.js | 2 +- 8 files changed, 87 insertions(+), 69 deletions(-) diff --git a/test/common.js b/test/common.js index d9fa7b7..202d1fa 100644 --- a/test/common.js +++ b/test/common.js @@ -55,7 +55,7 @@ exports.indirectInstanceOf = function(obj, cls) { exports.ddCommand = function(filename, kilobytes) { if (process.platform == 'win32') { return '"' + process.argv[0] + '" "' + path.resolve(exports.fixturesDir, - 'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024); + 'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024); } else { return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes; } diff --git a/test/simple/test-child-process-double-pipe.js b/test/simple/test-child-process-double-pipe.js index cb1edfa..b0fc11d 100644 --- a/test/simple/test-child-process-double-pipe.js +++ b/test/simple/test-child-process-double-pipe.js @@ -28,11 +28,16 @@ var assert = require('assert'), // We're trying to reproduce: // $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/ -var echo = is_windows ? spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo', - 'node&&', 'echo', 'and&&', 'echo', 'world']) : - spawn('echo', ['hello\nnode\nand\nworld\n']), - grep = spawn('grep', ['o']), - sed = spawn('sed', ['s/o/O/']); +var grep = spawn('grep', ['o']), + sed = spawn('sed', ['s/o/O/']), + echo; + +if (is_windows) { + echo = spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo', + 'node&&', 'echo', 'and&&', 'echo', 'world']); +} else { + echo = spawn('echo', ['hello\nnode\nand\nworld\n']); +} /* * grep and sed hang if the spawn function leaks file descriptors to child diff --git a/test/simple/test-executable-path.js b/test/simple/test-executable-path.js index c33a800..8d82b74 100644 --- a/test/simple/test-executable-path.js +++ b/test/simple/test-executable-path.js @@ -26,14 +26,14 @@ var match = false; var isDebug = process.features.debug; -var debugPaths = [ path.normalize(path.join(__dirname, '..', '..', - 'out', 'Debug', 'node')), - path.normalize(path.join(__dirname, '..', '..', - 'Debug', 'node'))]; -var defaultPaths = [ path.normalize(path.join(__dirname, '..', '..', - 'out', 'Release', 'node')), - path.normalize(path.join(__dirname, '..', '..', - 'Release', 'node'))]; +var debugPaths = [path.normalize(path.join(__dirname, '..', '..', + 'out', 'Debug', 'node')), + path.normalize(path.join(__dirname, '..', '..', + 'Debug', 'node'))]; +var defaultPaths = [path.normalize(path.join(__dirname, '..', '..', + 'out', 'Release', 'node')), + path.normalize(path.join(__dirname, '..', '..', + 'Release', 'node'))]; console.error('debugPaths: ' + debugPaths); console.error('defaultPaths: ' + defaultPaths); diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js index 2ed1d13..fadaaf0 100644 --- a/test/simple/test-http-1.0.js +++ b/test/simple/test-http-1.0.js @@ -112,7 +112,8 @@ function test(handler, request_generator, response_validator) { function request_generator() { return ('GET / HTTP/1.0\r\n' + - 'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' + + 'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 ' + + 'OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' + 'Host: 127.0.0.1:1337\r\n' + 'Accept: */*\r\n' + '\r\n'); @@ -147,7 +148,8 @@ function test(handler, request_generator, response_validator) { function request_generator() { return ('GET / HTTP/1.1\r\n' + - 'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' + + 'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 ' + + 'OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' + 'Connection: close\r\n' + 'Host: 127.0.0.1:1337\r\n' + 'Accept: */*\r\n' + diff --git a/test/simple/test-path-makelong.js b/test/simple/test-path-makelong.js index 885eb12..0ec298f 100644 --- a/test/simple/test-path-makelong.js +++ b/test/simple/test-path-makelong.js @@ -26,13 +26,13 @@ if (process.platform === 'win32') { var file = path.join(common.fixturesDir, 'a.js'); var resolvedFile = path.resolve(file); - var networkFile = '\\\\someserver\\someshare\\somefile'; assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file)); assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file)); assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile', - path._makeLong('\\\\someserver\\someshare\\somefile')); + path._makeLong('\\\\someserver\\someshare\\somefile')); assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile', - path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile')); - assert.equal('\\\\.\\pipe\\somepipe', path._makeLong('\\\\.\\pipe\\somepipe')); + path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile')); + assert.equal('\\\\.\\pipe\\somepipe', + path._makeLong('\\\\.\\pipe\\somepipe')); } diff --git a/test/simple/test-repl-tab-complete.js b/test/simple/test-repl-tab-complete.js index 4fdd923..ba51104 100644 --- a/test/simple/test-repl-tab-complete.js +++ b/test/simple/test-repl-tab-complete.js @@ -26,9 +26,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); }); } @@ -36,11 +36,11 @@ function ArrayStream() { util.inherits(ArrayStream, require('stream').Stream); ArrayStream.prototype.readable = true; ArrayStream.prototype.writable = true; -ArrayStream.prototype.resume = function () {}; -ArrayStream.prototype.write = function () {}; +ArrayStream.prototype.resume = function() {}; +ArrayStream.prototype.write = function() {}; -var works = [ [ 'inner.one' ], 'inner.o' ]; -var doesNotBreak = [ [], 'inner.o' ]; +var works = [['inner.one'], 'inner.o']; +var doesNotBreak = [[], 'inner.o']; var putIn = new ArrayStream(); var testMe = repl.start('', putIn); @@ -49,14 +49,15 @@ var testMe = repl.start('', putIn); putIn.run(['.clear']); putIn.run([ 'var inner = {', - 'one:1']); -testMe.complete('inner.o', function (error, data) { + 'one:1' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); // Tab Complete will return globaly scoped variables putIn.run(['};']); -testMe.complete('inner.o', function (error, data) { +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, works); }); @@ -66,8 +67,9 @@ putIn.run(['.clear']); putIn.run([ 'var inner = ( true ' , '?', - '{one: 1} : ']); -testMe.complete('inner.o', function (error, data) { + '{one: 1} : ' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); @@ -76,15 +78,16 @@ putIn.run(['.clear']); // Tab Complete will return a simple local variable putIn.run([ 'var top = function () {', - 'var inner = {one:1};']); -testMe.complete('inner.o', function (error, data) { + 'var inner = {one:1};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, works); }); // When you close the function scope tab complete will not return the // locally scoped variable putIn.run(['};']); -testMe.complete('inner.o', function (error, data) { +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); @@ -93,10 +96,11 @@ putIn.run(['.clear']); // Tab Complete will return a complex local variable putIn.run([ 'var top = function () {', - 'var inner = {', - ' one:1', - '};']); -testMe.complete('inner.o', function (error, data) { + 'var inner = {', + ' one:1', + '};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, works); }); @@ -106,10 +110,11 @@ putIn.run(['.clear']); // has paramaters putIn.run([ 'var top = function (one, two) {', - 'var inner = {', - ' one:1', - '};']); -testMe.complete('inner.o', function (error, data) { + 'var inner = {', + ' one:1', + '};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, works); }); @@ -119,11 +124,12 @@ putIn.run(['.clear']); // scope is nested inside an immediately executed function putIn.run([ 'var top = function () {', - '(function test () {', - 'var inner = {', - ' one:1', - '};']); -testMe.complete('inner.o', function (error, data) { + '(function test () {', + 'var inner = {', + ' one:1', + '};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, works); }); @@ -133,12 +139,13 @@ putIn.run(['.clear']); // def has the params and { on a seperate line putIn.run([ 'var top = function () {', - 'r = function test (', - ' one, two) {', - 'var inner = {', - ' one:1', - '};']); -testMe.complete('inner.o', function (error, data) { + 'r = function test (', + ' one, two) {', + 'var inner = {', + ' one:1', + '};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); @@ -147,12 +154,13 @@ putIn.run(['.clear']); // currently does not work, but should not break, not the { putIn.run([ 'var top = function () {', - 'r = function test ()', - '{', - 'var inner = {', - ' one:1', - '};']); -testMe.complete('inner.o', function (error, data) { + 'r = function test ()', + '{', + 'var inner = {', + ' one:1', + '};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); @@ -161,13 +169,14 @@ putIn.run(['.clear']); // currently does not work, but should not break putIn.run([ 'var top = function () {', - 'r = function test (', - ')', - '{', - 'var inner = {', - ' one:1', - '};']); -testMe.complete('inner.o', function (error, data) { + 'r = function test (', + ')', + '{', + 'var inner = {', + ' one:1', + '};' +]); +testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); diff --git a/test/simple/test-script-context.js b/test/simple/test-script-context.js index 5819744..a8d6c7a 100644 --- a/test/simple/test-script-context.js +++ b/test/simple/test-script-context.js @@ -54,9 +54,11 @@ try { } catch (e) { gh1140Exception = e; - assert.ok(/expected-filename/.test(e.stack), 'expected appearance of filename in Error stack'); + assert.ok(/expected-filename/.test(e.stack), + 'expected appearance of filename in Error stack'); } -assert.ok(gh1140Exception, 'expected exception from runInContext signature test'); +assert.ok(gh1140Exception, + 'expected exception from runInContext signature test'); // GH-558, non-context argument segfaults / raises assertion function isTypeError(o) { diff --git a/test/simple/test-stdin-child-proc.js b/test/simple/test-stdin-child-proc.js index 6c49999..ee23eee 100644 --- a/test/simple/test-stdin-child-proc.js +++ b/test/simple/test-stdin-child-proc.js @@ -24,4 +24,4 @@ var child_process = require('child_process'); var path = require('path'); child_process.spawn(process.execPath, - [ path.resolve(__dirname, 'test-stdin-pause-resume.js') ]); + [path.resolve(__dirname, 'test-stdin-pause-resume.js')]); -- 2.7.4