lib/punycode.js
+test/fixtures
+test/**/node_modules
+test/parallel/test-fs-non-number-arguments-throw.js
octalLiterals: true
binaryLiterals: true
generators: true
+ forOf: true
rules:
# Possible Errors
space-infix-ops: 2
## require spaces return, throw, case
space-return-throw-case: 2
+ ## no space before function, eg. 'function()'
+ space-before-function-paren: [2, "never"]
+ ## require space before blocks, eg 'function() {'
+ space-before-blocks: [2, "always"]
## require parens for Constructor
new-parens: 2
## max 80 length
./$(NODE_EXE) benchmark/idle_clients.js &
jslint:
- ./$(NODE_EXE) tools/eslint/bin/eslint.js src lib --reset --quiet
+ ./$(NODE_EXE) tools/eslint/bin/eslint.js src lib test --reset --quiet
CPPLINT_EXCLUDE ?=
CPPLINT_EXCLUDE += src/node_lttng.cc
--- /dev/null
+## Test-specific linter rules
+
+rules:
+ ## allow unreachable code
+ no-unreachable: 0
+'use strict';
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;
});
});
+'use strict';
var binding = require('./build/Release/binding');
+'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
assert.equal('world', binding());
+'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
assert.equal('world', binding.hello());
+'use strict';
var assert = require('assert');
var repl = require('repl');
var stream = require('stream');
+'use strict';
var assert = require('assert');
var binding = require('./build/Release/binding');
var obj = binding.alloc(16);
+'use strict';
var path = require('path');
var fs = require('fs');
var assert = require('assert');
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();
var context = {
expected: expected,
actual: 0,
- stack: (new Error).stack,
+ stack: (new Error()).stack,
name: fn.name || '<anonymous>'
};
*/
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');
}
/*
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'});
}
return serviceName;
-}
+};
exports.hasMultiLocalhost = function hasMultiLocalhost() {
var TCP = process.binding('tcp_wrap').TCP;
'(\\.([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.fileExists = function(pathname) {
try {
+'use strict';
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var common = require('../common');
var assert = require('assert');
quitCalled = true;
child.stdin.write('quit');
child.kill('SIGTERM');
- }
+ };
setTimeout(function() {
console.error('dying badly buffer=%j', buffer);
+'use strict';
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
child.on('close', function() {
assert(asserted, 'debugger did not pause on exception');
if (next) next();
- })
+ });
var exceptions = [];
+'use strict';
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var common = require('../common');
var assert = require('assert');
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
- '"sourceStart":"(function (module, exports, require) {' +
+ '"sourceStart":"(function(module, exports, require) {' +
'var dns = process.binding(\'cares\')' +
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
var connectCount = 0;
-var script = 'setTimeout(function () { console.log("blah"); });' +
- 'setInterval(function () {}, 1000000);';
+var script = 'setTimeout(function() { console.log("blah"); });' +
+ 'setInterval(function() {}, 1000000);';
var nodeProcess;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var repl = require('./helper-debugger-repl.js');
repl.startDebugger('break-in-module/main.js');
+'use strict';
var repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
// 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
+'use strict';
process.env.NODE_FORCE_READLINE = 1;
var repl = require('./helper-debugger-repl.js');
+'use strict';
var common = require('../common');
var script = common.fixturesDir + '/breakpoints_utf8.js';
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
+'use strict';
var repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
+'use strict';
var common = require('../common');
var assert = require('assert');
var https = require('https');
+'use strict';
var common = require('../common.js');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var bigish = Array(200);
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Some operating systems report errors when an UDP message is sent to an
// unreachable host. This error can be reported by sendto() and even by
// recvfrom(). Node should not propagate this error to the user.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
// Generate a lot of thread pool events
var pos = 0;
-fs.open(filename, 'r', 0666, function(err, fd) {
+fs.open(filename, 'r', 0o666, function(err, fd) {
if (err) throw err;
function readChunk() {
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
/* XXX Can this test be modified to not call the now-removed wait()? */
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path'),
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util'),
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Failing test for https
// Will fail with "socket hang up" for 4 out of 10 requests
var common = require('../common');
var https = require('https');
-for (var i = 0; i < 10; ++i)
-{
- https.get(
- {
- host: 'www.google.com',
- path: '/accounts/o8/id',
- port: 443
- }, function(res)
- {
- var data = '';
- res.on('data', function(chunk)
- {
- data += chunk;
- });
- res.on('end', function()
- {
- console.log(res.statusCode);
- });
- }).on('error', function(error)
- {
- console.log(error);
- });
+for (var i = 0; i < 10; ++i) {
+ https.get({
+ host: 'www.google.com',
+ path: '/accounts/o8/id',
+ port: 443
+ }, function(res) {
+ var data = '';
+ res.on('data', function(chunk) {
+ data += chunk;
+ });
+ res.on('end', function() {
+ console.log(res.statusCode);
+ });
+ }).on('error', function(error) {
+ console.log(error);
+ });
}
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
// Yet another use-case for require('tty').spawn ?
var common = require('../common');
}
});
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);
- }
+ };
rl.written_bytes = written_bytes;
return rl;
};
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);
{cursor: 7, key: key.xterm.metab},
{cursor: 4, key: key.xterm.metab},
{cursor: 0, key: key.xterm.metab},
-].forEach(function (action) {
+].forEach(function(action) {
written_bytes_length = rl.written_bytes.length;
rl.write.apply(rl, action.key);
assert.equal(action.cursor, rl.cursor);
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Test sending and receiving a file descriptor.
//
// This test is pretty complex. It ends up spawning test/fixtures/recvfd.js
+'use strict';
// Requires special privileges
var common = require('../common');
var assert = require('assert');
+/* eslint-disable no-debugger */
+'use strict';
// Server sends a large string. Client counts bytes and pauses every few
// seconds. Makes sure that pause and resume work properly.
var common = require('../common');
/*
client.pause();
- process.nextTick(function () {
+ process.nextTick(function() {
client.resume();
});
*/
+'use strict';
// Example of new TLS API. Test with:
//
// $> openssl s_client -connect localhost:12346 \
+'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var tls = require('tls');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
-setInterval(function () {}, 500);
+setInterval(function() {}, 500);
+'use strict';
var bindings
try {
bindings = require('../build/Release/weakref.node')
// backwards-compat with node-weakref
bindings.weaken = bindings.create
-Object.keys(bindings).forEach(function (name) {
+Object.keys(bindings).forEach(function(name) {
module.exports[name] = bindings[name]
})
+'use strict';
// just like test/gc/http-client.js,
// but aborting every connection that comes in.
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);
if (count >= todo)
return;
- (function(){
+ (function() {
function cb(res) {
- done+=1;
+ done += 1;
statusLater();
}
count++;
weak(req, afterGC);
- })()
+ })();
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
getall();
-function afterGC(){
+function afterGC() {
countGC ++;
}
+'use strict';
// just like test/gc/http-client.js,
// but with an on('error') handler that does nothing.
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);
if (count >= todo)
return;
- (function(){
+ (function() {
function cb(res) {
res.resume();
- done+=1;
+ done += 1;
statusLater();
}
function onerror(er) {
count++;
weak(req, afterGC);
- })()
+ })();
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
getall();
-function afterGC(){
+function afterGC() {
countGC ++;
}
+'use strict';
// just like test/gc/http-client.js,
// 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);
}
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);
if (count >= todo)
return;
- (function(){
+ (function() {
function cb(res) {
res.resume();
- done+=1;
+ done += 1;
statusLater();
}
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++)
getall();
-function afterGC(){
+function afterGC() {
countGC ++;
}
+'use strict';
// just a simple http server and client.
function serverHandler(req, res) {
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);
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);
}
hostname: 'localhost',
pathname: '/',
port: PORT
- }, cb)
+ }, cb);
count++;
weak(req, afterGC);
- })()
+ })();
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
getall();
-function afterGC(){
+function afterGC() {
countGC ++;
}
+'use strict';
// just like test/gc/http-client-timeout.js,
// but using a net server/client instead
sock.on('error', function(err) {
assert.strictEqual(err.code, 'ECONNRESET');
});
- timer = setTimeout(function () {
+ timer = setTimeout(function() {
sock.end('hello\n');
}, 100);
}
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);
if (count >= todo)
return;
- (function(){
+ (function() {
var req = net.connect(PORT, '127.0.0.1');
req.resume();
req.setTimeout(10, function() {
for (var i = 0; i < 10; i++)
getall();
-function afterGC(){
+function afterGC() {
countGC ++;
}
+'use strict';
var common = require('../common'),
assert = require('assert'),
dgram = require('dgram'),
// 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);
});
sendSocket.send(buf, 0, buf.length,
common.PORT, LOCAL_BROADCAST_HOST, function(err) {
-
if (err) throw err;
-
console.error('[PARENT] sent %s to %s:%s',
util.inspect(buf.toString()),
LOCAL_BROADCAST_HOST, common.PORT);
+'use strict';
var common = require('../common'),
assert = require('assert'),
dgram = require('dgram'),
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);
listenSocket.bind(common.PORT);
- listenSocket.on('listening', function () {
+ listenSocket.on('listening', function() {
listenSocket.addMembership(LOCAL_BROADCAST_HOST);
});
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var dns = require('dns');
+'use strict';
var common = require('../common');
var assert = require('assert'),
dns = require('dns'),
TEST(function test_lookup_all_ipv4(done) {
- var req = dns.lookup('www.google.com', {all: true, family: 4}, function(err, ips) {
+ var req = dns.lookup('www.google.com', {all: true, family: 4},
+ function(err, ips) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
TEST(function test_lookup_all_ipv6(done) {
- var req = dns.lookup('www.google.com', {all: true, family: 6}, function(err, ips) {
+ var req = dns.lookup('www.google.com', {all: true, family: 6},
+ function(err, ips) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
+'use strict';
/*
* Repeated requests for a domain that fails to resolve
* should trigger the error event after each attempt.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// This example attempts to time out before the connection is established
// https://groups.google.com/forum/#!topic/nodejs/UE0ZbfLt6t8
// https://groups.google.com/forum/#!topic/nodejs-dev/jR7-5UDqXkw
+'use strict';
var common = require('../common');
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();
+'use strict';
// Test for authorized access to the server which has a cross root
// certification between Starfield Class 2 and ValiCert Class 2
var tls = require('tls');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
process.maxTickDepth = 10;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
before
-*test*message*throw_custom_error.js:7
+*test*message*throw_custom_error.js:8
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
^
MyCustomError: This is a custom message
+/* eslint-disable indent */
+'use strict';
var common = require('../common');
var assert = require('assert');
console.error('before');
-(function () {
+(function() {
// these lines should contain tab!
throw ({ foo: 'bar' });
})();
before
-*test*message*throw_in_line_with_tabs.js:8
+*test*message*throw_in_line_with_tabs.js:10
throw ({ foo: 'bar' });
^
[object Object]
+'use strict';
var common = require('../common');
var assert = require('assert');
before
-*test*message*throw_non_error.js:7
+*test*message*throw_non_error.js:8
throw ({ foo: 'bar' });
^
[object Object]
+'use strict';
var common = require('../common');
var assert = require('assert');
-*test*message*throw_null.js:4
+*test*message*throw_null.js:5
throw null;
-^
+^
null
+'use strict';
var common = require('../common');
var assert = require('assert');
-*test*message*throw_undefined.js:4
+*test*message*throw_undefined.js:5
throw undefined;
^
undefined
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
+'use strict';
// See https://github.com/nodejs/io.js/issues/1376
// and https://code.google.com/p/v8/issues/detail?id=4019
+'use strict';
var common = require('../common');
var assert = require('assert');
var a = require('assert');
}
// primitive wrappers and object
-assert.doesNotThrow(makeBlock(a.deepEqual, new String('a'), ['a']), a.AssertionError);
-assert.doesNotThrow(makeBlock(a.deepEqual, new String('a'), {0: 'a'}), a.AssertionError);
-assert.doesNotThrow(makeBlock(a.deepEqual, new Number(1), {}), a.AssertionError);
-assert.doesNotThrow(makeBlock(a.deepEqual, new Boolean(true), {}), a.AssertionError);
+assert.doesNotThrow(makeBlock(a.deepEqual, new String('a'), ['a']),
+ a.AssertionError);
+assert.doesNotThrow(makeBlock(a.deepEqual, new String('a'), {0: 'a'}),
+ a.AssertionError);
+assert.doesNotThrow(makeBlock(a.deepEqual, new Number(1), {}),
+ a.AssertionError);
+assert.doesNotThrow(makeBlock(a.deepEqual, new Boolean(true), {}),
+ a.AssertionError);
//deepStrictEqual
assert.doesNotThrow(makeBlock(a.deepStrictEqual, new Date(2000, 3, 14),
assert.equal(true, threw,
'a.doesNotThrow is not catching type matching errors');
-assert.throws(function() {assert.ifError(new Error('test error'))});
-assert.doesNotThrow(function() {assert.ifError(null)});
-assert.doesNotThrow(function() {assert.ifError()});
+assert.throws(function() {assert.ifError(new Error('test error'));});
+assert.doesNotThrow(function() {assert.ifError(null);});
+assert.doesNotThrow(function() {assert.ifError();});
// make sure that validating using constructor really works
threw = false;
} 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(/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 }');
// #2893
try {
- assert.throws(function () {
+ assert.throws(function() {
assert.ifError(null);
});
} catch (e) {
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');
}
+'use strict';
var assert = require('assert'),
exception = null;
+'use strict';
var assert = require('assert');
process.on('beforeExit', function() {
+'use strict';
var assert = require('assert');
var net = require('net');
var util = require('util');
function tryTimer() {
console.log('set a timeout');
- setTimeout(function () {
+ setTimeout(function() {
console.log('timeout cb, do another once beforeExit');
revivals++;
process.once('beforeExit', tryListen);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
+'use strict';
var common = require('../common');
var assert = require('assert');
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
// GH-5110
-(function () {
+(function() {
var buffer = new Buffer('test'),
string = JSON.stringify(buffer);
// 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');
})();
(function() {
var a = [0];
for (var i = 0; i < 7; ++i) a = a.concat(a);
- a = a.map(function(_, i) { return i });
+ a = a.map(function(_, i) { return i; });
var b = Buffer(a);
var c = Buffer(b);
assert.equal(b.length, a.length);
})();
-assert.throws(function () {
+assert.throws(function() {
new Buffer(smalloc.kMaxLength + 1);
}, RangeError);
-assert.throws(function () {
+assert.throws(function() {
new SlowBuffer(smalloc.kMaxLength + 1);
}, RangeError);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
childExited = true;
});
- child.on('close', function () {
+ child.on('close', function() {
callback(output);
pwd_called = true;
childClosed = true;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
assert.strictEqual(forCode, code);
});
- child.on('close', function () {
+ child.on('close', function() {
forData && assert.strictEqual(forData, data.replace(/[\s\r\n]+$/, ''));
returns--;
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
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 ]);
-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);
});
});
+'use strict';
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
+'use strict';
var is_windows = process.platform === 'win32';
var common = require('../common');
});
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);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
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);
});
// 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');
+'use strict';
require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
+'use strict';
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
+'use strict';
var common = require('../common');
var assert = require('assert');
var child_process = require('child_process');
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var assert = require('assert'),
common = require('../common'),
fork = require('child_process').fork,
+'use strict';
/*
* The purpose of this test is to make sure that when forking a process,
* sending a fd representing a UDP socket to the child and sending messages
if (msg === 'server') {
server = clusterServer;
- server.on('message', function () {
+ server.on('message', function() {
process.send('gotMessage');
});
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;
}
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;
}
}, 1);
};
- var shutdown = function () {
+ var shutdown = function() {
child.send('stop');
server.close();
server.bind(common.PORT, '127.0.0.1');
- process.once('exit', function () {
+ process.once('exit', function() {
assert(parentGotMessage);
assert(childGotMessage);
});
+'use strict';
var assert = require('assert');
var child_process = require('child_process');
var spawn = child_process.spawn;
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);
});
}
+'use strict';
var assert = require('assert');
var cp = require('child_process');
var fs = require('fs');
+'use strict';
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
+'use strict';
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
+'use strict';
var common = require('../common');
var assert = require('assert');
var fork = require('child_process').fork;
process.send('2');
}, 200);
- process.on('disconnect', function () {
+ process.on('disconnect', function() {
process.stdout.write('3');
});
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var fork = require('child_process').fork;
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');
});
}
+'use strict';
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
+'use strict';
var common = require('../common');
var child_process = require('child_process');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Test that a Linux specific quirk in the handle passing protocol is handled
// correctly. See https://github.com/joyent/node/issues/5330 for details.
+'use strict';
var common = require('../common');
var assert = require('assert');
var fork = require('child_process').fork;
+'use strict';
var common = require('../common');
var assert = require('assert');
var ch = require('child_process');
+'use strict';
var common = require('../common');
var assert = require('assert');
var childProcess = require('child_process');
+'use strict';
var common = require('../common');
var fs = require('fs');
var spawn = require('child_process').spawn;
assert.equal(common.fileExists(enoentPath), false);
var enoentChild = spawn(enoentPath, spawnargs);
-enoentChild.on('error', function (err) {
+enoentChild.on('error', function(err) {
assert.equal(err.code, 'ENOENT');
assert.equal(err.errno, 'ENOENT');
assert.equal(err.syscall, 'spawn ' + enoentPath);
+'use strict';
var assert = require('assert');
var child_process = require('child_process');
var spawn = child_process.spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var cp = require('child_process');
+'use strict';
var common = require('../common');
var assert = require('assert');
var os = require('os');
+'use strict';
var common = require('../common');
var assert = require('assert');
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;
+'use strict';
var common = require('../common');
var assert = require('assert');
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', ['bar']).error;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
exitStatus = status;
});
-cat.on('close', function () {
+cat.on('close', function() {
closed = true;
if (is_windows) {
assert.equal('hello world\r\n', response);
+'use strict';
var common = require('../common');
var assert = require('assert');
var BUFSIZE = 1024;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
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') {
}
});
- child.on('close', function (data) {
+ child.on('close', function(data) {
assert(gotHello);
assert(gotBye);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
if (module.parent) {
// signal we've been loaded as a module
console.log('Loaded as a module, exiting with status code 42.');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
// This test starts two clustered HTTP servers on the same port. It expects the
// first cluster to succeed and the second cluster to fail with EADDRINUSE.
//
+'use strict';
var NUM_WORKERS = 4;
var PACKETS_PER_WORKER = 10;
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);
}
+'use strict';
var NUM_WORKERS = 4;
var PACKETS_PER_WORKER = 10;
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);
}
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);
}
+'use strict';
var cluster = require('cluster');
if (cluster.isMaster) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
process.env.NODE_CLUSTER_SCHED_POLICY = 'none';
var cluster = require('cluster');
}
} else {
if (process.env.BOUND === 'y') {
- var source = net.createServer()
+ var source = net.createServer();
source.listen(0);
}
+'use strict';
if (process.platform === 'win32') {
console.log('skipping test on windows, where clustered dgram is ENOTSUP');
process.exit(0);
+'use strict';
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
-// test that errors propagated from cluster children are properly received in their master
-// creates an EADDRINUSE condition by also forking a child process to listen on a socket
+'use strict';
+// test that errors propagated from cluster children are properly
+// received in their master creates an EADDRINUSE condition by also
+// forking a child process to listen on a socket
var common = require('../common');
var assert = require('assert');
assert.equal(gotError, 1);
});
} else {
- var cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js', { stdio: 'inherit' });
+ var cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js',
+ { stdio: 'inherit' });
// message from the child indicates it's ready and listening
cp.on('message', function() {
+'use strict';
// Check that having a worker bind to a port that's already taken doesn't
// leave the master process in a confused state. Releasing the port and
// trying again should Just Work[TM].
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
// It is not possible to send pipe handles over the IPC pipe on Windows.
if (process.platform === 'win32') {
process.exit(0);
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fork = require('child_process').fork;
+'use strict';
var common = require('../common');
var cluster = require('cluster');
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');
+'use strict';
// Testing mutual send of handles: from master to worker, and from worker to
// master.
+'use strict';
// Testing to send an handle twice to the parent process.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
// Installing a custom uncaughtException handler should override the default
// one that the cluster module installs.
// https://github.com/joyent/node/issues/2556
+'use strict';
// test-cluster-worker-constructor.js
// validates correct behavior of the cluster.Worker constructor
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
/*
* The goal of this test is to cover the Workers' implementation of
* Worker.prototype.destroy. Worker.prototype.destroy is called within
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
// events
assert.ok(w.emitDisconnect, 'Disconnect event did not emit');
- assert.ok(w.emitDisconnectInsideWorker, 'Disconnect event did not emit inside worker');
+ assert.ok(w.emitDisconnectInsideWorker,
+ 'Disconnect event did not emit inside worker');
assert.ok(c.emitDisconnect, 'Disconnect event did not emit');
assert.ok(w.emitExit, 'Exit event did not emit');
assert.ok(c.emitExit, 'Exit event did not emit');
+'use strict';
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
// test-cluster-worker-exit.js
// verifies that, when a child process exits (by calling `process.exit(code)`)
// - the parent receives the proper events in the proper order, no duplicates
// 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;
}
+}
+'use strict';
var assert = require('assert');
-var cluster = require('cluster')
+var cluster = require('cluster');
var net = require('net');
var SENTINEL = 42;
+'use strict';
// test-cluster-worker-init.js
// verifies that, when a child process is forked, the cluster.worker
// object can receive messages as expected
+'use strict';
var cluster = require('cluster');
var assert = require('assert');
var util = require('util');
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');
}
+'use strict';
var cluster = require('cluster');
var assert = require('assert');
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');
}
+'use strict';
// test-cluster-worker-kill.js
// verifies that, when a child process is killed (we use SIGKILL)
// - the parent receives the proper events in the proper order, no duplicates
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'],
+ 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']
+ worker_signalCode: [KILL_SIGNAL,
+ 'the worker exited w/ incorrect signalCode']
},
results = {
cluster_emitDisconnect: 0,
// 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;
}
+}
+'use strict';
var assert = require('assert');
-var cluster = require('cluster')
+var cluster = require('cluster');
var net = require('net');
var common = require('../common');
if (cluster.isMaster) {
server = net.createServer(function(conn) {
server.close();
- worker.disconnect()
+ worker.disconnect();
worker.once('disconnect', function() {
setTimeout(function() {
conn.destroy();
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var Stream = require('stream');
// 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/);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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 = [];
+'use strict';
var common = require('../common');
var assert = require('assert');
//
var TEST_CASES = [
- { algo: 'aes-128-gcm', key: '6970787039613669314d623455536234',
+ { algo: 'aes-128-gcm',
+ key: '6970787039613669314d623455536234',
iv: '583673497131313748307652', plain: 'Hello World!',
ct: '4BE13896F64DFA2C2D0F2C76',
tag: '272B422F62EB545EAA15B5FF84092447', tampered: false },
- { algo: 'aes-128-gcm', key: '6970787039613669314d623455536234',
+ { algo: 'aes-128-gcm',
+ key: '6970787039613669314d623455536234',
iv: '583673497131313748307652', plain: 'Hello World!',
ct: '4BE13896F64DFA2C2D0F2C76', aad: '000000FF',
tag: 'BA2479F66275665A88CB7B15F43EB005', tampered: false },
- { algo: 'aes-128-gcm', key: '6970787039613669314d623455536234',
+ { algo: 'aes-128-gcm',
+ key: '6970787039613669314d623455536234',
iv: '583673497131313748307652', plain: 'Hello World!',
ct: '4BE13596F64DFA2C2D0FAC76',
tag: '272B422F62EB545EAA15B5FF84092447', tampered: true },
- { algo: 'aes-256-gcm', key: '337a54767a7233703637564336316a6d56353472495975313534357834546c59',
+ { algo: 'aes-256-gcm',
+ key: '337a54767a7233703637564336316a6d56353472495975313534357834546c59',
iv: '36306950306836764a6f4561', plain: 'Hello node.js world!',
ct: '58E62CFE7B1D274111A82267EBB93866E72B6C2A',
tag: '9BB44F663BADABACAE9720881FB1EC7A', tampered: false },
- { algo: 'aes-256-gcm', key: '337a54767a7233703637564336316a6d56353472495975313534357834546c59',
+ { algo: 'aes-256-gcm',
+ key: '337a54767a7233703637564336316a6d56353472495975313534357834546c59',
iv: '36306950306836764a6f4561', plain: 'Hello node.js world!',
ct: '58E62CFF7B1D274011A82267EBB93866E72B6C2B',
tag: '9BB44F663BADABACAE9720881FB1EC7A', tampered: true },
- { algo: 'aes-192-gcm', key: '1ed2233fa2223ef5d7df08546049406c7305220bca40d4c9',
+ { algo: 'aes-192-gcm',
+ key: '1ed2233fa2223ef5d7df08546049406c7305220bca40d4c9',
iv: '0e1791e9db3bd21a9122c416', plain: 'Hello node.js world!',
password: 'very bad password', aad: '63616c76696e',
ct: 'DDA53A4059AA17B88756984995F7BBA3C636CC44',
+'use strict';
// This is the same as test/simple/test-crypto, but from before the shift
// to use buffers by default.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
// not assert. See #4886.
(function() {
var c = crypto.createCipher('aes-256-cbc', 'secret');
- try { c.final('xxx') } catch (e) { /* Ignore. */ }
- try { c.final('xxx') } catch (e) { /* Ignore. */ }
- try { c.final('xxx') } catch (e) { /* Ignore. */ }
+ try { c.final('xxx'); } catch (e) { /* Ignore. */ }
+ try { c.final('xxx'); } catch (e) { /* Ignore. */ }
+ try { c.final('xxx'); } catch (e) { /* Ignore. */ }
var d = crypto.createDecipher('aes-256-cbc', 'secret');
- try { d.final('xxx') } catch (e) { /* Ignore. */ }
- try { d.final('xxx') } catch (e) { /* Ignore. */ }
- try { d.final('xxx') } catch (e) { /* Ignore. */ }
+ try { d.final('xxx'); } catch (e) { /* Ignore. */ }
+ try { d.final('xxx'); } catch (e) { /* Ignore. */ }
+ try { d.final('xxx'); } catch (e) { /* Ignore. */ }
})();
// Regression test for #5482: string to Cipher#update() should not assert.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var constants = require('constants');
// Run this one twice to make sure that the dh3 clears its error properly
(function() {
var c = crypto.createDecipher('aes-128-ecb', '');
- assert.throws(function() { c.final('utf8') }, /wrong final block length/);
+ assert.throws(function() { c.final('utf8'); }, /wrong final block length/);
})();
assert.throws(function() {
(function() {
var c = crypto.createDecipher('aes-128-ecb', '');
- assert.throws(function() { c.final('utf8') }, /wrong final block length/);
+ assert.throws(function() { c.final('utf8'); }, /wrong final block length/);
})();
// Create a shared using a DH group.
+'use strict';
var common = require('../common');
var assert = require('assert');
var domain = require('domain');
+'use strict';
var common = require('../common');
var domain = require('domain');
var assert = require('assert');
var d = domain.create();
-var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes']
+var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'];
var errors = 0;
if (!common.hasCrypto) {
assert.equal(errors, 3);
});
-d.on('error', function (e) {
+d.on('error', function(e) {
assert.equal(e.message, expect.shift());
errors += 1;
});
-d.run(function () {
+d.run(function() {
one();
function one() {
- crypto.pbkdf2('a', 'b', 1, 8, function () {
+ crypto.pbkdf2('a', 'b', 1, 8, function() {
two();
throw new Error('pbkdf2');
});
}
function two() {
- crypto.randomBytes(4, function () {
+ crypto.randomBytes(4, function() {
three();
throw new Error('randomBytes');
});
}
function three() {
- crypto.pseudoRandomBytes(4, function () {
+ crypto.pseudoRandomBytes(4, function() {
throw new Error('pseudoRandomBytes');
});
}
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// This is the same as test/simple/test-crypto, but from before the shift
// to use buffers by default.
+'use strict';
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';
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
'4292c5ad'
}
},
-]
+];
for (var i = 0, l = wikipedia.length; i < l; i++) {
for (var hash in wikipedia[i]['hmac']) {
+'use strict';
var common = require('../common');
var assert = require('assert');
'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 \
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
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({});
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
+ });
});
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
}, /Bad input string/);
assert.throws(function() {
- var private = [
+ var priv = [
'-----BEGIN RSA PRIVATE KEY-----',
'MIGrAgEAAiEA+3z+1QNF2/unumadiwEr+C5vfhezsb3hp4jAnCNRpPcCAwEAAQIgQNriSQK4',
'EFwczDhMZp2dvbcz7OUUyt36z3S4usFPHSECEQD/41K7SujrstBfoCPzwC1xAhEA+5kt4BJy',
'-----END RSA PRIVATE KEY-----',
''
].join('\n');
- crypto.createSign('RSA-SHA256').update('test').sign(private);
+ crypto.createSign('RSA-SHA256').update('test').sign(priv);
}, /RSA_sign:digest too big for rsa key/);
// Make sure memory isn't released before being returned
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
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();
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,
// 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]);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
-socket.on('listening', function () {
+socket.on('listening', function() {
socket.close();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
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) {
+client.send(message, 0, message.length, 41234, 'localhost',
+ function(err, bytes) {
assert.strictEqual(bytes, message.length);
client.close();
});
+'use strict';
var assert = require('assert');
var common = require('../common');
var dgram = require('dgram');
+'use strict';
// Ensure that if a dgram socket is closed before the DNS lookup completes, it
// won't crash.
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
+'use strict';
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
+'use strict';
var common = require('../common'),
assert = require('assert'),
dgram = require('dgram'),
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)
+'use strict';
// Some operating systems report errors when an UDP message is sent to an
// unreachable host. This error can be reported by sendto() and even by
// recvfrom(). Node should not propagate this error to the user.
+'use strict';
var common = require('../common');
var assert = require('assert');
var Buffer = require('buffer').Buffer;
+'use strict';
var common = require('../common');
var dgram = require('dgram');
+'use strict';
// Remove this test once we support sending strings.
var common = require('../common');
// Should throw but not crash.
var socket = dgram.createSocket('udp4');
-assert.throws(function() { socket.send(true, 0, 1, 1, 'host') }, TypeError);
-assert.throws(function() { socket.sendto(5, 0, 1, 1, 'host') }, TypeError);
+assert.throws(function() { socket.send(true, 0, 1, 1, 'host'); }, TypeError);
+assert.throws(function() { socket.sendto(5, 0, 1, 1, 'host'); }, TypeError);
socket.close();
+'use strict';
var common = require('../common');
var assert = require('assert');
var dgram = require('dgram');
+'use strict';
var common = require('../common');
var assert = require('assert');
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() {
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var dns = require('dns');
'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');
});
});
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var cares = process.binding('cares_wrap');
+'use strict';
var common = require('../common');
var dns = require('dns');
+'use strict';
var common = require('../common');
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
+'use strict';
var common = require('../common');
var assert = require('assert');
'8.8.8.8',
'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',
];
-assert.doesNotThrow(function () { dns.setServers(goog6) });
+assert.doesNotThrow(function() { dns.setServers(goog6); });
assert.deepEqual(dns.getServers(), goog6);
goog6.push('4.4.4.4');
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() {
+'use strict';
// Flags: --abort_on_uncaught_exception
var common = require('../common');
assert.equal(errors, tests.length);
});
-tests.forEach(function(test) { test(); })
+tests.forEach(function(test) { test(); });
function nextTick() {
var d = domain.create();
conn.pipe(conn);
});
server.listen(common.PORT, '0.0.0.0', function() {
- var conn = net.connect(common.PORT, '0.0.0.0')
+ var conn = net.connect(common.PORT, '0.0.0.0');
conn.once('data', function() {
throw new Error('ok');
- })
+ });
conn.end('ok');
server.close();
});
+/* eslint-disable strict */
try {
var crypto = require('crypto');
} catch (e) {
+'use strict';
// Make sure the domain stack is a stack
var assert = require('assert');
function names(array) {
return array.map(function(d) {
- return d.name
+ return d.name;
}).join(', ');
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var domain = require('domain');
// 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);
setTimeout(secondTimer, 50);
-function err(){
+function err() {
var d = domain.create();
d.on('error', handle);
d.run(err2);
+'use strict';
var common = require('../common');
var assert = require('assert');
var domain = require('domain');
// 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);
+'use strict';
// Simple tests of most basic domain functionality.
var common = require('../common');
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);
});
});
+'use strict';
var domain = require('domain');
var http = require('http');
var assert = require('assert');
+'use strict';
// Simple tests of most basic domain functionality.
var common = require('../common');
+'use strict';
// Tests of multiple domains happening at once.
var common = require('../common');
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);
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');
}).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);
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
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);
throw2();
});
- domain1.run(function () {
+ domain1.run(function() {
throw1();
});
}
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);
gotDomain2Error = true;
});
- domain2.run(function () {
+ domain2.run(function() {
inner(throw1, throw2);
});
}
+'use strict';
// Make sure that the nested domains don't cause the domain stack to grow
var assert = require('assert');
domain.create().run(function() {
domain.create().run(function() {
domain.create().run(function() {
- domain.create().on("error", function(e) {
+ domain.create().on('error', function(e) {
// Don't need to do anything here
}).run(function() {
- throw new Error("died")
- })
- })
- })
-})
+ throw new Error('died');
+ });
+ });
+ });
+});
+'use strict';
// Make sure the domain stack doesn't get clobbered by un-matched .exit()
var assert = require('assert');
+'use strict';
// Make sure that the domain stack doesn't get out of hand.
var common = require('../common');
+'use strict';
var domain = require('domain');
var assert = require('assert');
var common = require('../common');
+'use strict';
// Simple tests of most basic domain functionality.
var common = require('../common');
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.
assert.equal(typeof er.errno, 'number');
break;
- case "ENOENT: no such file or directory, open 'stream for nonexistent file'":
+ case
+ "ENOENT: no such file or directory, open 'stream for nonexistent file'":
assert.equal(typeof er.errno, 'number');
assert.equal(er.code, 'ENOENT');
assert.equal(er_path, 'stream for nonexistent file');
// 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) {
// 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);
var implicit;
d.run(function() {
- implicit = new events.EventEmitter;
+ implicit = new events.EventEmitter();
});
setTimeout(function() {
expectCaught++;
-var result = d.run(function () {
+var result = d.run(function() {
return 'return value';
});
assert.equal(result, 'return value');
// check if the executed function take in count the applied parameters
-result = d.run(function (a, b) {
+result = d.run(function(a, b) {
return a + ' ' + b;
}, '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() {
+'use strict';
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
require('../common');
var util = require('util');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
var listen1 = function listen1() {};
var listen2 = function listen2() {};
-var e1 = new events.EventEmitter;
+var e1 = new events.EventEmitter();
e1.once('newListener', function() {
assert.deepEqual(e1.listeners('hello'), []);
e1.once('newListener', function() {
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
+'use strict';
var EventEmitter = require('events');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var EventEmitter = require('events');
+'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var EventEmitter = require('events').EventEmitter;
var assert = require('assert');
-var e = new EventEmitter;
+var e = new EventEmitter();
var fl; // foo listeners
fl = e.listeners('foo');
+'use strict';
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
});
assert.throws(function() {
- e.setMaxListeners("and even this");
+ e.setMaxListeners('and even this');
});
e.emit('maxListeners');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
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');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
assert.deepEqual(actual.sort(), expected.sort());
});
function listener(name) {
- actual.push(name)
+ actual.push(name);
}
return common.mustCall(listener, expected.length);
}
e4.on('removeListener', function(name, listener) {
assert.equal(expectLength--, this.listeners('baz').length);
});
-e4.on('baz', function(){});
-e4.on('baz', function(){});
-e4.on('baz', function(){});
-assert.equal(e4.listeners('baz').length, expectLength+1);
+e4.on('baz', function() {});
+e4.on('baz', function() {});
+e4.on('baz', function() {});
+assert.equal(e4.listeners('baz').length, expectLength + 1);
e4.removeAllListeners('baz');
assert.equal(e4.listeners('baz').length, 0);
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
+'use strict';
var common = require('../common');
var assert = require('assert');
var events = require('events');
-var e = new events.EventEmitter;
+var e = new events.EventEmitter();
assert.deepEqual(e._events, {});
e.setMaxListeners(5);
+'use strict';
var common = require('../common');
var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
var ee1 = new MyEE2();
var ee2 = new MyEE2();
-ee1.on('x', function () {});
+ee1.on('x', function() {});
assert.equal(EventEmitter.listenerCount(ee2, 'x'), 0);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var exec = require('child_process').exec;
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
fs.chmodSync(file, mode);
};
-createFileWithPerms(readOnlyFile, 0444);
-createFileWithPerms(readWriteFile, 0666);
+createFileWithPerms(readOnlyFile, 0o444);
+createFileWithPerms(readWriteFile, 0o666);
/*
* On non-Windows supported platforms, fs.access(readOnlyFile, W_OK, ...)
assert.throws(function() {
fs.accessSync(doesNotExist);
-}, function (err) {
+}, function(err) {
return err.code === 'ENOENT' && err.path === doesNotExist;
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var join = require('path').join;
fs.writeFileSync(filename4, currentFileData, { mode: m });
common.error('appending to ' + filename4);
-var m = 0600;
+var m = 0o600;
fs.appendFileSync(filename4, num, { mode: m });
// windows permissions aren't unix
if (process.platform !== 'win32') {
var st = fs.statSync(filename4);
- assert.equal(st.mode & 0700, m);
+ assert.equal(st.mode & 0o700, m);
}
var fileData4 = fs.readFileSync(filename4);
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
common.error('appending to ' + filename4);
-var m = 0600;
+var m = 0o600;
fs.appendFile(filename4, n, { mode: m }, function(e) {
if (e) throw e;
// windows permissions aren't unix
if (process.platform !== 'win32') {
var st = fs.statSync(filename4);
- assert.equal(st.mode & 0700, m);
+ assert.equal(st.mode & 0o700, m);
}
fs.readFile(filename4, function(e, buffer) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
// On Windows chmod is only able to manipulate read-only bit
if (is_windows) {
- mode_async = 0400; // read-only
- mode_sync = 0600; // read-write
+ mode_async = 0o400; // read-only
+ mode_sync = 0o600; // read-write
} else {
- mode_async = 0777;
- mode_sync = 0644;
+ mode_async = 0o777;
+ mode_sync = 0o644;
}
var file1 = path.join(common.fixturesDir, 'a.js'),
console.log(fs.statSync(file1).mode);
if (is_windows) {
- assert.ok((fs.statSync(file1).mode & 0777) & mode_async);
+ assert.ok((fs.statSync(file1).mode & 0o777) & mode_async);
} else {
- assert.equal(mode_async, fs.statSync(file1).mode & 0777);
+ assert.equal(mode_async, fs.statSync(file1).mode & 0o777);
}
fs.chmodSync(file1, mode_sync);
if (is_windows) {
- assert.ok((fs.statSync(file1).mode & 0777) & mode_sync);
+ assert.ok((fs.statSync(file1).mode & 0o777) & mode_sync);
} else {
- assert.equal(mode_sync, fs.statSync(file1).mode & 0777);
+ assert.equal(mode_sync, fs.statSync(file1).mode & 0o777);
}
success_count++;
}
console.log(fs.fstatSync(fd).mode);
if (is_windows) {
- assert.ok((fs.fstatSync(fd).mode & 0777) & mode_async);
+ assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async);
} else {
- assert.equal(mode_async, fs.fstatSync(fd).mode & 0777);
+ assert.equal(mode_async, fs.fstatSync(fd).mode & 0o777);
}
fs.fchmodSync(fd, mode_sync);
if (is_windows) {
- assert.ok((fs.fstatSync(fd).mode & 0777) & mode_sync);
+ assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync);
} else {
- assert.equal(mode_sync, fs.fstatSync(fd).mode & 0777);
+ assert.equal(mode_sync, fs.fstatSync(fd).mode & 0o777);
}
success_count++;
fs.close(fd);
got_error = true;
} else {
console.log(fs.lstatSync(link).mode);
- assert.equal(mode_async, fs.lstatSync(link).mode & 0777);
+ assert.equal(mode_async, fs.lstatSync(link).mode & 0o777);
fs.lchmodSync(link, mode_sync);
- assert.equal(mode_sync, fs.lstatSync(link).mode & 0777);
+ assert.equal(mode_sync, fs.lstatSync(link).mode & 0o777);
success_count++;
}
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
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);
}, common.platformTimeout(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);
}, common.platformTimeout(50));
});
+'use strict';
var common = require('../common');
var assert = require('assert');
assert.ok(0 <= err.message.indexOf(fn));
});
-fs.mkdir(existingFile, 0666, function(err) {
+fs.mkdir(existingFile, 0o666, function(err) {
assert.ok(0 <= err.message.indexOf(existingFile));
});
assert.ok(0 <= err.message.indexOf(existingFile));
});
-fs.chmod(fn, 0666, function(err) {
+fs.chmod(fn, 0o666, function(err) {
assert.ok(0 <= err.message.indexOf(fn));
});
-fs.open(fn, 'r', 0666, function(err) {
+fs.open(fn, 'r', 0o666, function(err) {
assert.ok(0 <= err.message.indexOf(fn));
});
try {
++expected;
- fs.mkdirSync(existingFile, 0666);
+ fs.mkdirSync(existingFile, 0o666);
} catch (err) {
errors.push('mkdir');
assert.ok(0 <= err.message.indexOf(existingFile));
try {
++expected;
- fs.chmodSync(fn, 0666);
+ fs.chmodSync(fn, 0o666);
} catch (err) {
errors.push('chmod');
assert.ok(0 <= err.message.indexOf(fn));
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
common.error('open ' + file);
-fs.open(file, 'a', 0777, function(err, fd) {
+fs.open(file, 'a', 0o777, function(err, fd) {
common.error('fd ' + fd);
if (err) throw err;
+'use strict';
var common = require('../common');
var fs = require('fs');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var constants = require('constants');
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path'),
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
// Copyright io.js contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
fs.open = function() {
openCount++;
return _fsopen.apply(null, arguments);
-}
+};
fs.close = function() {
openCount--;
return _fsclose.apply(null, arguments);
-}
+};
function testLeak(endFn, callback) {
console.log('testing for leaks from fs.createReadStream().%s()...', endFn);
if (++i === loopCount) {
clearTimeout(this);
setTimeout(function() {
- assert.equal(0, openCount, 'no leaked file descriptors using ' + endFn + '() (got ' + openCount + ')');
+ assert.equal(0, openCount, 'no leaked file descriptors using ' +
+ endFn + '() (got ' + openCount + ')');
openCount = 0;
callback && setTimeout(callback, 100);
}, 100);
+'use strict';
var fs = require('fs');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
console.error('ok');
});
-var file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1, start: 1, end: 2}));
+var file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
+ start: 1, end: 2}));
assert.equal(file4.start, 1);
assert.equal(file4.end, 2);
var contentRead = '';
assert.equal(contentRead, 'yz');
});
-var file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1, start: 1}));
+var file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1,
+ start: 1}));
assert.equal(file5.start, 1);
file5.data = '';
file5.on('data', function(data) {
});
// https://github.com/joyent/node/issues/2320
-var file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23, start: 1}));
+var file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23,
+ start: 1}));
assert.equal(file6.start, 1);
file6.data = '';
file6.on('data', function(data) {
fs.createReadStream(rangeFile, Object.create({start: 10, end: 2}));
}, /start must be <= end/);
-var stream = fs.createReadStream(rangeFile, Object.create({ start: 0, end: 0 }));
+var stream = fs.createReadStream(rangeFile, Object.create({ start: 0,
+ end: 0 }));
assert.equal(stream.start, 0);
assert.equal(stream.end, 0);
stream.data = '';
});
});
-function file7Next(){
+function file7Next() {
// This will tell us if the fd is usable again or not.
file7 = fs.createReadStream(null, Object.create({fd: file7.fd, start: 0 }));
file7.data = '';
}
// Just to make sure autoClose won't close the stream because of error.
-var file8 = fs.createReadStream(null, Object.create({fd: 13337, autoClose: false }));
+var file8 = fs.createReadStream(null, Object.create({fd: 13337,
+ autoClose: false }));
file8.on('data', function() {});
file8.on('error', common.mustCall(function() {}));
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
});
});
-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 = '';
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path'),
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert'),
common = require('../common'),
fs = require('fs'),
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
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++;
var link = folder + '/cycles';
var testPath = cycles;
for (var i = 0; i < 10; i++) testPath += '/folder/cycles';
- try {fs.unlinkSync(link)} catch (ex) {}
+ try {fs.unlinkSync(link);} catch (ex) {}
fs.symlinkSync(cycles, link, 'dir');
unlink.push(link);
assert.equal(fs.realpathSync(testPath), path.resolve(expected));
var entry = tmp('node-test-realpath-f1');
try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch (e) {}
try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch (e) {}
- fs.mkdirSync(tmp('node-test-realpath-d2'), 0700);
+ fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
try {
[
[entry, '../' + common.tmpDirName + '/node-test-realpath-d1/foo'],
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
['a/b',
'a'
].forEach(function(folder) {
- try {fs.rmdirSync(tmp(folder))} catch (ex) {}
+ try {fs.rmdirSync(tmp(folder));} catch (ex) {}
});
}
function setup() {
cleanup();
}
setup();
- fs.mkdirSync(tmp('a'), 0755);
- fs.mkdirSync(tmp('a/b'), 0755);
+ fs.mkdirSync(tmp('a'), 0o755);
+ fs.mkdirSync(tmp('a/b'), 0o755);
fs.symlinkSync('..', tmp('a/d'), 'dir');
unlink.push(tmp('a/d'));
fs.symlinkSync('..', tmp('a/b/e'), 'dir');
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();
['/a/b/c/x.txt',
'/a/link'
].forEach(function(file) {
- try {fs.unlinkSync(root + file)} catch (ex) {}
+ try {fs.unlinkSync(root + file);} catch (ex) {}
});
['/a/b/c',
'/a/b',
'/a',
''
].forEach(function(folder) {
- try {fs.rmdirSync(root + folder)} catch (ex) {}
+ try {fs.rmdirSync(root + folder);} catch (ex) {}
});
}
function setup() {
'/a/b/c'
].forEach(function(folder) {
console.log('mkdir ' + root + folder);
- fs.mkdirSync(root + folder, 0700);
+ fs.mkdirSync(root + folder, 0o700);
});
fs.writeFileSync(root + '/a/b/c/x.txt', 'foo');
fs.symlinkSync(root + '/a/b', root + '/a/link', type);
var s;
try { s = fs.statSync(t); } catch (ex) {}
if (s) return;
- fs.mkdirSync(t, 0700);
+ fs.mkdirSync(t, 0o700);
});
fs.writeFileSync(tmp('cycles/root.js'), "console.error('roooot!');");
console.error('start tests');
+'use strict';
var common = require('../common');
var fs = require('fs');
var assert = require('assert');
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
// Test creating and resolving relative junction or symbolic link
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path'),
writeCalled = 0;
-fs.open(filename, 'w', 0644, function(err, fd) {
+fs.open(filename, 'w', 0o644, function(err, fd) {
openCalled++;
if (err) throw err;
+'use strict';
var common = require('../common');
var join = require('path').join;
var util = require('util');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
fs.closeSync = closeSync;
// Reset the umask for testing
-var mask = process.umask(0000);
+var mask = process.umask(0o000);
// On Windows chmod is only able to manipulate read-only bit. Test if creating
// the file in read-only mode works.
if (isWindows) {
- mode = 0444;
+ mode = 0o444;
} else {
- mode = 0755;
+ mode = 0o755;
}
// Test writeFileSync
content = fs.readFileSync(file1, {encoding: 'utf8'});
assert.equal('123', content);
-assert.equal(mode, fs.statSync(file1).mode & 0777);
+assert.equal(mode, fs.statSync(file1).mode & 0o777);
removeFile(file1);
function removeFile(file) {
try {
if (isWindows)
- fs.chmodSync(file, 0666);
+ fs.chmodSync(file, 0o666);
fs.unlinkSync(file);
} catch (err) {
if (err && err.code !== 'ENOENT')
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var filename3 = join(common.tmpDir, 'test3.txt');
common.error('writing to ' + filename3);
-var m = 0600;
+var m = 0o600;
fs.writeFile(filename3, n, { mode: m }, function(e) {
if (e) throw e;
// windows permissions aren't unix
if (process.platform !== 'win32') {
var st = fs.statSync(filename3);
- assert.equal(st.mode & 0700, m);
+ assert.equal(st.mode & 0o700, m);
}
ncallbacks++;
+'use strict';
const common = require('../common');
const fs = require('fs');
const assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
fs.close = function(fd) {
assert.ok(fd, 'fs.close must not be called without an undefined fd.');
fs.close = _fs_close;
- }
+ };
stream.destroy();
})();
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var expected = data + '';
var found;
-fs.open(fn, 'w', 0644, function(err, fd) {
+fs.open(fn, 'w', 0o644, function(err, fd) {
if (err) throw err;
console.log('open done');
fs.write(fd, data, 0, 'utf8', function(err, written) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var constants = require('constants');
var found, found2;
-fs.open(fn, 'w', 0644, function(err, fd) {
+fs.open(fn, 'w', 0o644, function(err, fd) {
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', function(err, written) {
});
-fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0644,
+fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644,
function(err, fd) {
if (err) throw err;
console.log('open done');
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
process.on('uncaughtException', function() { });
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
var ctx = test.responses[current];
console.error('< SERVER SENDING RESPONSE', ctx);
res.writeHead(200, ctx.headers);
- ctx.chunks.slice(0, -1).forEach(function(chunk) { res.write(chunk) });
+ ctx.chunks.slice(0, -1).forEach(function(chunk) { res.write(chunk); });
res.end(ctx.chunks[ctx.chunks.length - 1]);
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var http = require('http');
var assert = require('assert');
+'use strict';
var common = require('../common');
var http = require('http');
var assert = require('assert');
res.socket.on('close', function() {
console.log('socket closed, but not res');
- })
+ });
// it would be nice if this worked:
res.on('close', function() {
+'use strict';
var assert = require('assert'),
common = require('../common'),
http = require('http');
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, '/');
res.writeHead(200);
res.write('foo');
- complete = complete || function () {
+ complete = complete || function() {
res.end();
};
});
-server.listen(common.PORT, function () {
+server.listen(common.PORT, function() {
console.log('listen', server.address().port);
var agent = new http.Agent({maxSockets: 1});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
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,
});
// 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;
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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);
}
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();
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');
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();
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();
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
opts.agent = new http.Agent();
opts.agent.protocol = null;
- http.get(opts, function (res) {
+ http.get(opts, function(res) {
response++;
res.resume();
server.close();
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var http = require('http');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
port: common.PORT
}, function(x) {
x.setEncoding('utf8');
- x.on('data', function(c) {data += c});
+ x.on('data', function(c) {data += c;});
x.on('error', function(e) {
throw e;
});
server.close();
});
});
- get.on('error', function(e) {throw e});
+ get.on('error', function(e) {throw e;});
get.end();
});
+'use strict';
var assert = require('assert');
var http = require('http');
var common = require('../common');
process.on('exit', function() {
assert.equal(count, 1);
-})
+});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// see https://github.com/joyent/node/issues/3257
var common = require('../common');
req.write('.');
- sched(function() { req.end() }, 5);
+ sched(function() { req.end(); }, 5);
});
// schedule a callback after `ticks` event loop ticks
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
req3.end();
req3.on('response', function(res3) {
res3.setEncoding('utf8');
- res3.on('data', function(chunk) { body3 += chunk });
+ res3.on('data', function(chunk) { body3 += chunk; });
res3.on('end', function() { server.close(); });
});
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var net = require('net');
var http = require('http');
var util = require('util');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common'),
assert = require('assert'),
http = require('http'),
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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;
});
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Length':'2'});
res.write('*');
- setTimeout(function() { res.end('*') }, 100);
+ setTimeout(function() { res.end('*'); }, 100);
});
server.listen(options.port, options.host, function() {
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
if (!common.opensslCli) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var http = require('http'),
PORT = common.PORT,
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var assert = require('assert');
var common = require('../common');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
const http = require('http');
const server = http.createServer();
-server.on('request', function(req, res){
+server.on('request', function(req, res) {
assert(req.headers['foo'], 'bar');
res.end('ok');
server.close();
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
// This test requires the program 'ab'
+'use strict';
// We are demonstrating a problem with http.get when queueing up many
// transfers. The server simply introduces some delay and sends a file.
// Note this is demonstrated with connection: close.
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common'),
assert = require('assert'),
http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var http = require('http'),
common = require('../common'),
assert = require('assert'),
+'use strict';
var common = require('../common');
var assert = require('assert');
return 'GET /' + r + ' HTTP/1.1\r\n' +
'Host: localhost:' + common.PORT + '\r\n' +
'\r\n' +
- '\r\n'
+ '\r\n';
}).join('');
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
}
process.on('exit', function() {
- assert.equal(actualRequests, expectRequests)
+ assert.equal(actualRequests, expectRequests);
console.log('ok');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
}
process.on('exit', function() {
- assert.equal(actualRequests, expectRequests)
+ assert.equal(actualRequests, expectRequests);
console.log('ok');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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' });
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,
+'use strict';
var common = require('../common');
var http = require('http'),
assert = require('assert');
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() {
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: '/',
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
var s = http.createServer(function(req, res) {
switch (test) {
case 'headers':
- assert.throws(function() { res.setHeader() });
- assert.throws(function() { res.setHeader('someHeader') });
- assert.throws(function() { res.getHeader() });
- assert.throws(function() { res.removeHeader() });
+ assert.throws(function() { res.setHeader(); });
+ assert.throws(function() { res.setHeader('someHeader'); });
+ assert.throws(function() { res.getHeader(); });
+ assert.throws(function() { res.removeHeader(); });
res.setHeader('x-test-header', 'testing');
res.setHeader('X-TEST-HEADER2', 'testing');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Run this program with valgrind or efence with --expose_gc to expose the
// problem.
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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];
};
+'use strict';
// Verify that the HTTP server implementation handles multiple instances
// of the same header as per RFC2616: joining the handful of fields by ', '
// that support it, and dropping duplicates for other fields.
+'use strict';
// Verify that the HTTP server implementation handles multiple instances
// of the same header as per RFC2616: joining the handful of fields by ', '
// that support it, and dropping duplicates for other fields.
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);
function makeHeader(value) {
return function(header) {
return [header, value];
- }
+ };
}
var headers = []
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
if (fn) {
console.log('# %s', fn.name);
fn(run);
- } else
+ } else {
console.log('ok');
+ }
}
test(function serverTimeout(cb) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
});
server.listen(port, function() {
- function callback(){}
+ function callback() {}
var req = http.request({
port: port,
res.on('end', function() {
clientRequests++;
server.close();
- })
+ });
res.resume();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
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});
createRequest().end();
}
- function callback(){}
+ function callback() {}
var count = 0;
function createRequest() {
- var req = http.request({port: port, path: '/', agent: agent}, function(res) {
-
+ var req = http.request({port: port, path: '/', agent: agent},
+ function(res) {
req.clearTimeout(callback);
res.on('end', function() {
if (count == 11) {
server.close();
}
- })
+ });
res.resume();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
// Verify that the 'upgrade' header causes an 'upgrade' event to be emitted to
// the HTTP client. This test uses a raw TCP server to better control server
// behavior.
+'use strict';
// Verify that the 'upgrade' header causes an 'upgrade' event to be emitted to
// the HTTP client. This test uses a raw TCP server to better control server
// behavior.
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
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;
}
});
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;
}
});
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;
}
});
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;
}
});
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;
}
});
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;
}
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ];
var interval = setInterval(function() {
if (paused)
- return
+ return;
var chunk = chunks.shift();
if (chunk !== undefined) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
});
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();
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);
});
+'use strict';
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Create an ssl server. First connection, validate that not resume.
// Cache session and close connection. Use session on second connection.
// ASSERT resumption.
var connections = 0;
// create server
-var server = https.createServer(options, function(res, res) {
+var server = https.createServer(options, function(req, res) {
res.end('Goodbye');
connections++;
});
+'use strict';
// This tests the situation where you try to connect a https client
// to an http server. You should get an error and exit.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// I hate HTTP. One way of terminating an HTTP response is to not send
// a content-length header, not send a transfer-encoding: chunked header,
// and simply terminate the TCP connection. That is identity
+'use strict';
var common = require('../common');
if (!common.opensslCli) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
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' });
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,
+'use strict';
var common = require('../common'),
fs = require('fs'),
assert = require('assert');
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() {
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,
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var data = '';
https.get(options, function(res) {
- res.on('data', function(data_) { data += data_ });
- res.on('end', function() { server.close() });
+ res.on('data', function(data_) { data += data_; });
+ res.on('end', function() { server.close(); });
});
process.on('exit', function() {
+'use strict';
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
+'use strict';
var common = require('../common');
var assert = require('assert');
if (fn) {
console.log('# %s', fn.name);
fn(run);
- } else
+ } else {
console.log('ok');
+ }
}
test(function serverTimeout(cb) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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');
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
+'use strict';
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
if (listenWait === 0) {
allListening();
}
- }
+ };
}
function makeReq(path, port, error, host, ca) {
}
if (host) {
- options.headers = { host: host }
+ options.headers = { host: host };
}
var req = https.get(options);
expectResponseCount++;
: 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) {
server3.close();
}
res.resume();
- })
+ });
}
function allListening() {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Flags: --expose_internals
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
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?
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
server: 'localhost',
port: PORT,
path: '/',
- }).on('response', function (res) {
+ }).on('response', function(res) {
var s = '';
res.on('data', function(c) {
s += c.toString();
assert.equal(res.statusCode, 200);
console.log('ok');
});
- })
+ });
}
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
server: 'localhost',
port: PORT,
path: '/',
- }).on('response', function (res) {
+ }).on('response', function(res) {
var s = '';
res.on('data', function(c) {
s += c.toString();
assert.equal(s, 'hello from child\n');
assert.equal(res.statusCode, 200);
});
- })
+ });
}
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
server: 'localhost',
port: PORT,
path: '/',
- }).on('response', function (res) {
+ }).on('response', function(res) {
var s = '';
res.on('data', function(c) {
s += c.toString();
assert.equal(s, 'hello from child\n');
assert.equal(res.statusCode, 200);
});
- })
+ });
}
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
server: 'localhost',
port: PORT,
path: '/',
- }).on('response', function (res) {
+ }).on('response', function(res) {
var s = '';
res.on('data', function(c) {
s += c.toString();
assert.equal(s, 'hello from child\n');
assert.equal(res.statusCode, 200);
});
- })
+ });
}
}
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
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);
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);
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);
+'use strict';
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);
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);
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
var domain = require('domain');
+'use strict';
var common = require('../common');
var assert = require('assert');
var domain = require('domain');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
var server = net.createServer(assert.fail);
server.listen(fp, assert.fail);
server.on('error', common.mustCall(function(e) {
- assert.equal(e.address, fp)
+ assert.equal(e.address, fp);
}));
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var net = require('net');
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
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;
});
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var net = require('net');
-var sock = new net.Socket;
+var sock = new net.Socket();
sock.end(); // Should not throw.
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
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();
});
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var assert = require('assert');
var common = require('../common');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
case 'EINVAL':
case 'ENOTSOCK':
gotError = e;
- break
+ break;
}
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common'),
assert = require('assert'),
net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var fs = require('fs');
var net = require('net');
var path = require('path');
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
if (sockets.length === 2) {
server.close();
- sockets.forEach(function(c) { c.destroy() });
+ sockets.forEach(function(c) { c.destroy(); });
}
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
// This tests binds to one port, then attempts to start a server on that
// port. It should be EADDRINUSE but be able to then bind to another port.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// This example sets a timeout then immediately attempts to disable the timeout
// https://github.com/joyent/node/pull/2245
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
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();
});
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();
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');
});
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
socket.destroy();
}).on('close', function() {
server.close();
- })
+ });
for (var i = 0; i < N; ++i) {
socket.write(buf, function() { });
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
/*
* This test verifies that having a single nextTick statement and nothing else
* does not hang the event loop. If this test times out it has failed.
+'use strict';
var common = require('../common');
var assert = require('assert');
require('domain');
-assert.strictEqual(origNextTick, process.nextTick, 'Requiring domain should not change nextTick');
+assert.strictEqual(origNextTick, process.nextTick,
+ 'Requiring domain should not change nextTick');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var i;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var os = require('os');
+'use strict';
var assert = require('assert');
var path = require('path');
var common = require('../common');
+'use strict';
var assert = require('assert');
var path = require('path');
];
var errors = [
- {method: 'parse', input: [null], message: /Path must be a string. Received null/},
- {method: 'parse', input: [{}], message: /Path must be a string. Received {}/},
- {method: 'parse', input: [true], message: /Path must be a string. Received true/},
- {method: 'parse', input: [1], message: /Path must be a string. Received 1/},
- {method: 'parse', input: [], message: /Path must be a string. Received 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: /Path must be a string. Received null/},
+ {method: 'parse', input: [{}],
+ message: /Path must be a string. Received {}/},
+ {method: 'parse', input: [true],
+ message: /Path must be a string. Received true/},
+ {method: 'parse', input: [1],
+ message: /Path must be a string. Received 1/},
+ {method: 'parse', input: [],
+ message: /Path must be a string. Received 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/},
];
check(path.win32, winPaths);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
// This test ensures SourceStream.pipe(DestStream) returns DestStream
var common = require('../common');
+'use strict';
var common = require('../common'),
assert = require('assert'),
path = require('path'),
option += '-r ' + preload + ' ';
});
return option;
-}
+};
var fixture = function(name) {
return path.join(__dirname, '../fixtures/' + name);
-}
+};
var fixtureA = fixture('printA.js');
var fixtureB = fixture('printB.js');
-var fixtureC = fixture('printC.js')
+var fixtureC = fixture('printC.js');
var fixtureThrows = fixture('throws_error4.js');
// test preloading a single module works
+'use strict';
var util = require('util');
var path = require('path');
var assert = require('assert');
console.error('argv=%j', process.argv);
console.error('exec=%j', process.execPath);
-if (process.argv[2] !== "child") {
- var child = spawn('./iojs', [__filename, "child"], {
+if (process.argv[2] !== 'child') {
+ var child = spawn('./iojs', [__filename, 'child'], {
cwd: path.dirname(process.execPath)
});
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: '));
assert.equal(childArgv0, process.execPath);
});
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var assert = require('assert');
assert.throws(
/No such module: test/
);
-assert.doesNotThrow(function () {
+assert.doesNotThrow(function() {
process.binding('buffer');
}, function(err) {
if ( (err instanceof Error) ) {
return true;
}
-}, "unexpected error");
+}, 'unexpected error');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
+'use strict';
+/* eslint-disable max-len */
+
// first things first, set the timezone; see tzset(3)
process.env.TZ = 'Europe/Amsterdam';
+'use strict';
var assert = require('assert');
var spawn = require('child_process').spawn;
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);
});
}
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var assert = require('assert');
// recursively calling .exit() should not overflow the call stack
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
+'use strict';
var common = require('../common');
var assert = require('assert');
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));
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
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.
//
+'use strict';
var common = require('../common');
var assert = require('assert');
var N = 2;
+'use strict';
var common = require('../common');
var assert = require('assert');
var os = require('os');
+'use strict';
if (process.platform === 'win32') {
// Win32 doesn't have signals, just a kindof emulation, insufficient
// for this test to apply.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var Process = process.binding('process_wrap').Process;
+'use strict';
var common = require('../common');
var assert = require('assert');
var domain = require('domain');
}, 10);
}
-asyncTest('synchronously rejected promise should trigger unhandledRejection', function(done) {
+asyncTest('synchronously rejected promise should trigger' +
+ ' unhandledRejection', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
Promise.reject(e);
});
-asyncTest('synchronously rejected promise should trigger unhandledRejection', function(done) {
+asyncTest('synchronously rejected promise should trigger' +
+ ' unhandledRejection', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
});
-asyncTest('Promise rejected after setImmediate should trigger unhandledRejection', function(done) {
+asyncTest('Promise rejected after setImmediate should trigger' +
+ ' unhandledRejection', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
});
-asyncTest('Promise rejected after setTimeout(,1) should trigger unhandled rejection', function(done) {
+asyncTest('Promise rejected after setTimeout(,1) should trigger' +
+ ' unhandled rejection', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
});
-asyncTest('Catching a promise rejection after setImmediate is not soon enough to stop unhandledRejection', function(done) {
+asyncTest('Catching a promise rejection after setImmediate is not' +
+ ' soon enough to stop unhandledRejection', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
var _reject;
var promise = new Promise(function(_, reject) {
_reject = reject;
- })
+ });
_reject(e);
setImmediate(function() {
- promise.then(assert.fail, function(){});
+ promise.then(assert.fail, function() {});
});
});
-asyncTest('When re-throwing new errors in a promise catch, only the re-thrown error should hit unhandledRejection', function(done) {
+asyncTest('When re-throwing new errors in a promise catch, only the' +
+ ' re-thrown error should hit unhandledRejection', function(done) {
var e = new Error();
var e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
});
});
-asyncTest('Test params of unhandledRejection for a synchronously-rejected promise', function(done) {
+asyncTest('Test params of unhandledRejection for a synchronously-rejected' +
+ 'promise', function(done) {
var e = new Error();
var e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
var promise = Promise.reject(e);
});
-asyncTest('When re-throwing new errors in a promise catch, only the re-thrown error should hit unhandledRejection: original promise rejected async with setTimeout(,1)', function(done) {
+asyncTest('When re-throwing new errors in a promise catch, only the ' +
+ 're-thrown error should hit unhandledRejection: original promise' +
+ ' rejected async with setTimeout(,1)', function(done) {
var e = new Error();
var e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
});
});
-asyncTest('When re-throwing new errors in a promise catch, only the re-thrown error should hit unhandledRejection: promise catch attached a process.nextTick after rejection', function(done) {
+asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' +
+ ' error should hit unhandledRejection: promise catch attached a' +
+ ' process.nextTick after rejection', function(done) {
var e = new Error();
var e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
var promise2;
});
-asyncTest('unhandledRejection should not be triggered if a promise catch is attached synchronously upon the promise\'s creation', function(done) {
+asyncTest('unhandledRejection should not be triggered if a promise catch is' +
+ ' attached synchronously upon the promise\'s creation',
+ function(done) {
var e = new Error();
onUnhandledFail(done);
- Promise.reject(e).then(assert.fail, function(){});
+ Promise.reject(e).then(assert.fail, function() {});
});
-asyncTest('unhandledRejection should not be triggered if a promise catch is attached synchronously upon the promise\'s creation', function(done) {
+asyncTest('unhandledRejection should not be triggered if a promise catch is' +
+ ' attached synchronously upon the promise\'s creation',
+ function(done) {
var e = new Error();
onUnhandledFail(done);
new Promise(function(_, reject) {
reject(e);
- }).then(assert.fail, function(){});
+ }).then(assert.fail, function() {});
});
-asyncTest('Attaching a promise catch in a process.nextTick is soon enough to prevent unhandledRejection', function(done) {
+asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
+ ' prevent unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
var promise = Promise.reject(e);
process.nextTick(function() {
- promise.then(assert.fail, function(){});
+ promise.then(assert.fail, function() {});
});
});
-asyncTest('Attaching a promise catch in a process.nextTick is soon enough to prevent unhandledRejection', function(done) {
+asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
+ ' prevent unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
var promise = new Promise(function(_, reject) {
reject(e);
});
process.nextTick(function() {
- promise.then(assert.fail, function(){});
+ promise.then(assert.fail, function() {});
});
});
// State adapation tests
-asyncTest('catching a promise which is asynchronously rejected (via resolution to an asynchronously-rejected promise) prevents unhandledRejection', function(done) {
+asyncTest('catching a promise which is asynchronously rejected (via' +
+ 'resolution to an asynchronously-rejected promise) prevents' +
+ ' unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
Promise.resolve().then(function() {
});
});
-asyncTest('Catching a rejected promise derived from throwing in a fulfillment handler prevents unhandledRejection', function(done) {
+asyncTest('Catching a rejected promise derived from throwing in a' +
+ ' fulfillment handler prevents unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
Promise.resolve().then(function() {
});
});
-asyncTest('Catching a rejected promise derived from returning a synchronously-rejected promise in a fulfillment handler prevents unhandledRejection', function(done) {
+asyncTest('Catching a rejected promise derived from returning a' +
+ ' synchronously-rejected promise in a fulfillment handler' +
+ ' prevents unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
Promise.resolve().then(function() {
});
});
-asyncTest('A rejected promise derived from returning an asynchronously-rejected promise in a fulfillment handler does trigger unhandledRejection', function(done) {
+asyncTest('A rejected promise derived from returning an' +
+ ' asynchronously-rejected promise in a fulfillment handler' +
+ ' does trigger unhandledRejection', function(done) {
var e = new Error();
var _promise;
onUnhandledSucceed(done, function(reason, promise) {
});
});
-asyncTest('A rejected promise derived from throwing in a fulfillment handler does trigger unhandledRejection', function(done) {
+asyncTest('A rejected promise derived from throwing in a fulfillment handler' +
+ ' does trigger unhandledRejection', function(done) {
var e = new Error();
var _promise;
onUnhandledSucceed(done, function(reason, promise) {
});
});
-asyncTest('A rejected promise derived from returning a synchronously-rejected promise in a fulfillment handler does trigger unhandledRejection', function(done) {
+asyncTest('A rejected promise derived from returning a synchronously-rejected' +
+ ' promise in a fulfillment handler does trigger unhandledRejection',
+ function(done) {
var e = new Error();
var _promise;
onUnhandledSucceed(done, function(reason, promise) {
});
// Combinations with Promise.all
-asyncTest('Catching the Promise.all() of a collection that includes a rejected promise prevents unhandledRejection', function(done) {
+asyncTest('Catching the Promise.all() of a collection that includes a' +
+ 'rejected promise prevents unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
Promise.all([Promise.reject(e)]).then(assert.fail, function()Â {});
});
-asyncTest('Catching the Promise.all() of a collection that includes a nextTick-async rejected promise prevents unhandledRejection', function(done) {
+asyncTest('Catching the Promise.all() of a collection that includes a ' +
+ 'nextTick-async rejected promise prevents unhandledRejection',
+ function(done) {
var e = new Error();
onUnhandledFail(done);
var p = new Promise(function(_, reject) {
});
});
-asyncTest('Failing to catch the Promise.all() of a collection that includes a rejected promise triggers unhandledRejection for the returned promise, not the passed promise', function(done) {
+asyncTest('Failing to catch the Promise.all() of a collection that includes' +
+ ' a rejected promise triggers unhandledRejection for the returned' +
+ ' promise, not the passed promise', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
var p = Promise.all([Promise.reject(e)]);
});
-asyncTest('Waiting setTimeout(, 10) to catch a promise causes an unhandledRejection + rejectionHandled pair', function(done) {
+asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
+ ' unhandledRejection + rejectionHandled pair', function(done) {
clean();
var unhandledPromises = [];
var e = new Error();
}, 10);
});
-asyncTest('Waiting for some combination of process.nextTick + promise microtasks to attach a catch handler is still soon enough to prevent unhandledRejection', function(done) {
+asyncTest('Waiting for some combination of process.nextTick + promise' +
+ ' microtasks to attach a catch handler is still soon enough to' +
+ ' prevent unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
});
});
-asyncTest('Waiting for some combination of process.nextTick + promise microtasks to attach a catch handler is still soon enough to prevent unhandledRejection: inside setImmediate', function(done) {
+asyncTest('Waiting for some combination of process.nextTick + promise' +
+ ' microtasks to attach a catch handler is still soon enough to ' +
+ 'prevent unhandledRejection: inside setImmediate', function(done) {
var e = new Error();
onUnhandledFail(done);
});
});
-asyncTest('Waiting for some combination of process.nextTick + promise microtasks to attach a catch handler is still soon enough to prevent unhandledRejection: inside setTimeout', function(done) {
+asyncTest('Waiting for some combination of process.nextTick + promise ' +
+ 'microtasks to attach a catch handler is still soon enough to ' +
+ 'prevent unhandledRejection: inside setTimeout', function(done) {
var e = new Error();
onUnhandledFail(done);
}, 0);
});
-asyncTest('Waiting for some combination of promise microtasks + process.nextTick to attach a catch handler is still soon enough to prevent unhandledRejection', function(done) {
+asyncTest('Waiting for some combination of promise microtasks + ' +
+ 'process.nextTick to attach a catch handler is still soon enough' +
+ ' to prevent unhandledRejection', function(done) {
var e = new Error();
onUnhandledFail(done);
});
});
-asyncTest('Waiting for some combination of promise microtasks + process.nextTick to attach a catch handler is still soon enough to prevent unhandledRejection: inside setImmediate', function(done) {
+asyncTest('Waiting for some combination of promise microtasks +' +
+ ' process.nextTick to attach a catch handler is still soon enough' +
+ ' to prevent unhandledRejection: inside setImmediate',
+ function(done) {
var e = new Error();
onUnhandledFail(done);
});
});
-asyncTest('Waiting for some combination of promise microtasks + process.nextTick to attach a catch handler is still soon enough to prevent unhandledRejection: inside setTimeout', function(done) {
+asyncTest('Waiting for some combination of promise microtasks +' +
+ ' process.nextTick to attach a catch handler is still soon enough' +
+ ' to prevent unhandledRejection: inside setTimeout', function(done) {
var e = new Error();
onUnhandledFail(done);
}, 0);
});
-asyncTest('setImmediate + promise microtasks is too late to attach a catch handler; unhandledRejection will be triggered in that case. (setImmediate before promise creation/rejection)', function(done) {
+asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
+ ' handler; unhandledRejection will be triggered in that case.' +
+ ' (setImmediate before promise creation/rejection)', function(done) {
var e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
var p = Promise.reject(e);
setImmediate(function() {
- Promise.resolve().then(function () {
- p.catch(function(){});
+ Promise.resolve().then(function() {
+ p.catch(function() {});
});
});
});
-asyncTest('setImmediate + promise microtasks is too late to attach a catch handler; unhandledRejection will be triggered in that case (setImmediate before promise creation/rejection)', function(done) {
+asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
+ ' handler; unhandledRejection will be triggered in that case' +
+ ' (setImmediate before promise creation/rejection)', function(done) {
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(undefined, reason);
assert.strictEqual(p, promise);
});
setImmediate(function() {
- Promise.resolve().then(function () {
- Promise.resolve().then(function () {
- Promise.resolve().then(function () {
- Promise.resolve().then(function () {
- p.catch(function(){});
+ Promise.resolve().then(function() {
+ Promise.resolve().then(function() {
+ Promise.resolve().then(function() {
+ Promise.resolve().then(function() {
+ p.catch(function() {});
});
});
});
var p = Promise.reject();
});
-asyncTest('setImmediate + promise microtasks is too late to attach a catch handler; unhandledRejection will be triggered in that case (setImmediate after promise creation/rejection)', function(done) {
+asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
+ ' handler; unhandledRejection will be triggered in that case' +
+ ' (setImmediate after promise creation/rejection)', function(done) {
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(undefined, reason);
assert.strictEqual(p, promise);
});
var p = Promise.reject();
setImmediate(function() {
- Promise.resolve().then(function () {
- Promise.resolve().then(function () {
- Promise.resolve().then(function () {
- Promise.resolve().then(function () {
- p.catch(function(){});
+ Promise.resolve().then(function() {
+ Promise.resolve().then(function() {
+ Promise.resolve().then(function() {
+ Promise.resolve().then(function() {
+ p.catch(function() {});
});
});
});
});
});
-asyncTest('Promise unhandledRejection handler does not interfere with domain error handlers being given exceptions thrown from nextTick.', function(done) {
+asyncTest('Promise unhandledRejection handler does not interfere with domain' +
+ ' error handlers being given exceptions thrown from nextTick.',
+ function(done) {
var d = domain.create();
var domainReceivedError;
d.on('error', function(e) {
});
});
-asyncTest('nextTick is immediately scheduled when called inside an event handler', function(done) {
+asyncTest('nextTick is immediately scheduled when called inside an event' +
+ ' handler', function(done) {
clean();
var e = new Error('error');
process.on('unhandledRejection', function(reason, promise) {
});
setTimeout(function() {
order.push(2);
- assert.deepEqual([1,2], order);
+ assert.deepEqual([1, 2], order);
done();
}, 1);
});
Promise.reject(e);
});
-asyncTest('Throwing an error inside a rejectionHandled handler goes to unhandledException, and does not cause .catch() to throw an exception', function(done) {
+asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
+ ' unhandledException, and does not cause .catch() to throw an' +
+ 'exception', function(done) {
clean();
var e = new Error();
var e2 = new Error();
var tearDownException = setupException(function(err) {
- assert.equal(e2, err);
- tearDownException();
- done();
+ assert.equal(e2, err);
+ tearDownException();
+ done();
});
process.on('rejectionHandled', function() {
throw e2;
var p = Promise.reject(e);
setTimeout(function() {
try {
- p.catch(function(){});
+ p.catch(function() {});
} catch (e) {
done(new Error('fail'));
}
+'use strict';
var common = require('../common');
var punycode = require('punycode');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
// 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'});
+'use strict';
/*
* Tests to verify we're reading in doubles correctly
*/
+'use strict';
/*
* Tests to verify we're reading in floats correctly
*/
+'use strict';
/*
* Tests to verify we're reading in signed integers correctly
*/
+'use strict';
var assert = require('assert');
var readline = require('readline');
var EventEmitter = require('events').EventEmitter;
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 });
});
rli.on('close', function() {
callCount++;
- })
+ });
fi.emit('data', expectedLines.join('\n'));
fi.emit('end');
assert.equal(callCount, expectedLines.length);
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('> '), '> ');
+ 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);
assert.equal(readline.getStringWidth('\u001b[31m\u001b[39m'), 0);
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
assert.ok(called);
assert.doesNotThrow(function() {
- rli.setPrompt("ddd> ");
+ rli.setPrompt('ddd> ');
});
assert.doesNotThrow(function() {
});
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();
- })
+ });
});
});
+'use strict';
var EventEmitter = require('events').EventEmitter;
var PassThrough = require('stream').PassThrough;
var assert = require('assert');
var rli = new Interface({ input: fi, output: fo, terminal: true });
var keys = [];
-fi.on('keypress', function (s, k) {
+fi.on('keypress', function(s, k) {
keys.push(k);
});
expectedKeys = [ expectedKeys ];
}
- expectedKeys = expectedKeys.map(function (k) {
+ expectedKeys = expectedKeys.map(function(k) {
return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k;
});
keys = [];
- sequences.forEach(function (sequence) {
+ sequences.forEach(function(sequence) {
fi.write(sequence);
});
assert.deepStrictEqual(keys, expectedKeys);
+'use strict';
var assert = require('assert');
var readline = require('readline');
var Stream = require('stream');
+'use strict';
/*
* A battery of tests to help us read a series of uints
*/
+'use strict';
process.domain = null;
-timer = setTimeout(function() {
- console.log("this console.log statement should not make node crash");
+var timer = setTimeout(function() {
+ console.log('this console.log statement should not make node crash');
}, 1);
+'use strict';
var assert = require('assert');
var readline = require('readline');
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();
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common'),
assert = require('assert'),
vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
process.stdin.emit('end');
+'use strict';
var assert = require('assert');
var child_process = require('child_process');
+'use strict';
//console.log('puts before');
Object.prototype.xadsadsdasasdxx = function() {
+'use strict';
var assert = require('assert');
var util = require('util');
var join = require('path').join;
data.forEach(function(line) {
self.emit('data', line + '\n');
});
- }
+ };
}
util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true;
var testFile = [
- 'var top = function () {',
+ 'var top = function() {',
'var inner = {one:1};'
];
var saveFileName = join(common.tmpDir, 'test.save.js');
+'use strict';
var assert = require('assert');
var util = require('util');
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');
});
- }
+ };
}
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 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) {
assert(gotWrite);
}
-function test2(){
+function test2() {
var gotWrite = false;
putIn.write = function(data) {
gotWrite = true;
+'use strict';
var common = require('../common'),
assert = require('assert'),
Stream = require('stream'),
// 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({
+'use strict';
var assert = require('assert');
var common = require('../common');
data.forEach(function(line) {
self.emit('data', line + '\n');
});
- }
+ };
}
util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true;
// 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") })'
]);
+'use strict';
var common = require('../common'),
assert = require('assert'),
Stream = require('stream'),
// 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() {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var Stream = require('stream');
cli.input.emit('data', `
x = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), '> 3\n> ')
+ assert.equal(cli.output.accumulator.join(''), '> 3\n> ');
cli.output.accumulator.length = 0;
cli.input.emit('data', `
cli.input.emit('data', `
x = 3
`.trim() + '\n');
- assert.equal(cli.output.accumulator.join(''), '> 3\n> ')
+ assert.equal(cli.output.accumulator.join(''), '> 3\n> ');
cli.output.accumulator.length = 0;
cli.input.emit('data', `
function initRepl(mode) {
var input = new Stream();
- input.write = input.pause = input.resume = function(){};
+ input.write = input.pause = input.resume = function() {};
input.readable = true;
var output = new Stream();
+'use strict';
var common = require('../common'),
assert = require('assert'),
Stream = require('stream'),
// 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
writer: writer,
replMode: repl.REPL_MODE_MAGIC,
historySize: 50
-})
+});
assert.equal(r3.replMode, repl.REPL_MODE_MAGIC);
assert.equal(r3.historySize, 50);
+'use strict';
var common = require('../common'),
assert = require('assert'),
repl = require('repl');
+'use strict';
var common = require('../common');
common.globalCheck = false;
// 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) {
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();
});
});
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();
+'use strict';
var common = require('../common'),
assert = require('assert'),
spawn = require('child_process').spawn,
'var e = new (require("repl")).REPLServer("foo.. "); e.context.e = e;',
];
-var p = "bar.. ";
+var p = 'bar.. ';
var child = spawn(process.execPath, args);
child.stdout.setEncoding('utf8');
var data = '';
-child.stdout.on('data', function(d) { data += d });
+child.stdout.on('data', function(d) { data += d; });
child.stdin.end(util.format("e.setPrompt('%s');%s", p, os.EOL));
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
data.forEach(function(line) {
self.emit('data', line + '\n');
});
- }
+ };
}
util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true;
// Tab Complete will not break in an ternary operator with ()
putIn.run([
- 'var inner = ( true ' ,
+ 'var inner = ( true ',
'?',
'{one: 1} : '
]);
// Tab Complete will return a simple local variable
putIn.run([
- 'var top = function () {',
+ 'var top = function() {',
'var inner = {one:1};'
]);
testMe.complete('inner.o', function(error, data) {
// Tab Complete will return a complex local variable
putIn.run([
- 'var top = function () {',
+ 'var top = function() {',
'var inner = {',
' one:1',
'};'
// Tab Complete will return a complex local variable even if the function
// has parameters
putIn.run([
- 'var top = function (one, two) {',
+ 'var top = function(one, two) {',
'var inner = {',
' one:1',
'};'
// Tab Complete will return a complex local variable even if the
// scope is nested inside an immediately executed function
putIn.run([
- 'var top = function () {',
+ 'var top = function() {',
'(function test () {',
'var inner = {',
' one:1',
// currently does not work, but should not break note the inner function
// def has the params and { on a separate line
putIn.run([
- 'var top = function () {',
+ 'var top = function() {',
'r = function test (',
' one, two) {',
'var inner = {',
// currently does not work, but should not break, not the {
putIn.run([
- 'var top = function () {',
+ 'var top = function() {',
'r = function test ()',
'{',
'var inner = {',
// currently does not work, but should not break
putIn.run([
- 'var top = function () {',
+ 'var top = function() {',
'r = function test (',
')',
'{',
}, 1000);
testMe.complete(' ', function(error, data) {
- assert.deepEqual(data, [[],undefined]);
+ assert.deepEqual(data, [[], undefined]);
clearTimeout(spaceTimeout);
});
+'use strict';
var assert = require('assert');
var util = require('util');
var repl = require('repl');
callback(null, cmd);
});
-testMe._domain.on('error', function (e) {
+testMe._domain.on('error', function(e) {
assert.fail();
});
+'use strict';
var assert = require('assert');
var common = require('../common');
stdout += c;
});
-child.stdin.write = function(original) { return function(c) {
- process.stderr.write(c);
- return original.call(child.stdin, c);
-}}(child.stdin.write);
+child.stdin.write = function(original) {
+ return function(c) {
+ process.stderr.write(c);
+ return original.call(child.stdin, c);
+ };
+}(child.stdin.write);
child.stdout.once('data', function() {
child.stdin.write('var throws = 0;');
+/* eslint-disable max-len, strict */
var common = require('../common');
var assert = require('assert');
{ client: client_unix, send: '1 }',
expect: '{ a: 1 }' },
// Multiline anonymous function with comment
- { client: client_unix, send: '(function () {',
+ { client: client_unix, send: '(function() {',
expect: prompt_multiline },
{ client: client_unix, send: '// blah',
expect: prompt_multiline },
// npm prompt error message
{ client: client_unix, send: 'npm install foobar',
expect: expect_npm },
- { client: client_unix, send: '(function () {\n\nreturn 1;\n})()',
+ { client: client_unix, send: '(function() {\n\nreturn 1;\n})()',
expect: '1' },
{ client: client_unix, send: '{\n\na: 1\n}',
expect: '{ a: 1 }' },
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var module = require('module');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+/* eslint-disable max-len */
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
try {
+'use strict';
var assert = require('assert');
var nativeProcess = require('process');
+'use strict';
var common = require('../common');
var fixturesDir = common.fixturesDir;
var assert = require('assert');
+'use strict';
// SIGUSR1 and SIGHUP are not supported on Windows
if (process.platform === 'win32') {
process.exit(0);
// has been previously registered, and `process.listeners(SIGNAL).length === 1`
process.on('SIGHUP', function() {});
process.removeAllListeners('SIGHUP');
-process.on('SIGHUP', function() { sighup = true });
+process.on('SIGHUP', function() { sighup = true; });
process.kill(process.pid, 'SIGHUP');
process.on('exit', function() {
+'use strict';
var common = require('../common');
var assert = require('assert');
var Signal = process.binding('signal_wrap').Signal;
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var os = require('os');
+'use strict';
var common = require('../common');
// This test *only* verifies that invoking the stdin getter does not
+'use strict';
console.error('before opening stdin');
process.stdin.resume();
console.error('stdin opened');
+'use strict';
console.error('before opening stdin');
process.stdin.resume();
console.error('stdin opened');
+'use strict';
process.stdin.resume();
process.stdin.pause();
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
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;
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
+'use strict';
var common = require('../common');
var assert = require('assert');
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);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var gotEnd = false;
+'use strict';
var assert = require('assert');
var common = require('../common');
var stream = require('stream');
-var readable = new stream.Readable;
+var readable = new stream.Readable();
// _read is a noop, here.
readable._read = Function();
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// This test asserts that Stream.prototype.pipe does not leave listeners
// hanging on the source or dest.
+'use strict';
var common = require('../common');
var assert = require('assert');
var Stream = require('stream').Stream;
var R = Stream.Readable;
var W = Stream.Writable;
- var r = new R;
- var w = new W;
+ var r = new R();
+ var w = new W();
var removed = false;
var didTest = false;
var R = Stream.Readable;
var W = Stream.Writable;
- var r = new R;
- var w = new W;
+ var r = new R();
+ var w = new W();
var removed = false;
var didTest = false;
var caught = false;
+'use strict';
var common = require('../common');
var stream = require('stream');
var assert = require('assert');
+'use strict';
var common = require('../common');
var Readable = require('stream').Readable;
var assert = require('assert');
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);
// 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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var r = new Readable({ read: _read });
r.resume();
-process.on('exit', function () {
+process.on('exit', function() {
assert.equal(r._read, _read);
assert(_readCalled);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
t.end(new Buffer('blerg'));
t.resume();
-process.on('exit', function () {
+process.on('exit', function() {
assert.equal(t._transform, _transform);
assert.equal(t._flush, _flush);
assert(_transformCalled);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
assert(parser._readableState.highWaterMark === 16);
assert(parser._writableState.highWaterMark === (16 * 1024));
-parser._transform = function (chunk, enc, callback) {
+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);
});
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 });
-process.on('exit', function () {
+process.on('exit', function() {
assert(serialized[0] === 42);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
};
+'use strict';
var common = require('../common');
var assert = require('assert');
w2.write(new Buffer('blerg'));
w2.end();
-process.on('exit', function () {
+process.on('exit', function() {
assert.equal(w._write, _write);
assert(_writeCalled);
assert.equal(w2._writev, _writev);
+'use strict';
var common = require('../common');
var assert = require('assert');
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();
};
+'use strict';
var common = require('../common');
var assert = require('assert');
};
var expectChunks = decode ?
- [{ encoding: 'buffer',
- chunk: [104, 101, 108, 108, 111, 44, 32] },
- { encoding: 'buffer', chunk: [119, 111, 114, 108, 100] },
- { encoding: 'buffer', chunk: [33] },
- { 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] }] :
- [{ encoding: 'ascii', chunk: 'hello, ' },
+ [
+ { encoding: 'buffer',
+ chunk: [104, 101, 108, 108, 111, 44, 32] },
+ { encoding: 'buffer',
+ chunk: [119, 111, 114, 108, 100] },
+ { encoding: 'buffer',
+ chunk: [33] },
+ { 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]}
+ ] : [
+ { encoding: 'ascii', chunk: 'hello, ' },
{ encoding: 'utf8', chunk: 'world' },
{ encoding: 'buffer', chunk: [33] },
{ encoding: 'binary', chunk: '\nand then...' },
- { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }];
+ { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }
+ ];
var actualChunks;
w._writev = function(chunks, cb) {
+'use strict';
var common = require('../common');
var R = require('_stream_readable');
var W = require('_stream_writable');
src.on('end', function() {
assert.equal(Buffer.concat(accum) + '', 'MQ==');
clearTimeout(timeout);
-})
+});
src.pipe(dst);
+'use strict';
var common = require('../common');
var R = require('_stream_readable');
var assert = require('assert');
+'use strict';
var common = require('../common');
var stream = require('stream');
var Buffer = require('buffer').Buffer;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var Readable = require('_stream_readable');
var Writable = require('_stream_writable');
+'use strict';
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var stream = require('stream');
var Readable = stream.Readable;
encoding: 'utf8'
});
-var source = new EE;
+var source = new EE();
stream._read = function() {
console.error('stream._read');
// now emit some chunks.
-var chunk = "asdfg";
+var chunk = 'asdfg';
var set = 0;
readStart();
+'use strict';
var common = require('../common');
var assert = require('assert');
var Readable = require('stream').Readable;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var common = require('../common');
var fromList = require('_stream_readable')._fromList;
fn({
same: assert.deepEqual,
equal: assert.equal,
- end: function () {
+ end: function() {
count--;
run();
}
}
// ensure all tests have run
-process.on("exit", function () {
+process.on('exit', function() {
assert.equal(count, 0);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var common = require('../common');
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;
}
+'use strict';
var common = require('../common');
var assert = require('assert');
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);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
function runTest(highWaterMark, objectMode, produce) {
testRuns++;
- var old = new EE;
- var r = new Readable({ highWaterMark: highWaterMark, objectMode: objectMode });
+ var old = new EE();
+ var r = new Readable({ highWaterMark: highWaterMark,
+ objectMode: objectMode });
assert.equal(r, r.wrap(old));
var ended = false;
}
}
- 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);
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() });
+runTest(1, true, function() { return objectChunks.shift(); });
process.on('exit', function() {
assert.equal(testRuns, completedRuns);
+'use strict';
var common = require('../common');
var assert = require('assert');
var R = require('_stream_readable');
fn({
same: assert.deepEqual,
equal: assert.equal,
- end: function () {
+ end: function() {
count--;
run();
}
}
// ensure all tests have run
-process.on("exit", function () {
+process.on('exit', function() {
assert.equal(count, 0);
});
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);
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();
});
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;
+'use strict';
var assert = require('assert');
var common = require('../common');
var PassThrough = require('_stream_passthrough');
same: assert.deepEqual,
equal: assert.equal,
ok: assert,
- end: function () {
+ end: function() {
count--;
run();
}
}
// ensure all tests have run
-process.on("exit", function () {
+process.on('exit', function() {
assert.equal(count, 0);
});
t.end();
});
-test('object passthrough', function (t) {
+test('object passthrough', function(t) {
var pt = new PassThrough({ objectMode: true });
pt.write(1);
});
test('simple transform', function(t) {
- var pt = new Transform;
+ var pt = new Transform();
pt._transform = function(c, e, cb) {
var ret = new Buffer(c.length);
ret.fill('x');
});
test('async passthrough', function(t) {
- var pt = new Transform;
+ var pt = new Transform();
pt._transform = function(chunk, encoding, cb) {
setTimeout(function() {
pt.push(chunk);
});
test('assymetric transform (expand)', function(t) {
- var pt = new Transform;
+ var pt = new Transform();
// emit each chunk 2 times.
pt._transform = function(chunk, encoding, cb) {
setTimeout(function() {
pt.push(chunk);
cb();
- }, 10)
+ }, 10);
}, 10);
};
});
test('assymetric transform (compress)', function(t) {
- var pt = new Transform;
+ var pt = new Transform();
// each output is the first char of 3 consecutive chunks,
// or whatever's left.
});
test('passthrough event emission reordered', function(t) {
- var pt = new PassThrough;
+ var pt = new PassThrough();
var emits = 0;
pt.on('readable', function() {
- console.error('emit readable', emits)
+ console.error('emit readable', emits);
emits++;
});
test('passthrough facaded', function(t) {
console.error('passthrough facaded');
- var pt = new PassThrough;
+ var pt = new PassThrough();
var datas = [];
pt.on('data', function(chunk) {
datas.push(chunk.toString());
var objects = [
{ foo: 'bar' },
100,
- "string",
- { nested: { things: [ { foo: 'bar' }, 100, "string" ] } }
+ 'string',
+ { nested: { things: [ { foo: 'bar' }, 100, 'string' ] } }
];
var ended = false;
process.nextTick(function() {
t.ok(ended);
t.end();
- })
+ });
});
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;
process.nextTick(function() {
t.ok(ended);
t.end();
- })
+ });
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
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)
};
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));
};
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);
});
});
-process.on('exit', function () {
+process.on('exit', function() {
assert.equal(src1.reads, 2);
assert.equal(src2.reads, 2);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
+'use strict';
var common = require('../common');
var W = require('_stream_writable');
var D = require('_stream_duplex');
fn({
same: assert.deepEqual,
equal: assert.equal,
- end: function () {
+ end: function() {
count--;
run();
}
}
// ensure all tests have run
-process.on("exit", function () {
+process.on('exit', function() {
assert.equal(count, 0);
});
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;
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() {
writeCalledback = true;
});
- tw.end(function () {
+ tw.end(function() {
t.equal(writeCalledback, true);
t.end();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// verify that the string decoder works getting 1 byte at a time,
// the whole buffer at once, and that both match the .toString(enc)
// result of the entire buffer.
+'use strict';
var common = require('../common');
var assert = require('assert');
var StringDecoder = require('string_decoder').StringDecoder;
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);
}
});
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;
}
function writeSequences(length, start, sequence) {
if (start === undefined) {
start = 0;
- sequence = []
+ sequence = [];
} else if (start === length) {
return [sequence];
}
+'use strict';
var common = require('../common');
var assert = require('assert');
// minimum string size to overflow into external string space
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);
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?
}
})();
-(function () {
+(function() {
for (var j = 0; j < RADIOS * 2; j += 1) {
var datum = b;
var slice = datum.slice(0, PRE_3OF4_APEX + j);
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) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var t = new (process.binding('timer_wrap').Timer);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var L = require('_linklist');
+'use strict';
/*
* This test makes sure that non-integer timer delays do not make the process
* hang. See https://github.com/joyent/node/issues/8065 and
+'use strict';
var common = require('../common');
var assert = require('assert');
var Timer = process.binding('timer_wrap').Timer;
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
+'use strict';
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var Timer = process.binding('timer_wrap').Timer;
+'use strict';
var assert = require('assert');
var called = 0;
+'use strict';
var common = require('../common');
var assert = require('assert');
})();
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_callbacks, 1, 'Callback should only run once');
+ 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_callbacks, 1,
+ 'Callback should only run once');
});
+'use strict';
/*
* This test is a regression test for joyent/node#8900.
*/
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
assert.equal(cert.subjectaltname,
'DNS:google.com\0.evil.com, ' +
'DNS:just-another.com, ' +
- 'IP Address:8.8.8.8, '+
- 'IP Address:8.8.4.4, '+
+ 'IP Address:8.8.8.8, ' +
+ 'IP Address:8.8.4.4, ' +
'DNS:last.com');
c.write('ok');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
key: loadPEM('agent2-key'),
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');
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var common = require('../common');
tls.createSecureContext = function(options) {
ciphers = options.ciphers;
throw new Done();
- }
+ };
try {
var s = tls.connect(common.PORT);
+'use strict';
// Create an ssl server. First connection, validate that not resume.
// Cache session and close connection. Use session on second connection.
// ASSERT resumption.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Create an ssl server. First connection, validate that not resume.
// Cache session and close connection. Use session on second connection.
// ASSERT resumption.
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
if (!common.hasCrypto) {
// Error: Hostname/IP doesn't match certificate's altnames:
// "Host: undefined. is not cert's CN: localhost"
}, function() {
- assert(socket.authorized);
- process.exit();
+ assert(socket.authorized);
+ process.exit();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var assert = require('assert'),
fs = require('fs'),
path = require('path'),
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
}
});
- client.on('close', function (hadError) {
+ client.on('close', function(hadError) {
assert.strictEqual(hadError, true, 'Client never errored');
});
});
+'use strict';
var common = require('../common');
var assert = require('assert');
};
// 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,
});
// 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,
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();
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
if (!common.hasCrypto) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
if (!common.hasCrypto) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
if (!process.features.tls_npn) {
console.error('Skipping because node compiled without OpenSSL or ' +
'with old OpenSSL version.');
+'use strict';
var common = require('../common');
if (!process.features.tls_ocsp) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
if (!common.opensslCli) {
+'use strict';
var common = require('../common');
if (!common.opensslCli) {
+'use strict';
var common = require('../common');
if (!common.opensslCli) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
if (!process.features.tls_sni) {
console.error('Skipping because node compiled without OpenSSL or ' +
'with old OpenSSL version.');
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']);
});
+'use strict';
if (!process.features.tls_sni) {
console.error('Skipping because node compiled without OpenSSL or ' +
'with old OpenSSL version.');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
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) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Can't test this when 'make test' doesn't assign a tty to the stdout.
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+/* eslint-disable max-len */
+'use strict';
var common = require('../common');
var assert = require('assert');
'http://bucket_name.s3.amazonaws.com/image.jpg': {
protocol: 'http:',
- 'slashes': true,
slashes: true,
host: 'bucket_name.s3.amazonaws.com',
hostname: 'bucket_name.s3.amazonaws.com',
};
for (var u in parseTests) {
- var actual = url.parse(u),
- spaced = url.parse(' \t ' + u + '\n\t');
- expected = parseTests[u];
+ var actual = url.parse(u);
+ var spaced = url.parse(' \t ' + u + '\n\t');
+ var 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;
}
query: {
foo: 'theA1'
},
- hash: "#bar"
+ hash: '#bar'
},
// `#`,`?` in path + `#` in query
query: {
foo: 'the#1'
},
- hash: "#bar"
+ hash: '#bar'
},
// `?` and `#` in path and search
['g?y#s', bases[0], 'http://a/b/c/g?y#s'],
[';x', bases[0], 'http://a/b/c/;x'],
['g;x', bases[0], 'http://a/b/c/g;x'],
- ['g;x?y#s' , bases[0], 'http://a/b/c/g;x?y#s'],
+ ['g;x?y#s', bases[0], 'http://a/b/c/g;x?y#s'],
// changed with RFC 2396bis
//('', bases[0], CURRENT_DOC_URI],
['', bases[0], 'http://a/b/c/d;p?q'],
['../g', bases[0], 'http://a/b/g'],
['../..', bases[0], 'http://a/'],
['../../', bases[0], 'http://a/'],
- ['../../g' , bases[0], 'http://a/g'],
+ ['../../g', bases[0], 'http://a/g'],
['../../../g', bases[0], ('http://a/../g', 'http://a/g')],
['../../../../g', bases[0], ('http://a/../../g', 'http://a/g')],
// changed with RFC 2396bis
//('?y', bases[1], 'http://a/b/c/?y'],
['?y', bases[1], 'http://a/b/c/d;p?y'],
['g?y', bases[1], 'http://a/b/c/g?y'],
- ['g?y/./x' , bases[1], 'http://a/b/c/g?y/./x'],
+ ['g?y/./x', bases[1], 'http://a/b/c/g?y/./x'],
['g?y/../x', bases[1], 'http://a/b/c/g?y/../x'],
['g#s', bases[1], 'http://a/b/c/g#s'],
- ['g#s/./x' , bases[1], 'http://a/b/c/g#s/./x'],
+ ['g#s/./x', bases[1], 'http://a/b/c/g#s/./x'],
['g#s/../x', bases[1], 'http://a/b/c/g#s/../x'],
['./', bases[1], 'http://a/b/c/'],
['../', bases[1], 'http://a/b/'],
['../g', bases[1], 'http://a/b/g'],
['../../', bases[1], 'http://a/'],
- ['../../g' , bases[1], 'http://a/g'],
+ ['../../g', bases[1], 'http://a/g'],
// http://gbiv.com/protocols/uri/test/rel_examples3.html
// slashes in path params
['../', bases[2], 'http://a/b/c/'],
['../g', bases[2], 'http://a/b/c/g'],
['../../', bases[2], 'http://a/b/'],
- ['../../g' , bases[2], 'http://a/b/g'],
+ ['../../g', bases[2], 'http://a/b/g'],
// http://gbiv.com/protocols/uri/test/rel_examples4.html
// double and triple slash, unknown scheme
['../g', bases[3], 'fred:///s//a/g'],
['../../', bases[3], 'fred:///s//'],
- ['../../g' , bases[3], 'fred:///s//g'],
+ ['../../g', bases[3], 'fred:///s//g'],
['../../../g', bases[3], 'fred:///s/g'],
// may change to fred:///s//a/../../../g
['../../../../g', bases[3], 'fred:///g'],
['../', bases[4], 'http:///s//a/'],
['../g', bases[4], 'http:///s//a/g'],
['../../', bases[4], 'http:///s//'],
- ['../../g' , bases[4], 'http:///s//g'],
+ ['../../g', bases[4], 'http:///s//g'],
// may change to http:///s//a/../../g
['../../../g', bases[4], 'http:///s/g'],
// may change to http:///s//a/../../../g
true,
false,
0,
- function () {}
+ function() {}
];
for (var i = 0; i < throws.length; i++) {
- assert.throws(function () { url.format(throws[i]); }, TypeError);
+ assert.throws(function() { url.format(throws[i]); }, TypeError);
};
assert(url.format('') === '');
assert(url.format({}) === '');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
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, 'message',
+ { value: msg, enumerable: false });
+ Object.defineProperty(this, 'name',
+ { value: 'CustomError', enumerable: false });
}
util.inherits(CustomError, Error);
assert.equal(util.format(new CustomError('bar')), '[CustomError: bar]');
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
'\\\\': 2,
'\\\\\\': 3,
'\\\\\\\\': 4,
-}
+};
var y = ['a', 'b', 'c'];
y['\\\\\\'] = 'd';
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);
test_color_style('null', null);
test_color_style('string', 'test string');
-test_color_style('date', new Date);
+test_color_style('date', new Date());
test_color_style('regexp', /regexp/);
// an object with "hasOwnProperty" overwritten should not throw
// "customInspect" option can enable/disable calling inspect() on objects
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: false }).indexOf('123') === -1);
-assert(util.inspect(subject, { customInspect: false }).indexOf('inspect') !== -1);
+assert(util.inspect(subject,
+ { customInspect: true }).indexOf('123') !== -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);
// custom inspect() functions should be able to return other Objects
subject.inspect = function() { return { foo: 'bar' }; };
function test_lines(input) {
var count_lines = function(str) {
return (str.match(/\n/g) || []).length;
- }
+ };
var without_color = util.inspect(input);
var with_color = util.inspect(input, {colors: true});
subject[Symbol('symbol')] = 42;
assert.equal(util.inspect(subject), '[ 1, 2, 3 ]');
- assert.equal(util.inspect(subject, options), '[ 1, 2, 3, [length]: 3, [Symbol(symbol)]: 42 ]');
+ assert.equal(util.inspect(subject, options),
+ '[ 1, 2, 3, [length]: 3, [Symbol(symbol)]: 42 ]');
}
// test Set
-assert.equal(util.inspect(new Set), 'Set {}');
+assert.equal(util.inspect(new Set()), 'Set {}');
assert.equal(util.inspect(new Set([1, 2, 3])), 'Set { 1, 2, 3 }');
var set = new Set(['foo']);
set.bar = 42;
assert.equal(util.inspect(set, true), 'Set { \'foo\', [size]: 1, bar: 42 }');
// test Map
-assert.equal(util.inspect(new Map), 'Map {}');
+assert.equal(util.inspect(new Map()), 'Map {}');
assert.equal(util.inspect(new Map([[1, 'a'], [2, 'b'], [3, 'c']])),
'Map { 1 => \'a\', 2 => \'b\', 3 => \'c\' }');
var map = new Map([['foo', null]]);
// a bonafide native Promise.
var oldPromise = Promise;
global.Promise = function() { this.bar = 42; };
-assert.equal(util.inspect(new Promise), '{ bar: 42 }');
+assert.equal(util.inspect(new Promise()), '{ bar: 42 }');
global.Promise = oldPromise;
return obj;
}());
checkAlignment(new Set(big_array));
-checkAlignment(new Map(big_array.map(function (y) { return [y, null] })));
+checkAlignment(new Map(big_array.map(function(y) { return [y, null]; })));
+'use strict';
var assert = require('assert');
var util = require('util');
{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 ]'}
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
assert.equal(false, util.isArray({}));
assert.equal(false, util.isArray({ push: function() {} }));
assert.equal(false, util.isArray(/regexp/));
-assert.equal(false, util.isArray(new Error));
+assert.equal(false, util.isArray(new Error()));
assert.equal(false, util.isArray(Object.create(Array.prototype)));
// isRegExp
assert.equal(false, util.isDate(Date()));
assert.equal(false, util.isDate({}));
assert.equal(false, util.isDate([]));
-assert.equal(false, util.isDate(new Error));
+assert.equal(false, util.isDate(new Error()));
assert.equal(false, util.isDate(Object.create(Date.prototype)));
// isError
-assert.equal(true, util.isError(new Error));
-assert.equal(true, util.isError(new TypeError));
-assert.equal(true, util.isError(new SyntaxError));
+assert.equal(true, util.isError(new Error()));
+assert.equal(true, util.isError(new TypeError()));
+assert.equal(true, util.isError(new SyntaxError()));
assert.equal(true, util.isError(new (context('Error'))));
assert.equal(true, util.isError(new (context('TypeError'))));
assert.equal(true, util.isError(new (context('SyntaxError'))));
// isPrimitive
assert.equal(false, util.isPrimitive({}));
-assert.equal(false, util.isPrimitive(new Error));
+assert.equal(false, util.isPrimitive(new Error()));
assert.equal(false, util.isPrimitive(new Date()));
assert.equal(false, util.isPrimitive([]));
assert.equal(false, util.isPrimitive(/regexp/));
-assert.equal(false, util.isPrimitive(function(){}));
+assert.equal(false, util.isPrimitive(function() {}));
assert.equal(false, util.isPrimitive(new Number(1)));
assert.equal(false, util.isPrimitive(new String('bla')));
assert.equal(false, util.isPrimitive(new Boolean(true)));
// inherits
var ctor = function() {};
-assert.throws(function() { util.inherits(ctor, {}) }, TypeError);
-assert.throws(function() { util.inherits(ctor, null) }, TypeError);
-assert.throws(function() { util.inherits(null, ctor) }, TypeError);
-assert.doesNotThrow(function() { util.inherits(ctor, ctor) }, TypeError);
+assert.throws(function() { util.inherits(ctor, {}); }, TypeError);
+assert.throws(function() { util.inherits(ctor, null); }, TypeError);
+assert.throws(function() { util.inherits(null, ctor); }, TypeError);
+assert.doesNotThrow(function() { util.inherits(ctor, ctor); }, TypeError);
+'use strict';
var common = require('../common');
var assert = require('assert');
var v8 = require('v8');
-assert.throws(function() {v8.setFlagsFromString(1)}, TypeError);
-assert.throws(function() {v8.setFlagsFromString()}, TypeError);
+assert.throws(function() {v8.setFlagsFromString(1);}, TypeError);
+assert.throws(function() {v8.setFlagsFromString();}, TypeError);
+'use strict';
var common = require('../common');
var assert = require('assert');
var v8 = require('v8');
assert(vm.runInThisContext('%_IsSmi(42)'));
v8.setFlagsFromString('--noallow_natives_syntax');
-assert.throws(function() { eval('%_IsSmi(42)') }, SyntaxError);
-assert.throws(function() { vm.runInThisContext('%_IsSmi(42)') }, SyntaxError);
+assert.throws(function() { eval('%_IsSmi(42)'); }, SyntaxError);
+assert.throws(function() { vm.runInThisContext('%_IsSmi(42)'); }, SyntaxError);
+'use strict';
var common = require('../common');
var assert = require('assert');
var v8 = require('v8');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
assert.equal('lala', context.thing);
// Issue GH-227:
-assert.throws(function () {
+assert.throws(function() {
vm.runInNewContext('', null, 'some.js');
}, TypeError);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
});
assert.doesNotThrow(function() {
- var sandbox = {};
- vm.createContext(sandbox);
- vm.createContext(sandbox);
+ var sandbox = {};
+ vm.createContext(sandbox);
+ vm.createContext(sandbox);
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
var ctx = vm.createContext(global);
assert.doesNotThrow(function() {
- vm.runInContext("!function() { var x = console.log; }()", ctx);
+ vm.runInContext('!function() { var x = console.log; }()', ctx);
});
+/* eslint-disable no-debugger */
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
// 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');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
// Flags: --harmony_proxies
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
var Script = require('vm').Script;
console.error('undefined reference');
var error;
script = new Script('foo.bar = 5;');
-assert.throws(function () {
+assert.throws(function() {
script.runInNewContext();
}, /not defined/);
console.error('call a function by reference');
script = new Script('f()');
-function changeFoo() { foo = 100 }
+function changeFoo() { foo = 100; }
script.runInNewContext({ f: changeFoo });
assert.equal(foo, 100);
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
var Script = require('vm').Script;
assert.equal(1, foo);
console.error('call a function');
-f = function() { foo = 100 };
+f = function() { foo = 100; };
script = new Script('f()');
script.runInThisContext(script);
assert.equal(100, foo);
+/* eslint-disable strict */
// Flags: --expose-gc
var common = require('../common');
assert.equal(2, foo);
console.error('call a function by reference');
-function changeFoo() { foo = 100 }
+function changeFoo() { foo = 100; }
vm.runInNewContext('f()', { f: changeFoo });
assert.equal(foo, 100);
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
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
assert.equal(1, foo);
console.error('call a function');
-f = function() { foo = 100 };
+f = function() { foo = 100; };
vm.runInThisContext('f()');
assert.equal(100, foo);
+'use strict';
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
+'use strict';
/*
* Tests to verify we're writing doubles correctly
*/
+'use strict';
/*
* Tests to verify we're writing floats correctly
*/
+'use strict';
/*
* Tests to verify we're writing signed integers correctly
*/
+'use strict';
/*
* A battery of tests to help us read a series of uints
*/
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+/* eslint-disable strict */
var common = require('../common');
var assert = require('assert');
+'use strict';
// test convenience methods with and without options supplied
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+'use strict';
// test compression/decompression with dictionary
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+'use strict';
// test unzipping a file that was created with a non-node gzip lib,
// piped in as fast as possible.
+'use strict';
// test compressing and uncompressing a string with zlib
var common = require('../common');
+'use strict';
// test uncompressing invalid input
var common = require('../common'),
zlib.Inflate(),
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
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+'use strict';
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) {
+'use strict';
var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
+'use strict';
var assert = require('assert');
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
// The tests below should throw an error, not abort the process...
-assert.throws(function() { new Buffer(0x3fffffff + 1) }, RangeError);
-assert.throws(function() { new Int8Array(0x3fffffff + 1) }, RangeError);
-assert.throws(function() { new ArrayBuffer(0x3fffffff + 1) }, RangeError);
-assert.throws(function() { new Float64Array(0x7ffffff + 1) }, RangeError);
+assert.throws(function() { new Buffer(0x3fffffff + 1); }, RangeError);
+assert.throws(function() { new Int8Array(0x3fffffff + 1); }, RangeError);
+assert.throws(function() { new ArrayBuffer(0x3fffffff + 1); }, RangeError);
+assert.throws(function() { new Float64Array(0x7ffffff + 1); }, RangeError);
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
});
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');
}
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var os = require('os');
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);
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);
+'use strict';
var common = require('../common');
var assert = require('assert');
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';
}
+'use strict';
var common = require('../common');
var assert = require('assert');
}
}
-makeFile(function () {
+makeFile(function() {
fs.readFile(filename, function(err) {
assert.ok(err, 'should get RangeError');
assert.equal(err.name, 'RangeError', 'should get RangeError');
});
});
-process.on('uncaughtException', function (err) {
+process.on('uncaughtException', function(err) {
assert.ok(!err, 'should not throw uncaughtException');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
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);
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
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);
}
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
process.on('exit', cleanup);
cleanup();
-try { fs.mkdirSync(testsubdir, 0700); } catch (e) {}
+try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
// Need a grace period, else the mkdirSync() above fires off an event.
setTimeout(function() {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
// 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.
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
if (process.platform === 'win32') {
console.log('skipping this test because there is no wrk on windows');
process.exit(0);
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'}));
//console.log(comm, args.join(' '));
+'use strict';
// verify that connect reqs are properly cleaned up
var common = require('../common');
+'use strict';
// Flags: --expose-gc
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
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();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
socket.on('timeout', function() {
console.log('server timeout');
- timeouttime = new Date;
+ timeouttime = new Date();
console.dir(timeouttime);
socket.destroy();
});
if (exchanges == 5) {
console.log('wait for timeout - should come in ' + timeout + ' ms');
- starttime = new Date;
+ starttime = new Date();
console.dir(starttime);
}
}
+'use strict';
// socket.write was not resetting the timeout timer. See
// https://github.com/joyent/node/issues/2002
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Flags: --expose_gc
function newBuffer(size, value) {
+'use strict';
// Flags: --expose_gc
var common = require('../common');
+'use strict';
// Uploading a big file via HTTPS causes node to drop out of the event loop.
// https://github.com/joyent/node/issues/892
// In this test we set up an HTTPS in this process and launch a subprocess
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
// Test that having a bunch of streams piping in parallel
// doesn't break anything.
+'use strict';
var common = require('../common');
var R = require('_stream_readable');
var assert = require('assert');
same: assert.deepEqual,
ok: assert,
equal: assert.equal,
- end: function () {
+ end: function() {
count--;
run();
}
}
// ensure all tests have run
-process.on("exit", function () {
+process.on('exit', function() {
assert.equal(count, 0);
});
'xxxxx',
'xxxxx',
'xxxxx',
- 'xxxxx' ]
+ 'xxxxx' ];
- var w = new TestWriter;
+ var w = new TestWriter();
var flush = true;
w.on('end', function(received) {
-[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);
// both writers should get the same exact data.
test('multipipe', function(t) {
var r = new TestReader(5);
- var w = [ new TestWriter, new TestWriter ];
+ var w = [ new TestWriter(), new TestWriter() ];
var expect = [ 'xxxxx',
'xxxxx',
});
-[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);
});
});
-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;
- }
+ };
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);
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) {
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
clearInterval(null);
assert.equal(true, setTimeout instanceof Function);
-var starttime = new Date;
+var starttime = new Date();
setTimeout(function() {
- var endtime = new Date;
+ var endtime = new Date();
var diff = endtime - starttime;
assert.ok(diff > 0);
setInterval(function() {
interval_count += 1;
- var endtime = new Date;
+ var endtime = new Date( );
var diff = endtime - starttime;
assert.ok(diff > 0);
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
// Flags: --expose-gc
var common = require('../common');
+'use strict';
//
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
if (!common.opensslCli) {
// 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);
// Expects a callback -- cb(connectionType : enum ['New'|'Reused'])
- var Client = function (cb) {
+ var Client = function(cb) {
var flags = [
's_client',
'-connect', 'localhost:' + common.PORT,
});
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];
assert(connectionType === 'New');
Client(function(connectionType) {
assert(connectionType === 'Reused');
- setTimeout(function () {
+ setTimeout(function() {
Client(function(connectionType) {
assert(connectionType === 'New');
server.close();
+'use strict';
// Server sends a large string. Client counts bytes and pauses every few
// seconds. Makes sure that pause and resume work properly.
+'use strict';
// Flags: --max_old_space_size=32
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.');
assert.throws(function() { process.chdir(); }, TypeError, 'Bad argument.');
-assert.throws(function() { process.chdir("x", "y"); }, TypeError, 'Bad argument.');
+assert.throws(function() { process.chdir('x', 'y'); },
+ TypeError, 'Bad argument.');
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var util = require('util');
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() {
+'use strict';
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
+'use strict';
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
+'use strict';
// Flags: --debugger
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var execFile = require('child_process').execFile;
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');
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
try { fs.rmdirSync(testsubdir); } catch (e) { }
};
- try { fs.mkdirSync(testsubdir, 0700); } catch (e) {}
+ try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
assert.doesNotThrow(function() {
var watcher = fs.watch(testDir, {recursive: true});
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
assert.doesNotThrow(
function() {
- var watcher = fs.watch(filepathOne)
+ var watcher = fs.watch(filepathOne);
watcher.on('change', function(event, filename) {
assert.equal('change', event);
}, 20);
try { fs.unlinkSync(filepathThree); } catch (e) {}
-try { fs.mkdirSync(testsubdir, 0700); } catch (e) {}
+try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
assert.doesNotThrow(
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();
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
(function() {
var assert = require('assert'),
child = require('child_process'),
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var mkdir_error = false;
var rmdir_error = false;
-fs.mkdir(d, 0666, function(err) {
+fs.mkdir(d, 0o666, function(err) {
if (err) {
console.log('mkdir error: ' + err.message);
mkdir_error = true;
} else {
- fs.mkdir(d, 0666, function(err) {
+ fs.mkdir(d, 0o666, function(err) {
console.log('expect EEXIST error: ', err);
assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message');
assert.equal(err.code, 'EEXIST', 'got EEXIST code');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
assert.equal(true, common.indirectInstanceOf(d4.D, Function));
assert.equal('D', d4.D());
-assert.ok((new a.SomeClass) instanceof c.SomeClass);
+assert.ok((new a.SomeClass()) instanceof c.SomeClass);
common.debug('test index.js modules ids and relative loading');
var one = require('../fixtures/nested-index/one'),
var my_path = require('../fixtures/path');
assert.ok(common.indirectInstanceOf(my_path.path_func, Function));
// this one does not exist and should throw
-assert.throws(function() { require('./utils')});
+assert.throws(function() { require('./utils'); });
var errorThrown = false;
try {
// 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;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
}).on('connect', function() {
assert.strictEqual(client.localPort, common.PORT + 1);
});
-})
+});
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
// 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);
// 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);
// 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);
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
// 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();
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var net = require('net'),
cp = require('child_process'),
// Block the event loop for 1 second
var start = (new Date()).getTime();
- while ((new Date).getTime() < start + 1000) {}
+ while ((new Date()).getTime() < start + 1000) {}
client.write(alittle);
+'use strict';
// Open a chain of five Node processes each a child of the next. The final
// process exits immediately. Each process in the chain is instructed to
// exit when its child exits.
console.error('gen=%d, pid=%d', gen, process.pid);
/*
-var timer = setTimeout(function () {
+var timer = setTimeout(function() {
throw new Error('timeout! gen='+gen);
}, 1000);
*/
+'use strict';
var path = require('path');
var assert = require('assert');
var spawn = require('child_process').spawn;
+'use strict';
// This test is only relevant on Windows.
if (process.platform !== 'win32') {
return process.exit(0);
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);
+'use strict';
var common = require('../common'),
assert = require('assert'),
fs = require('fs'),
+'use strict';
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
// https://github.com/joyent/node/issues/4948
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();
// 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) {
+ var r = http.request({hostname: 'localhost',
+ port: common.PORT}, function(res) {
// required, just needs to be in the client response somewhere
- serverRes.end();
+ serverRes.end();
// required for test to fail
res.on('data', function(data) { });
+'use strict';
// Just test that destroying stdin doesn't mess up listening on a server.
// This is a regression test for GH-746.
+'use strict';
// Regression test for GH-784
// https://github.com/joyent/node/issues/784
//
+'use strict';
var common = require('../common');
var net = require('net');
var assert = require('assert');
+'use strict';
var common = require('../common');
var http = require('http');
var assert = require('assert');
+'use strict';
// We've experienced a regression where the module loader stats a bunch of
// directories on require() even if it's been called before. The require()
// should caching the request.
+'use strict';
// Original test written by Jakub Lekstan <kuebzky@gmail.com>
// FIXME add sunos support
+'use strict';
// This test is to assert that we can SIGINT a script which loops forever.
// Ref(http):
// groups.google.com/group/nodejs-dev/browse_thread/thread/e20f2f8df0296d3f
+'use strict';
var common = require('../common');
var assert = require('assert');
serverData += c;
});
sock.on('end', function() {
- gotServerEnd = true
+ gotServerEnd = true;
sock.write(serverData);
sock.end();
});
+'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
serverData += c;
});
sock.on('end', function() {
- gotServerEnd = true
+ gotServerEnd = true;
sock.end(serverData);
server.close();
});
+'use strict';
// This tests that pausing and resuming stdin does not hang and timeout
// when done in a child process. See test/simple/test-stdin-pause-resume.js
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var join = require('path').join;
+'use strict';
// This tests that piping stdin will cause it to resume() as well.
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var R = require('_stream_readable');
var assert = require('assert');
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();
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');
+'use strict';
var common = require('../common');
var assert = require('assert');
var http = require('http');
+'use strict';
// Make sure that sync writes to stderr get processed before exiting.
var common = require('../common');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var common = require('../common');
var assert = require('assert');
var TCP = process.binding('tcp_wrap').TCP;
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
+'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
+'use strict';
var assert = require('assert');
var vm = require('vm');
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'
+ 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' +
'j;';
var ctx = vm.createContext({
+'use strict';
// Serving up a zero-length buffer should work.
var common = require('../common');
+'use strict';
// FaketimeFlags: --exclude-monotonic -f '2014-07-21 09:00:00'
var common = require('../common');
*/
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);
:jslint
if not defined jslint goto exit
echo running jslint
-%config%\iojs tools\eslint\bin\eslint.js src lib --reset --quiet
+%config%\iojs tools\eslint\bin\eslint.js src lib test --reset --quiet
goto exit
:create-msvs-files-failed