diff --git a/test/fixtures/a.js b/test/fixtures/a.js index 86b34a7f60b..672da808964 100644 --- a/test/fixtures/a.js +++ b/test/fixtures/a.js @@ -1,25 +1,25 @@ -var c = require("./b/c"); +var c = require('./b/c'); -common.debug("load fixtures/a.js"); +common.debug('load fixtures/a.js'); -var string = "A"; +var string = 'A'; exports.SomeClass = c.SomeClass; -exports.A = function () { +exports.A = function() { return string; }; -exports.C = function () { +exports.C = function() { return c.C(); }; -exports.D = function () { +exports.D = function() { return c.D(); }; exports.number = 42; -process.addListener("exit", function () { - string = "A done"; +process.addListener('exit', function() { + string = 'A done'; }); diff --git a/test/fixtures/b/c.js b/test/fixtures/b/c.js index 66ab77ed7a9..cb4bb5528c1 100644 --- a/test/fixtures/b/c.js +++ b/test/fixtures/b/c.js @@ -1,28 +1,28 @@ -var d = require("./d"); +var d = require('./d'); -var assert = require("assert"); +var assert = require('assert'); -var package = require("./package"); +var package = require('./package'); -assert.equal("world", package.hello); +assert.equal('world', package.hello); -common.debug("load fixtures/b/c.js"); +common.debug('load fixtures/b/c.js'); -var string = "C"; +var string = 'C'; exports.SomeClass = function() { }; -exports.C = function () { +exports.C = function() { return string; }; -exports.D = function () { +exports.D = function() { return d.D(); }; -process.addListener("exit", function () { - string = "C done"; - console.log("b/c.js exit"); +process.addListener('exit', function() { + string = 'C done'; + console.log('b/c.js exit'); }); diff --git a/test/fixtures/b/d.js b/test/fixtures/b/d.js index a7e808b7cde..55c812b7f4d 100644 --- a/test/fixtures/b/d.js +++ b/test/fixtures/b/d.js @@ -1,12 +1,12 @@ -common.debug("load fixtures/b/d.js"); +common.debug('load fixtures/b/d.js'); -var string = "D"; +var string = 'D'; -exports.D = function () { +exports.D = function() { return string; }; -process.addListener("exit", function () { - string = "D done"; +process.addListener('exit', function() { + string = 'D done'; }); diff --git a/test/fixtures/b/package/index.js b/test/fixtures/b/package/index.js index 589096b6998..c69024b7e27 100644 --- a/test/fixtures/b/package/index.js +++ b/test/fixtures/b/package/index.js @@ -1,2 +1,2 @@ -exports.hello = "world"; -common.debug("load package/index.js"); +exports.hello = 'world'; +common.debug('load package/index.js'); diff --git a/test/fixtures/child_process_should_emit_error.js b/test/fixtures/child_process_should_emit_error.js index 3bfdc69a2a5..9f7b2bb80ff 100644 --- a/test/fixtures/child_process_should_emit_error.js +++ b/test/fixtures/child_process_should_emit_error.js @@ -1,8 +1,8 @@ var exec = require('child_process').exec; [0, 1].forEach(function(i) { - exec('ls', function(err, stdout, stderr) { - console.log(i); - throw new Error('hello world'); - }); + exec('ls', function(err, stdout, stderr) { + console.log(i); + throw new Error('hello world'); + }); }); diff --git a/test/fixtures/cycles/folder/foo.js b/test/fixtures/cycles/folder/foo.js index 268a6130ff2..f2bf829bac5 100644 --- a/test/fixtures/cycles/folder/foo.js +++ b/test/fixtures/cycles/folder/foo.js @@ -1,6 +1,6 @@ -var root = require("./../root"); +var root = require('./../root'); -exports.hello = function () { +exports.hello = function() { return root.calledFromFoo(); }; diff --git a/test/fixtures/cycles/root.js b/test/fixtures/cycles/root.js index d93488c8ff0..e73c9d9d6a9 100644 --- a/test/fixtures/cycles/root.js +++ b/test/fixtures/cycles/root.js @@ -1,10 +1,10 @@ -var foo = exports.foo = require("./folder/foo"); +var foo = exports.foo = require('./folder/foo'); -exports.hello = "hello"; -exports.sayHello = function () { +exports.hello = 'hello'; +exports.sayHello = function() { return foo.hello(); }; -exports.calledFromFoo = function () { +exports.calledFromFoo = function() { return exports.hello; }; diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js index f206b515c7c..3aba96b8a79 100644 --- a/test/fixtures/echo.js +++ b/test/fixtures/echo.js @@ -1,14 +1,14 @@ -common = require("../common"); +common = require('../common'); assert = common.assert; -common.print("hello world\r\n"); +common.print('hello world\r\n'); var stdin = process.openStdin(); -stdin.addListener("data", function (data) { +stdin.addListener('data', function(data) { process.stdout.write(data.toString()); }); -stdin.addListener("end", function () { +stdin.addListener('end', function() { process.stdout.end(); }); diff --git a/test/fixtures/global/plain.js b/test/fixtures/global/plain.js index a9d4d9180e0..42567881d65 100644 --- a/test/fixtures/global/plain.js +++ b/test/fixtures/global/plain.js @@ -1,4 +1,4 @@ -foo = "foo"; -global.bar = "bar"; +foo = 'foo'; +global.bar = 'bar'; -exports.fooBar = {foo: global.foo, bar:bar}; \ No newline at end of file +exports.fooBar = {foo: global.foo, bar: bar}; diff --git a/test/fixtures/nested-index/one/hello.js b/test/fixtures/nested-index/one/hello.js index e2872756292..f139fee4d2f 100644 --- a/test/fixtures/nested-index/one/hello.js +++ b/test/fixtures/nested-index/one/hello.js @@ -1,2 +1,2 @@ -exports.hello = "hello from one!"; +exports.hello = 'hello from one!'; diff --git a/test/fixtures/nested-index/two/hello.js b/test/fixtures/nested-index/two/hello.js index fead2bde46b..8ec14b950e7 100644 --- a/test/fixtures/nested-index/two/hello.js +++ b/test/fixtures/nested-index/two/hello.js @@ -1,2 +1,2 @@ -exports.hello = "hello from two!"; +exports.hello = 'hello from two!'; diff --git a/test/fixtures/net-fd-passing-receiver.js b/test/fixtures/net-fd-passing-receiver.js index a51dc094bf5..e22d1883eda 100644 --- a/test/fixtures/net-fd-passing-receiver.js +++ b/test/fixtures/net-fd-passing-receiver.js @@ -1,32 +1,32 @@ -process.mixin(require("../common")); -net = require("net"); +process.mixin(require('../common')); +net = require('net'); path = process.ARGV[2]; greeting = process.ARGV[3]; receiver = net.createServer(function(socket) { - socket.addListener("fd", function(fd) { + socket.addListener('fd', function(fd) { var peerInfo = process.getpeername(fd); peerInfo.fd = fd; var passedSocket = new net.Socket(peerInfo); - passedSocket.addListener("eof", function() { + passedSocket.addListener('eof', function() { passedSocket.close(); }); - passedSocket.addListener("data", function(data) { - passedSocket.send("[echo] " + data); + passedSocket.addListener('data', function(data) { + passedSocket.send('[echo] ' + data); }); - passedSocket.addListener("close", function() { + passedSocket.addListener('close', function() { receiver.close(); }); - passedSocket.send("[greeting] " + greeting); + passedSocket.send('[greeting] ' + greeting); }); }); /* To signal the test runne we're up and listening */ -receiver.addListener("listening", function() { - common.print("ready"); +receiver.addListener('listening', function() { + common.print('ready'); }); receiver.listen(path); diff --git a/test/fixtures/print-chars-from-buffer.js b/test/fixtures/print-chars-from-buffer.js index d8c28703873..9409c1dd890 100644 --- a/test/fixtures/print-chars-from-buffer.js +++ b/test/fixtures/print-chars-from-buffer.js @@ -1,10 +1,12 @@ -common = require("../common"); -assert = common.assert -Buffer = require("buffer").Buffer; +common = require('../common'); +assert = common.assert; +Buffer = require('buffer').Buffer; var n = parseInt(process.argv[2]); b = new Buffer(n); -for (var i = 0; i < n; i++) { b[i] = 100; } +for (var i = 0; i < n; i++) { + b[i] = 100; +} process.stdout.write(b); diff --git a/test/fixtures/print-chars.js b/test/fixtures/print-chars.js index 4ceda97df40..25a4f0632bd 100644 --- a/test/fixtures/print-chars.js +++ b/test/fixtures/print-chars.js @@ -1,9 +1,9 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var n = parseInt(process.argv[2]); -var s = ""; +var s = ''; for (var i = 0; i < n; i++) { s += 'c'; } diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js index 09b2864b7ed..f9ac1fbca7f 100644 --- a/test/fixtures/recvfd.js +++ b/test/fixtures/recvfd.js @@ -36,7 +36,7 @@ function processData(s) { if (pipeStream.write(JSON.stringify(d) + '\n')) { drainFunc(); } -}; +} // Create a UNIX socket to the path defined by argv[2] and read a file // descriptor and misc data from it. diff --git a/test/fixtures/require-path/p1/bar.js b/test/fixtures/require-path/p1/bar.js index cc67811001e..2e8ccf9a2fe 100644 --- a/test/fixtures/require-path/p1/bar.js +++ b/test/fixtures/require-path/p1/bar.js @@ -1,8 +1,8 @@ -var path = require("path"); +var path = require('path'); -require.paths.unshift(path.join(__dirname,"../p2")); +require.paths.unshift(path.join(__dirname, '../p2')); -exports.foo = require("foo"); +exports.foo = require('foo'); -exports.expect = require(path.join(__dirname, "../p2/bar")); +exports.expect = require(path.join(__dirname, '../p2/bar')); exports.actual = exports.foo.bar; diff --git a/test/fixtures/require-path/p1/foo.js b/test/fixtures/require-path/p1/foo.js index 6e926f2746d..43a7e4b8ca7 100644 --- a/test/fixtures/require-path/p1/foo.js +++ b/test/fixtures/require-path/p1/foo.js @@ -1,2 +1,2 @@ require.paths.unshift(__dirname); -exports.bar = require("bar"); +exports.bar = require('bar'); diff --git a/test/fixtures/require-path/p2/foo.js b/test/fixtures/require-path/p2/foo.js index ebf2ac288c4..0ee9298bc76 100644 --- a/test/fixtures/require-path/p2/foo.js +++ b/test/fixtures/require-path/p2/foo.js @@ -1,2 +1,2 @@ require.paths.unshift(__dirname); -exports.bar = require("bar"); // surprise! this is not /p2/bar, this is /p1/bar +exports.bar = require('bar'); // surprise! this is not /p2/bar, this is /p1/bar diff --git a/test/fixtures/should_exit.js b/test/fixtures/should_exit.js index 826a1181d5b..1a37a575c4a 100644 --- a/test/fixtures/should_exit.js +++ b/test/fixtures/should_exit.js @@ -1,6 +1,6 @@ function tmp() {} -process.addListener("SIGINT", tmp); -process.removeListener("SIGINT", tmp); -setInterval(function () { +process.addListener('SIGINT', tmp); +process.removeListener('SIGINT', tmp); +setInterval(function() { process.stdout.write('keep alive\n'); }, 1000); diff --git a/test/fixtures/stdio-filter.js b/test/fixtures/stdio-filter.js index b3e481330e1..0078b5fa0ab 100644 --- a/test/fixtures/stdio-filter.js +++ b/test/fixtures/stdio-filter.js @@ -5,7 +5,7 @@ var replacement = process.argv[3]; var re = new RegExp(regexIn, 'g'); var stdin = process.openStdin(); -stdin.addListener("data", function (data) { +stdin.addListener('data', function(data) { data = data.toString(); process.stdout.write(data.replace(re, replacement)); }); diff --git a/test/fixtures/throws_error.js b/test/fixtures/throws_error.js index 728ece555f5..80055bdf603 100644 --- a/test/fixtures/throws_error.js +++ b/test/fixtures/throws_error.js @@ -1 +1 @@ -throw new Error("blah"); +throw new Error('blah'); diff --git a/test/fixtures/throws_error1.js b/test/fixtures/throws_error1.js index 728ece555f5..80055bdf603 100644 --- a/test/fixtures/throws_error1.js +++ b/test/fixtures/throws_error1.js @@ -1 +1 @@ -throw new Error("blah"); +throw new Error('blah'); diff --git a/test/fixtures/throws_error3.js b/test/fixtures/throws_error3.js index aaf774b2eff..080d0311fd2 100644 --- a/test/fixtures/throws_error3.js +++ b/test/fixtures/throws_error3.js @@ -1,3 +1,3 @@ -process.nextTick(function () { +process.nextTick(function() { JSON.parse(undefined); }); diff --git a/test/message/2100bytes.js b/test/message/2100bytes.js index cc371f0db02..f4da1a3e575 100644 --- a/test/message/2100bytes.js +++ b/test/message/2100bytes.js @@ -1,49 +1,49 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; util = require('util'); console.log([ - '_______________________________________________50', - '______________________________________________100', - '______________________________________________150', - '______________________________________________200', - '______________________________________________250', - '______________________________________________300', - '______________________________________________350', - '______________________________________________400', - '______________________________________________450', - '______________________________________________500', - '______________________________________________550', - '______________________________________________600', - '______________________________________________650', - '______________________________________________700', - '______________________________________________750', - '______________________________________________800', - '______________________________________________850', - '______________________________________________900', - '______________________________________________950', - '_____________________________________________1000', - '_____________________________________________1050', - '_____________________________________________1100', - '_____________________________________________1150', - '_____________________________________________1200', - '_____________________________________________1250', - '_____________________________________________1300', - '_____________________________________________1350', - '_____________________________________________1400', - '_____________________________________________1450', - '_____________________________________________1500', - '_____________________________________________1550', - '_____________________________________________1600', - '_____________________________________________1650', - '_____________________________________________1700', - '_____________________________________________1750', - '_____________________________________________1800', - '_____________________________________________1850', - '_____________________________________________1900', - '_____________________________________________1950', - '_____________________________________________2000', - '_____________________________________________2050', - '_____________________________________________2100', + '_______________________________________________50', + '______________________________________________100', + '______________________________________________150', + '______________________________________________200', + '______________________________________________250', + '______________________________________________300', + '______________________________________________350', + '______________________________________________400', + '______________________________________________450', + '______________________________________________500', + '______________________________________________550', + '______________________________________________600', + '______________________________________________650', + '______________________________________________700', + '______________________________________________750', + '______________________________________________800', + '______________________________________________850', + '______________________________________________900', + '______________________________________________950', + '_____________________________________________1000', + '_____________________________________________1050', + '_____________________________________________1100', + '_____________________________________________1150', + '_____________________________________________1200', + '_____________________________________________1250', + '_____________________________________________1300', + '_____________________________________________1350', + '_____________________________________________1400', + '_____________________________________________1450', + '_____________________________________________1500', + '_____________________________________________1550', + '_____________________________________________1600', + '_____________________________________________1650', + '_____________________________________________1700', + '_____________________________________________1750', + '_____________________________________________1800', + '_____________________________________________1850', + '_____________________________________________1900', + '_____________________________________________1950', + '_____________________________________________2000', + '_____________________________________________2050', + '_____________________________________________2100' ].join('\n')); diff --git a/test/message/hello_world.js b/test/message/hello_world.js index 522d64903b7..6f60c4cc0e4 100644 --- a/test/message/hello_world.js +++ b/test/message/hello_world.js @@ -1,4 +1,4 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; console.log('hello world'); diff --git a/test/message/undefined_reference_in_new_context.js b/test/message/undefined_reference_in_new_context.js index b7d8d225410..67fe9be494b 100644 --- a/test/message/undefined_reference_in_new_context.js +++ b/test/message/undefined_reference_in_new_context.js @@ -1,5 +1,5 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; common.error('before'); diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index 8624fff8db3..bd81341bd52 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -1,5 +1,5 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var spawn = require('child_process').spawn; @@ -7,23 +7,23 @@ var SIZE = 1000 * 1024; var N = 40; var finished = false; -function doSpawn (i) { - var child = spawn( 'python', ['-c', 'print ' + SIZE + ' * "C"']); +function doSpawn(i) { + var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']); var count = 0; child.stdout.setEncoding('ascii'); - child.stdout.addListener("data", function (chunk) { + child.stdout.addListener('data', function(chunk) { count += chunk.length; }); - child.stderr.addListener("data", function (chunk) { + child.stderr.addListener('data', function(chunk) { console.log('stderr: ' + chunk); }); - child.addListener("exit", function () { + child.addListener('exit', function() { assert.equal(SIZE + 1, count); // + 1 for \n if (i < N) { - doSpawn(i+1); + doSpawn(i + 1); } else { finished = true; } @@ -32,6 +32,6 @@ function doSpawn (i) { doSpawn(0); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.ok(finished); }); diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index bf26a7b018b..3a5de31cafb 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -1,9 +1,9 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; -var net = require("net"), - util = require("util"), - http = require("http"); +var net = require('net'), + util = require('util'), + http = require('http'); var errorCount = 0; var eofCount = 0; @@ -11,33 +11,33 @@ var eofCount = 0; var server = net.createServer(function(socket) { socket.end(); }); -server.on('listening', function(){ +server.on('listening', function() { var client = http.createClient(common.PORT); - client.addListener("error", function(err) { - console.log("ERROR! "+(err.stack||err)); + client.addListener('error', function(err) { + console.log('ERROR! ' + (err.stack || err)); errorCount++; }); - client.addListener("end", function() { - console.log("EOF!"); + client.addListener('end', function() { + console.log('EOF!'); eofCount++; }); - var request = client.request("GET", "/", {"host": "localhost"}); + var request = client.request('GET', '/', {'host': 'localhost'}); request.end(); request.addListener('response', function(response) { - console.log("STATUS: " + response.statusCode); + console.log('STATUS: ' + response.statusCode); }); }); server.listen(common.PORT); -setTimeout(function () { +setTimeout(function() { server.close(); }, 500); -process.addListener('exit', function () { +process.addListener('exit', function() { assert.equal(0, errorCount); assert.equal(1, eofCount); }); diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js index e37b6953257..4fb49800193 100644 --- a/test/pummel/test-http-upload-timeout.js +++ b/test/pummel/test-http-upload-timeout.js @@ -1,8 +1,8 @@ // This tests setTimeout() by having multiple clients connecting and sending // data in random intervals. Clients are also randomly disconnecting until there // are no more clients left. If no false timeout occurs, this test has passed. -var common = require("../common"), - assert = require("assert"), +var common = require('../common'), + assert = require('assert'), http = require('http'), server = http.createServer(), connections = 0; diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index fb0979a543f..d75ac9bd53a 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -1,14 +1,14 @@ -// This test requires the program "ab" -common = require("../common"); -assert = common.assert -http = require("http"); -exec = require("child_process").exec; +// This test requires the program 'ab' +common = require('../common'); +assert = common.assert; +http = require('http'); +exec = require('child_process').exec; -body = "hello world\n"; -server = http.createServer(function (req, res) { +body = 'hello world\n'; +server = http.createServer(function(req, res) { res.writeHead(200, { - "Content-Length": body.length, - "Content-Type": "text/plain" + 'Content-Length': body.length, + 'Content-Type': 'text/plain' }); res.write(body); res.end(); @@ -19,11 +19,11 @@ var normalReqSec = 0; function runAb(opts, callback) { - var command = "ab " + opts + " http://127.0.0.1:" + common.PORT + "/"; - exec(command, function (err, stdout, stderr) { + var command = 'ab ' + opts + ' http://127.0.0.1:' + common.PORT + '/'; + exec(command, function(err, stdout, stderr) { if (err) { - if (stderr.indexOf("ab") >= 0) { - console.log("ab not installed? skipping test.\n" + stderr); + if (stderr.indexOf('ab') >= 0) { + console.log('ab not installed? skipping test.\n' + stderr); process.reallyExit(0); } return; @@ -44,22 +44,22 @@ function runAb(opts, callback) { }); } -server.listen(common.PORT, function () { - runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) { +server.listen(common.PORT, function() { + runAb('-k -c 100 -t 2', function(reqSec, keepAliveRequests) { keepAliveReqSec = reqSec; assert.equal(true, keepAliveRequests > 0); - console.log("keep-alive: " + keepAliveReqSec + " req/sec"); + console.log('keep-alive: ' + keepAliveReqSec + ' req/sec'); - runAb("-c 100 -t 2", function (reqSec, keepAliveRequests) { + runAb('-c 100 -t 2', function(reqSec, keepAliveRequests) { normalReqSec = reqSec; assert.equal(0, keepAliveRequests); - console.log("normal: " + normalReqSec + " req/sec"); + console.log('normal: ' + normalReqSec + ' req/sec'); server.close(); }); }); }); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(true, normalReqSec > 50); assert.equal(true, keepAliveReqSec > 50); assert.equal(true, normalReqSec < keepAliveReqSec); diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index f6e3619d39e..e389099829a 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -1,56 +1,56 @@ -common = require("../common"); -assert = common.assert -net = require("net"); +common = require('../common'); +assert = common.assert; +net = require('net'); // settings -var bytes = 1024*40; +var bytes = 1024 * 40; var concurrency = 100; var connections_per_client = 5; // measured var total_connections = 0; -var body = ""; +var body = ''; for (var i = 0; i < bytes; i++) { - body += "C"; + body += 'C'; } -var server = net.createServer(function (c) { - c.addListener("connect", function () { +var server = net.createServer(function(c) { + c.addListener('connect', function() { total_connections++; - common.print("#"); + common.print('#'); c.write(body); c.end(); }); }); -function runClient (callback) { +function runClient(callback) { var client = net.createConnection(common.PORT); client.connections = 0; - client.setEncoding("utf8"); + client.setEncoding('utf8'); - client.addListener("connect", function () { - common.print("c"); - client.recved = ""; + client.addListener('connect', function() { + common.print('c'); + client.recved = ''; client.connections += 1; }); - client.addListener("data", function (chunk) { + client.addListener('data', function(chunk) { this.recved += chunk; }); - client.addListener("end", function () { + client.addListener('end', function() { client.end(); }); - client.addListener("error", function (e) { - console.log("\n\nERROOOOOr"); + client.addListener('error', function(e) { + console.log('\n\nERROOOOOr'); throw e; }); - client.addListener("close", function (had_error) { - common.print("."); + client.addListener('close', function(had_error) { + common.print('.'); assert.equal(false, had_error); assert.equal(bytes, client.recved.length); @@ -67,16 +67,16 @@ function runClient (callback) { }); } -server.listen(common.PORT, function () { +server.listen(common.PORT, function() { var finished_clients = 0; for (var i = 0; i < concurrency; i++) { - runClient(function () { + runClient(function() { if (++finished_clients == concurrency) server.close(); }); } }); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(connections_per_client * concurrency, total_connections); - console.log("\nokay!"); + console.log('\nokay!'); }); diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index 82b48ba0464..057da9f85a4 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -1,47 +1,47 @@ -var common = require("../common"); +var common = require('../common'); var assert = common.assert; -var net = require("net"); +var net = require('net'); var N = 200; -var recv = "", chars_recved = 0; +var recv = '', chars_recved = 0; -server = net.createServer(function (connection) { - function write (j) { +server = net.createServer(function(connection) { + function write(j) { if (j >= N) { connection.end(); return; } - setTimeout(function () { - connection.write("C"); - write(j+1); + setTimeout(function() { + connection.write('C'); + write(j + 1); }, 10); } write(0); }); -server.on('listening', function(){ +server.on('listening', function() { client = net.createConnection(common.PORT); - client.setEncoding("ascii"); - client.addListener("data", function (d) { - common.print(d); - recv += d; + client.setEncoding('ascii'); + client.addListener('data', function(d) { + common.print(d); + recv += d; }); - setTimeout(function () { + setTimeout(function() { chars_recved = recv.length; - console.log("pause at: " + chars_recved); + console.log('pause at: ' + chars_recved); assert.equal(true, chars_recved > 1); client.pause(); - setTimeout(function () { - console.log("resume at: " + chars_recved); + setTimeout(function() { + console.log('resume at: ' + chars_recved); assert.equal(chars_recved, recv.length); client.resume(); - setTimeout(function () { + setTimeout(function() { chars_recved = recv.length; - console.log("pause at: " + chars_recved); + console.log('pause at: ' + chars_recved); client.pause(); - setTimeout(function () { - console.log("resume at: " + chars_recved); + setTimeout(function() { + console.log('resume at: ' + chars_recved); assert.equal(chars_recved, recv.length); client.resume(); @@ -53,14 +53,14 @@ server.on('listening', function(){ }, 500); - client.addListener("end", function () { + client.addListener('end', function() { server.close(); client.end(); }); }); server.listen(common.PORT); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(N, recv.length); - common.debug("Exit"); + common.debug('Exit'); }); diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js index f1e3dace439..41c69227c76 100644 --- a/test/pummel/test-net-pingpong-delay.js +++ b/test/pummel/test-net-pingpong-delay.js @@ -1,84 +1,84 @@ -common = require("../common"); -assert = common.assert -net = require("net"); +common = require('../common'); +assert = common.assert; +net = require('net'); var tests_run = 0; -function pingPongTest (port, host, on_complete) { +function pingPongTest(port, host, on_complete) { var N = 100; var DELAY = 1; var count = 0; var client_ended = false; - var server = net.createServer({ allowHalfOpen: true }, function (socket) { - socket.setEncoding("utf8"); + var server = net.createServer({ allowHalfOpen: true }, function(socket) { + socket.setEncoding('utf8'); - socket.addListener("data", function (data) { + socket.addListener('data', function(data) { console.log(data); - assert.equal("PING", data); - assert.equal("open", socket.readyState); + assert.equal('PING', data); + assert.equal('open', socket.readyState); assert.equal(true, count <= N); - setTimeout(function () { - assert.equal("open", socket.readyState); - socket.write("PONG"); + setTimeout(function() { + assert.equal('open', socket.readyState); + socket.write('PONG'); }, DELAY); }); - socket.addListener("timeout", function () { - common.debug("server-side timeout!!"); + socket.addListener('timeout', function() { + common.debug('server-side timeout!!'); assert.equal(false, true); }); - socket.addListener("end", function () { - console.log("server-side socket EOF"); - assert.equal("writeOnly", socket.readyState); + socket.addListener('end', function() { + console.log('server-side socket EOF'); + assert.equal('writeOnly', socket.readyState); socket.end(); }); - socket.addListener("close", function (had_error) { - console.log("server-side socket.end"); + socket.addListener('close', function(had_error) { + console.log('server-side socket.end'); assert.equal(false, had_error); - assert.equal("closed", socket.readyState); + assert.equal('closed', socket.readyState); socket.server.close(); }); }); - server.listen(port, host, function () { + server.listen(port, host, function() { var client = net.createConnection(port, host); - client.setEncoding("utf8"); + client.setEncoding('utf8'); - client.addListener("connect", function () { - assert.equal("open", client.readyState); - client.write("PING"); + client.addListener('connect', function() { + assert.equal('open', client.readyState); + client.write('PING'); }); - client.addListener("data", function (data) { + client.addListener('data', function(data) { console.log(data); - assert.equal("PONG", data); - assert.equal("open", client.readyState); + assert.equal('PONG', data); + assert.equal('open', client.readyState); - setTimeout(function () { - assert.equal("open", client.readyState); + setTimeout(function() { + assert.equal('open', client.readyState); if (count++ < N) { - client.write("PING"); + client.write('PING'); } else { - console.log("closing client"); + console.log('closing client'); client.end(); client_ended = true; } }, DELAY); }); - client.addListener("timeout", function () { - common.debug("client-side timeout!!"); + client.addListener('timeout', function() { + common.debug('client-side timeout!!'); assert.equal(false, true); }); - client.addListener("close", function () { - console.log("client.end"); - assert.equal(N+1, count); + client.addListener('close', function() { + console.log('client.end'); + assert.equal(N + 1, count); assert.ok(client_ended); if (on_complete) on_complete(); tests_run += 1; @@ -88,6 +88,6 @@ function pingPongTest (port, host, on_complete) { pingPongTest(common.PORT); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(1, tests_run); }); diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index e58b4734a4f..4546470f53b 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -1,83 +1,84 @@ -common = require("../common"); -assert = common.assert -net = require("net"); +common = require('../common'); +assert = common.assert; +net = require('net'); var tests_run = 0; -function pingPongTest (port, host, on_complete) { +function pingPongTest(port, host, on_complete) { var N = 1000; var count = 0; var sent_final_ping = false; - var server = net.createServer({ allowHalfOpen: true }, function (socket) { + var server = net.createServer({ allowHalfOpen: true }, function(socket) { assert.equal(true, socket.remoteAddress !== null); assert.equal(true, socket.remoteAddress !== undefined); - if (host === "127.0.0.1" || host === "localhost" || !host) { - assert.equal(socket.remoteAddress, "127.0.0.1"); + if (host === '127.0.0.1' || host === 'localhost' || !host) { + assert.equal(socket.remoteAddress, '127.0.0.1'); } else { - console.log('host = ' + host + ', remoteAddress = ' + socket.remoteAddress); - assert.equal(socket.remoteAddress, "::1"); + console.log('host = ' + host + + ', remoteAddress = ' + socket.remoteAddress); + assert.equal(socket.remoteAddress, '::1'); } - socket.setEncoding("utf8"); + socket.setEncoding('utf8'); socket.setNoDelay(); socket.timeout = 0; - socket.addListener("data", function (data) { - console.log("server got: " + JSON.stringify(data)); - assert.equal("open", socket.readyState); + socket.addListener('data', function(data) { + console.log('server got: ' + JSON.stringify(data)); + assert.equal('open', socket.readyState); assert.equal(true, count <= N); if (/PING/.exec(data)) { - socket.write("PONG"); + socket.write('PONG'); } }); - socket.addListener("end", function () { - assert.equal("writeOnly", socket.readyState); + socket.addListener('end', function() { + assert.equal('writeOnly', socket.readyState); socket.end(); }); - socket.addListener("close", function (had_error) { + socket.addListener('close', function(had_error) { assert.equal(false, had_error); - assert.equal("closed", socket.readyState); + assert.equal('closed', socket.readyState); socket.server.close(); }); }); - server.listen(port, host, function () { + server.listen(port, host, function() { var client = net.createConnection(port, host); - client.setEncoding("utf8"); + client.setEncoding('utf8'); - client.addListener("connect", function () { - assert.equal("open", client.readyState); - client.write("PING"); + client.addListener('connect', function() { + assert.equal('open', client.readyState); + client.write('PING'); }); - client.addListener("data", function (data) { + client.addListener('data', function(data) { console.log('client got: ' + data); - assert.equal("PONG", data); + assert.equal('PONG', data); count += 1; if (sent_final_ping) { - assert.equal("readOnly", client.readyState); + assert.equal('readOnly', client.readyState); return; } else { - assert.equal("open", client.readyState); + assert.equal('open', client.readyState); } if (count < N) { - client.write("PING"); + client.write('PING'); } else { sent_final_ping = true; - client.write("PING"); + client.write('PING'); client.end(); } }); - client.addListener("close", function () { - assert.equal(N+1, count); + client.addListener('close', function() { + assert.equal(N + 1, count); assert.equal(true, sent_final_ping); if (on_complete) on_complete(); tests_run += 1; @@ -86,13 +87,13 @@ function pingPongTest (port, host, on_complete) { } /* All are run at once, so run on different ports */ -pingPongTest(common.PORT, "localhost"); -pingPongTest(common.PORT+1, null); +pingPongTest(common.PORT, 'localhost'); +pingPongTest(common.PORT + 1, null); // This IPv6 isn't working on Solaris var solaris = /sunos/i.test(process.platform); -if (!solaris) pingPongTest(common.PORT+2, "::1"); +if (!solaris) pingPongTest(common.PORT + 2, '::1'); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(solaris ? 2 : 3, tests_run); }); diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index 6aada7ab70f..66f74f08708 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -1,49 +1,49 @@ -common = require("../common"); -assert = common.assert -net = require("net"); -N = 160*1024; // 30kb +common = require('../common'); +assert = common.assert; +net = require('net'); +N = 160 * 1024; // 30kb chars_recved = 0; npauses = 0; -console.log("build big string"); -var body = ""; +console.log('build big string'); +var body = ''; for (var i = 0; i < N; i++) { - body += "C"; + body += 'C'; } -console.log("start server on port " + common.PORT); +console.log('start server on port ' + common.PORT); -server = net.createServer(function (connection) { - connection.addListener("connect", function () { +server = net.createServer(function(connection) { + connection.addListener('connect', function() { assert.equal(false, connection.write(body)); connection.end(); }); }); -server.listen(common.PORT, function () { +server.listen(common.PORT, function() { var paused = false; client = net.createConnection(common.PORT); - client.setEncoding("ascii"); - client.addListener("data", function (d) { + client.setEncoding('ascii'); + client.addListener('data', function(d) { chars_recved += d.length; - console.log("got " + chars_recved); + console.log('got ' + chars_recved); if (!paused) { client.pause(); npauses += 1; paused = true; - console.log("pause"); + console.log('pause'); x = chars_recved; - setTimeout(function () { + setTimeout(function() { assert.equal(chars_recved, x); client.resume(); - console.log("resume"); + console.log('resume'); paused = false; }, 100); } }); - client.addListener("end", function () { + client.addListener('end', function() { server.close(); client.end(); }); @@ -51,7 +51,7 @@ server.listen(common.PORT, function () { -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(N, chars_recved); assert.equal(true, npauses > 2); }); diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index a02540e8130..d571acd4c3a 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -1,83 +1,83 @@ -common = require("../common"); -assert = common.assert -net = require("net"); +common = require('../common'); +assert = common.assert; +net = require('net'); exchanges = 0; starttime = null; timeouttime = null; timeout = 1000; -var echo_server = net.createServer(function (socket) { +var echo_server = net.createServer(function(socket) { socket.setTimeout(timeout); - socket.addListener("timeout", function () { - console.log("server timeout"); + socket.addListener('timeout', function() { + console.log('server timeout'); timeouttime = new Date; console.dir(timeouttime); socket.destroy(); }); - socket.addListener("error", function (e) { - throw new Error("Server side socket should not get error. We disconnect willingly."); + socket.addListener('error', function(e) { + throw new Error('Server side socket should not get error. We disconnect willingly.'); }) - socket.addListener("data", function (d) { + socket.addListener('data', function(d) { console.log(d); socket.write(d); }); - socket.addListener("end", function () { + socket.addListener('end', function() { socket.end(); }); }); -echo_server.listen(common.PORT, function () { - console.log("server listening at " + common.PORT); +echo_server.listen(common.PORT, function() { + console.log('server listening at ' + common.PORT); var client = net.createConnection(common.PORT); - client.setEncoding("UTF8"); + client.setEncoding('UTF8'); client.setTimeout(0); // disable the timeout for client - client.addListener("connect", function () { - console.log("client connected."); - client.write("hello\r\n"); + client.addListener('connect', function() { + console.log('client connected.'); + client.write('hello\r\n'); }); - client.addListener("data", function (chunk) { - assert.equal("hello\r\n", chunk); + client.addListener('data', function(chunk) { + assert.equal('hello\r\n', chunk); if (exchanges++ < 5) { - setTimeout(function () { - console.log("client write 'hello'"); - client.write("hello\r\n"); + setTimeout(function() { + console.log('client write "hello"'); + client.write('hello\r\n'); }, 500); if (exchanges == 5) { - console.log("wait for timeout - should come in " + timeout + " ms"); + console.log('wait for timeout - should come in ' + timeout + ' ms'); starttime = new Date; console.dir(starttime); } } }); - client.addListener("timeout", function () { + client.addListener('timeout', function() { throw new Error("client timeout - this shouldn't happen"); }); - client.addListener("end", function () { - console.log("client end"); + client.addListener('end', function() { + console.log('client end'); client.end(); }); - client.addListener("close", function () { - console.log("client disconnect"); + client.addListener('close', function() { + console.log('client disconnect'); echo_server.close(); }); }); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.ok(starttime != null); assert.ok(timeouttime != null); diff = timeouttime - starttime; - console.log("diff = " + diff); + console.log('diff = ' + diff); assert.ok(timeout < diff); diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index a9681d782a1..e25f5844e12 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -1,4 +1,4 @@ -common = require("../common"); +common = require('../common'); assert = common.assert assert = require('assert'); @@ -14,28 +14,28 @@ clearInterval(null); assert.equal(true, setTimeout instanceof Function); var starttime = new Date; -setTimeout(function () { +setTimeout(function() { var endtime = new Date; var diff = endtime - starttime; assert.ok(diff > 0); - console.log("diff: " + diff); + console.log('diff: ' + diff); assert.equal(true, 1000 - WINDOW < diff && diff < 1000 + WINDOW); setTimeout_called = true; }, 1000); // this timer shouldn't execute -var id = setTimeout(function () { assert.equal(true, false); }, 500); +var id = setTimeout(function() { assert.equal(true, false); }, 500); clearTimeout(id); -setInterval(function () { +setInterval(function() { interval_count += 1; var endtime = new Date; var diff = endtime - starttime; assert.ok(diff > 0); - console.log("diff: " + diff); + console.log('diff: ' + diff); var t = interval_count * 1000; @@ -49,38 +49,38 @@ setInterval(function () { // Single param: setTimeout(function(param){ - assert.equal("test param", param); -}, 1000, "test param"); + assert.equal('test param', param); +}, 1000, 'test param'); var interval_count2 = 0; setInterval(function(param){ ++interval_count2; - assert.equal("test param", param); + assert.equal('test param', param); if(interval_count2 == 3) clearInterval(this); -}, 1000, "test param"); +}, 1000, 'test param'); // Multiple param setTimeout(function(param1, param2){ - assert.equal("param1", param1); - assert.equal("param2", param2); -}, 1000, "param1", "param2"); + assert.equal('param1', param1); + assert.equal('param2', param2); +}, 1000, 'param1', 'param2'); var interval_count3 = 0; setInterval(function(param1, param2){ ++interval_count3; - assert.equal("param1", param1); - assert.equal("param2", param2); + assert.equal('param1', param1); + assert.equal('param2', param2); if(interval_count3 == 3) clearInterval(this); -}, 1000, "param1", "param2"); +}, 1000, 'param1', 'param2'); // setInterval(cb, 0) should be called multiple times. count4 = 0; -interval4 = setInterval(function () { +interval4 = setInterval(function() { if (++count4 > 10) clearInterval(interval4); }, 0); @@ -101,9 +101,9 @@ z = setTimeout(t, 200); clearTimeout(y); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.equal(true, setTimeout_called); assert.equal(3, interval_count); assert.equal(11, count4); - assert.equal(0, expectedTimeouts, "clearTimeout cleared too many timeouts"); + assert.equal(0, expectedTimeouts, 'clearTimeout cleared too many timeouts'); }); diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 8c594410ed5..f949c13710b 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -1,18 +1,18 @@ -common = require("../common"); +common = require('../common'); assert = common.assert -var fs = require("fs"); -var path = require("path"); +var fs = require('fs'); +var path = require('path'); -var f = path.join(common.fixturesDir, "x.txt"); -var f2 = path.join(common.fixturesDir, "x2.txt"); +var f = path.join(common.fixturesDir, 'x.txt'); +var f2 = path.join(common.fixturesDir, 'x2.txt'); -console.log("watching for changes of " + f); +console.log('watching for changes of ' + f); var changes = 0; function watchFile () { - fs.watchFile(f, function (curr, prev) { - console.log(f + " change"); + fs.watchFile(f, function(curr, prev) { + console.log(f + ' change'); changes++; assert.ok(curr.mtime != prev.mtime); fs.unwatchFile(f); @@ -24,10 +24,10 @@ function watchFile () { watchFile(); -var fd = fs.openSync(f, "w+"); +var fd = fs.openSync(f, 'w+'); fs.writeSync(fd, 'xyz\n'); fs.closeSync(fd); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.ok(changes > 0); }); diff --git a/test/simple/test-next-tick-ordering.js b/test/simple/test-next-tick-ordering.js index 5621272a65f..90dec646aa5 100644 --- a/test/simple/test-next-tick-ordering.js +++ b/test/simple/test-next-tick-ordering.js @@ -1,32 +1,32 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var i; var N = 30; var done = []; function get_printer(timeout) { - return function () { - console.log("Running from setTimeout " + timeout); + return function() { + console.log('Running from setTimeout ' + timeout); done.push(timeout); }; } -process.nextTick(function () { - console.log("Running from nextTick"); +process.nextTick(function() { + console.log('Running from nextTick'); done.push('nextTick'); -}) +}); for (i = 0; i < N; i += 1) { setTimeout(get_printer(i), i); } -console.log("Running from main."); +console.log('Running from main.'); -process.addListener('exit', function () { +process.addListener('exit', function() { assert.equal('nextTick', done[0]); for (i = 0; i < N; i += 1) { - assert.equal(i, done[i+1]); + assert.equal(i, done[i + 1]); } }); diff --git a/test/simple/test-next-tick-ordering2.js b/test/simple/test-next-tick-ordering2.js index 4280abd1d61..a699c51f276 100644 --- a/test/simple/test-next-tick-ordering2.js +++ b/test/simple/test-next-tick-ordering2.js @@ -1,8 +1,8 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var order = []; -process.nextTick(function () { +process.nextTick(function() { setTimeout(function() { order.push('setTimeout'); }, 0); @@ -12,6 +12,6 @@ process.nextTick(function () { }); }) -process.addListener('exit', function () { +process.addListener('exit', function() { assert.deepEqual(order, ['nextTick', 'setTimeout']); }); diff --git a/test/simple/test-script-context.js b/test/simple/test-script-context.js index a2622d03ea4..2af7bd0feaa 100644 --- a/test/simple/test-script-context.js +++ b/test/simple/test-script-context.js @@ -1,5 +1,5 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var Script = require('vm').Script; var script = new Script('"passed";'); diff --git a/test/simple/test-script-static-context.js b/test/simple/test-script-static-context.js index 388a995b6bc..87ff3e19b0c 100644 --- a/test/simple/test-script-static-context.js +++ b/test/simple/test-script-static-context.js @@ -1,5 +1,5 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var Script = require('vm').Script; diff --git a/test/simple/test-signal-unregister.js b/test/simple/test-signal-unregister.js index 6a3874649b2..20732ecba79 100644 --- a/test/simple/test-signal-unregister.js +++ b/test/simple/test-signal-unregister.js @@ -1,32 +1,32 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var childKilled = false, done = false, spawn = require('child_process').spawn, - util = require("util"), + util = require('util'), child; var join = require('path').join; child = spawn(process.argv[0], [join(common.fixturesDir, 'should_exit.js')]); -child.addListener('exit', function () { +child.addListener('exit', function() { if (!done) childKilled = true; }); -setTimeout(function () { - console.log("Sending SIGINT"); - child.kill("SIGINT"); - setTimeout(function () { - console.log("Chance has been given to die"); +setTimeout(function() { + console.log('Sending SIGINT'); + child.kill('SIGINT'); + setTimeout(function() { + console.log('Chance has been given to die'); done = true; if (!childKilled) { // Cleanup - console.log("Child did not die on SIGINT, sending SIGTERM"); - child.kill("SIGTERM"); + console.log('Child did not die on SIGINT, sending SIGTERM'); + child.kill('SIGTERM'); } }, 200); }, 200); -process.addListener("exit", function () { +process.addListener('exit', function() { assert.ok(childKilled); }); diff --git a/test/simple/test-string-decoder.js b/test/simple/test-string-decoder.js index cc59b070c30..6c3a3e30432 100644 --- a/test/simple/test-string-decoder.js +++ b/test/simple/test-string-decoder.js @@ -1,5 +1,5 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; Buffer = require('buffer').Buffer; StringDecoder = require('string_decoder').StringDecoder; @@ -34,8 +34,9 @@ assert.ok(s.length > 0); // U+12E4 -> E1 8B A4 // U+0030 -> 30 // U+3045 -> E3 81 85 -expected = "\u02e4\u0064\u12e4\u0030\u3045"; -buffer = new Buffer([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, 0xE3, 0x81, 0x85]); +expected = '\u02e4\u0064\u12e4\u0030\u3045'; +buffer = new Buffer([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, + 0x30, 0xE3, 0x81, 0x85]); charLengths = [0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5]; // Split the buffer into 3 segments @@ -57,8 +58,8 @@ for (var j = 2; j < buffer.length; j++) { sum += decoder.write(buffer.slice(i, j)); sum += decoder.write(buffer.slice(j, buffer.length)); assert.equal(expected, sum); - common.print("."); + common.print('.'); } } -console.log(" crayon!"); +console.log(' crayon!'); diff --git a/test/simple/test-sync-fileread.js b/test/simple/test-sync-fileread.js index 92deb388052..5b8602e4c3e 100644 --- a/test/simple/test-sync-fileread.js +++ b/test/simple/test-sync-fileread.js @@ -1,8 +1,8 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var path = require('path'); var fs = require('fs'); -var fixture = path.join(__dirname, "../fixtures/x.txt"); +var fixture = path.join(__dirname, '../fixtures/x.txt'); -assert.equal("xyz\n", fs.readFileSync(fixture)); +assert.equal('xyz\n', fs.readFileSync(fixture)); diff --git a/test/simple/test-sys.js b/test/simple/test-sys.js index 9fc6c205147..625c02b1bd9 100644 --- a/test/simple/test-sys.js +++ b/test/simple/test-sys.js @@ -1,19 +1,19 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; -assert.equal("0", common.inspect(0)); -assert.equal("1", common.inspect(1)); -assert.equal("false", common.inspect(false)); -assert.equal("''", common.inspect("")); -assert.equal("'hello'", common.inspect("hello")); -assert.equal("[Function]", common.inspect(function() {})); +assert.equal('0', common.inspect(0)); +assert.equal('1', common.inspect(1)); +assert.equal('false', common.inspect(false)); +assert.equal("''", common.inspect('')); +assert.equal("'hello'", common.inspect('hello')); +assert.equal('[Function]', common.inspect(function() {})); assert.equal('undefined', common.inspect(undefined)); assert.equal('null', common.inspect(null)); assert.equal('/foo(bar\\n)?/gi', common.inspect(/foo(bar\n)?/gi)); assert.equal('Sun, 14 Feb 2010 11:48:40 GMT', - common.inspect(new Date("Sun, 14 Feb 2010 11:48:40 GMT"))); + common.inspect(new Date('Sun, 14 Feb 2010 11:48:40 GMT'))); -assert.equal("'\\n\\u0001'", common.inspect("\n\u0001")); +assert.equal("'\\n\\u0001'", common.inspect('\n\u0001')); assert.equal('[]', common.inspect([])); assert.equal('[]', common.inspect(Object.create([]))); @@ -26,78 +26,74 @@ assert.equal('{ a: [Function] }', common.inspect({a: function() {}})); assert.equal('{ a: 1, b: 2 }', common.inspect({a: 1, b: 2})); assert.equal('{ a: {} }', common.inspect({'a': {}})); assert.equal('{ a: { b: 2 } }', common.inspect({'a': {'b': 2}})); -assert.equal('{ a: { b: { c: [Object] } } }', common.inspect({'a': {'b': { 'c': { 'd': 2 }}}})); -assert.equal('{ a: { b: { c: { d: 2 } } } }', common.inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null)); -assert.equal('[ 1, 2, 3, [length]: 3 ]', common.inspect([1,2,3], true)); -assert.equal('{ a: [Object] }', common.inspect({'a': {'b': { 'c': 2}}},false,0)); -assert.equal('{ a: { b: [Object] } }', common.inspect({'a': {'b': { 'c': 2}}},false,1)); -assert.equal("{ visible: 1 }", - common.inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}})) +assert.equal('{ a: { b: { c: [Object] } } }', + common.inspect({'a': {'b': { 'c': { 'd': 2 }}}})); +assert.equal('{ a: { b: { c: { d: 2 } } } }', + common.inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null)); +assert.equal('[ 1, 2, 3, [length]: 3 ]', common.inspect([1, 2, 3], true)); +assert.equal('{ a: [Object] }', + common.inspect({'a': {'b': { 'c': 2}}}, false, 0)); +assert.equal('{ a: { b: [Object] } }', + common.inspect({'a': {'b': { 'c': 2}}}, false, 1)); +assert.equal('{ visible: 1 }', + common.inspect(Object.create({}, + {visible: {value: 1, enumerable: true}, hidden: {value: 2}})) ); -assert.equal("{ [hidden]: 2, visible: 1 }", - common.inspect(Object.create({}, {visible:{value:1,enumerable:true},hidden:{value:2}}), true) +assert.equal('{ [hidden]: 2, visible: 1 }', + common.inspect(Object.create({}, + {visible: {value: 1, enumerable: true}, hidden: {value: 2}}), true) ); // Objects without prototype -assert.equal( - "{ [hidden]: 'secret', name: 'Tim' }", - common.inspect(Object.create(null, {name: {value: "Tim", enumerable: true}, hidden: {value: "secret"}}), true) +assert.equal('{ [hidden]: \'secret\', name: \'Tim\' }', + common.inspect(Object.create(null, + {name: {value: 'Tim', enumerable: true}, + hidden: {value: 'secret'}}), true) ); -assert.equal( - "{ name: 'Tim' }", - common.inspect(Object.create(null, {name: {value: "Tim", enumerable: true}, hidden: {value: "secret"}})) +assert.equal('{ name: \'Tim\' }', + common.inspect(Object.create(null, + {name: {value: 'Tim', enumerable: true}, + hidden: {value: 'secret'}})) ); // Dynamic properties -assert.equal( - "{ readonly: [Getter] }", - common.inspect({get readonly(){}}) -); -assert.equal( - "{ readwrite: [Getter/Setter] }", - common.inspect({get readwrite(){},set readwrite(val){}}) -); -assert.equal( - "{ writeonly: [Setter] }", - common.inspect({set writeonly(val){}}) -); +assert.equal('{ readonly: [Getter] }', + common.inspect({get readonly() {}})); + +assert.equal('{ readwrite: [Getter/Setter] }', + common.inspect({get readwrite() {},set readwrite(val) {}})); + +assert.equal('{ writeonly: [Setter] }', + common.inspect({set writeonly(val) {}})); var value = {}; value['a'] = value; assert.equal('{ a: [Circular] }', common.inspect(value)); value = Object.create([]); value.push(1); -assert.equal("[ 1, length: 1 ]", common.inspect(value)); +assert.equal('[ 1, length: 1 ]', common.inspect(value)); // Array with dynamic properties -value = [1,2,3]; -value.__defineGetter__('growingLength', function () { this.push(true); return this.length; }); -assert.equal( - "[ 1, 2, 3, growingLength: [Getter] ]", - common.inspect(value) -); +value = [1, 2, 3]; +value.__defineGetter__('growingLength', function() { + this.push(true); return this.length; +}); +assert.equal('[ 1, 2, 3, growingLength: [Getter] ]', common.inspect(value)); // Function with properties -value = function () {}; +value = function() {}; value.aprop = 42; -assert.equal( - "{ [Function] aprop: 42 }", - common.inspect(value) -); +assert.equal('{ [Function] aprop: 42 }', common.inspect(value)); // Regular expressions with properties value = /123/ig; value.aprop = 42; -assert.equal( - "{ /123/gi aprop: 42 }", - common.inspect(value) -); +assert.equal('{ /123/gi aprop: 42 }', common.inspect(value)); // Dates with properties -value = new Date("Sun, 14 Feb 2010 11:48:40 GMT"); +value = new Date('Sun, 14 Feb 2010 11:48:40 GMT'); value.aprop = 42; -assert.equal( - "{ Sun, 14 Feb 2010 11:48:40 GMT aprop: 42 }", - common.inspect(value) +assert.equal('{ Sun, 14 Feb 2010 11:48:40 GMT aprop: 42 }', + common.inspect(value) ); diff --git a/test/simple/test-umask.js b/test/simple/test-umask.js index 45cb9244881..850bfb50363 100644 --- a/test/simple/test-umask.js +++ b/test/simple/test-umask.js @@ -1,5 +1,5 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; var mask = 0664; var old = process.umask(mask); diff --git a/test/simple/test-url.js b/test/simple/test-url.js index 0ecc0353042..1bd94bcb51a 100644 --- a/test/simple/test-url.js +++ b/test/simple/test-url.js @@ -1,8 +1,8 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; -var url = require("url"), - util = require("util"); +var url = require('url'), + util = require('util'); // URLs to parse, and expected data // { url : parsed } diff --git a/test/simple/test-utf8-scripts.js b/test/simple/test-utf8-scripts.js index 83b389c72a2..2fea454b5ac 100644 --- a/test/simple/test-utf8-scripts.js +++ b/test/simple/test-utf8-scripts.js @@ -1,9 +1,9 @@ -common = require("../common"); -assert = common.assert +common = require('../common'); +assert = common.assert; // üäö -console.log("Σὲ γνωρίζω ἀπὸ τὴν κόψη"); +console.log('Σὲ γνωρίζω ἀπὸ τὴν κόψη'); -assert.equal(true, /Hellö Wörld/.test("Hellö Wörld") ); +assert.equal(true, /Hellö Wörld/.test('Hellö Wörld')); diff --git a/test/simple/test-zerolengthbufferbug.js b/test/simple/test-zerolengthbufferbug.js index f5cc85c7083..52f2dd015cd 100644 --- a/test/simple/test-zerolengthbufferbug.js +++ b/test/simple/test-zerolengthbufferbug.js @@ -1,39 +1,40 @@ // Serving up a zero-length buffer should work. -var common = require("../common"); +var common = require('../common'); var assert = common.assert; var http = require('http'); -var server = http.createServer(function (req, res) { +var server = http.createServer(function(req, res) { var buffer = new Buffer(0); + // FIXME: WTF gjslint want this? res.writeHead(200, {'Content-Type': 'text/html', - 'Content-Length': buffer.length}); + 'Content-Length': buffer.length}); res.end(buffer); }); var gotResponse = false; var resBodySize = 0; -server.listen(common.PORT, function () { +server.listen(common.PORT, function() { var client = http.createClient(common.PORT); - + var req = client.request('GET', '/'); req.end(); - req.on('response', function (res) { + req.on('response', function(res) { gotResponse = true; - res.on('data', function (d) { + res.on('data', function(d) { resBodySize += d.length; }); - res.on('end', function (d) { + res.on('end', function(d) { server.close(); }); }); }); -process.on('exit', function () { +process.on('exit', function() { assert.ok(gotResponse); assert.equal(0, resBodySize); });