parent
627f379f22
commit
87286cc737
@ -256,7 +256,7 @@ Client.prototype.req = function(req, cb) {
|
||||
|
||||
|
||||
Client.prototype.reqVersion = function(cb) {
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.req({ command: 'version' } , function(err, body, res) {
|
||||
if (err) return cb(err);
|
||||
cb(null, res.body.body.V8Version, res.body.running);
|
||||
@ -276,7 +276,7 @@ Client.prototype.reqLookup = function(refs, cb) {
|
||||
}
|
||||
};
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.req(req, function(err, res) {
|
||||
if (err) return cb(err);
|
||||
for (var ref in res) {
|
||||
@ -285,7 +285,7 @@ Client.prototype.reqLookup = function(refs, cb) {
|
||||
}
|
||||
}
|
||||
|
||||
cb(null, res);
|
||||
cb(null, res);
|
||||
});
|
||||
};
|
||||
|
||||
@ -296,7 +296,7 @@ Client.prototype.reqScopes = function(cb) {
|
||||
arguments: {}
|
||||
};
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.req(req, function(err, res) {
|
||||
if (err) return cb(err);
|
||||
var refs = res.scopes.map(function(scope) {
|
||||
@ -328,7 +328,7 @@ Client.prototype.reqEval = function(expression, cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
// Otherwise we need to get the current frame to see which scopes it has.
|
||||
this.reqBacktrace(function(err, bt) {
|
||||
if (err || !bt.frames) {
|
||||
@ -361,7 +361,7 @@ Client.prototype._reqFramesEval = function(expression, evalFrames, cb) {
|
||||
var self = this;
|
||||
var i = evalFrames.shift();
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.reqFrameEval(expression, i, function(err, res) {
|
||||
if (!err) return cb(null, res);
|
||||
self._reqFramesEval(expression, evalFrames, cb);
|
||||
@ -382,7 +382,7 @@ Client.prototype.reqFrameEval = function(expression, frame, cb) {
|
||||
req.arguments.frame = frame;
|
||||
}
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.req(req, function(err, res) {
|
||||
if (!err) self._addHandle(res);
|
||||
cb(err, res);
|
||||
@ -415,7 +415,7 @@ Client.prototype.reqBacktrace = function(cb) {
|
||||
//
|
||||
Client.prototype.reqScripts = function(cb) {
|
||||
var self = this;
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
|
||||
this.req({ command: 'scripts' } , function(err, res) {
|
||||
if (err) return cb(err);
|
||||
@ -502,7 +502,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
|
||||
return p.ref;
|
||||
});
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.reqLookup(propertyRefs, function(err, res) {
|
||||
if (err) {
|
||||
console.error('problem with reqLookup');
|
||||
@ -581,7 +581,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
|
||||
Client.prototype.fullTrace = function(cb) {
|
||||
var self = this;
|
||||
|
||||
cb = cb || function () {};
|
||||
cb = cb || function() {};
|
||||
this.reqBacktrace(function(err, trace) {
|
||||
if (err) return cb(err);
|
||||
if (trace.totalFrames <= 0) return cb(Error('No frames'));
|
||||
@ -641,7 +641,7 @@ var commands = [
|
||||
'out (o)',
|
||||
'backtrace (bt)',
|
||||
'setBreakpoint (sb)',
|
||||
'clearBreakpoint (cb)',
|
||||
'clearBreakpoint (cb)'
|
||||
],
|
||||
[
|
||||
'watch',
|
||||
@ -799,7 +799,7 @@ function Interface(stdin, stdout, args) {
|
||||
self.resume();
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Stream control
|
||||
@ -882,7 +882,7 @@ Interface.prototype.handleBreak = function(r) {
|
||||
this.print(SourceInfo(r));
|
||||
|
||||
// Show watchers' values
|
||||
this.watchers(true, function (err) {
|
||||
this.watchers(true, function(err) {
|
||||
if (err) return self.error(err);
|
||||
|
||||
// And list source
|
||||
@ -1167,9 +1167,9 @@ Interface.prototype.scripts = function() {
|
||||
script.name == client.currentScript ||
|
||||
!script.isNative) {
|
||||
scripts.push(
|
||||
(script.name == client.currentScript ? '* ' : ' ') +
|
||||
id + ': ' +
|
||||
path.basename(script.name)
|
||||
(script.name == client.currentScript ? '* ' : ' ') +
|
||||
id + ': ' +
|
||||
path.basename(script.name)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1572,7 +1572,7 @@ Interface.prototype.trySpawn = function(cb) {
|
||||
});
|
||||
|
||||
client.on('close', function() {
|
||||
self.pause()
|
||||
self.pause();
|
||||
self.print('program terminated');
|
||||
self.resume();
|
||||
self.client = null;
|
||||
|
@ -74,7 +74,7 @@ function truncate(s, n) {
|
||||
|
||||
assert.AssertionError.prototype.toString = function() {
|
||||
if (this.message) {
|
||||
return [ this.name + ':', this.message ].join(' ');
|
||||
return [this.name + ':', this.message].join(' ');
|
||||
} else {
|
||||
return [
|
||||
this.name + ':',
|
||||
@ -122,7 +122,7 @@ assert.fail = fail;
|
||||
|
||||
function ok(value, message) {
|
||||
if (!!!value) fail(value, true, message, '==', assert.ok);
|
||||
};
|
||||
}
|
||||
assert.ok = ok;
|
||||
|
||||
// 5. The equality assertion tests shallow, coercive equality with
|
||||
|
@ -1,20 +1,20 @@
|
||||
// Copyright (c) 2008, Fair Oaks Labs, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
//
|
||||
// * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@ -69,7 +69,7 @@ exports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) {
|
||||
eMax = (1 << eLen) - 1,
|
||||
eBias = eMax >> 1,
|
||||
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
|
||||
i = isBE ? (nBytes-1) : 0,
|
||||
i = isBE ? (nBytes - 1) : 0,
|
||||
d = isBE ? -1 : 1,
|
||||
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
||||
|
||||
@ -84,7 +84,7 @@ exports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) {
|
||||
e--;
|
||||
c *= 2;
|
||||
}
|
||||
if (e+eBias >= 1) {
|
||||
if (e + eBias >= 1) {
|
||||
value += rt / c;
|
||||
} else {
|
||||
value += rt * Math.pow(2, 1 - eBias);
|
||||
|
@ -272,7 +272,7 @@ function setStreamOption(name, index, options) {
|
||||
if (options.customFds[index] === index) {
|
||||
options[name] = null;
|
||||
} else {
|
||||
throw new Error("customFds not yet supported");
|
||||
throw new Error('customFds not yet supported');
|
||||
}
|
||||
} else {
|
||||
options[name] = createPipe();
|
||||
@ -283,9 +283,9 @@ function setStreamOption(name, index, options) {
|
||||
ChildProcess.prototype.spawn = function(options) {
|
||||
var self = this;
|
||||
|
||||
setStreamOption("stdinStream", 0, options);
|
||||
setStreamOption("stdoutStream", 1, options);
|
||||
setStreamOption("stderrStream", 2, options);
|
||||
setStreamOption('stdinStream', 0, options);
|
||||
setStreamOption('stdoutStream', 1, options);
|
||||
setStreamOption('stderrStream', 2, options);
|
||||
|
||||
var r = this._internal.spawn(options);
|
||||
|
||||
@ -304,7 +304,7 @@ ChildProcess.prototype.spawn = function(options) {
|
||||
|
||||
this._internal.close();
|
||||
this._internal = null;
|
||||
throw errnoException("spawn", errno)
|
||||
throw errnoException('spawn', errno);
|
||||
}
|
||||
|
||||
this.pid = this._internal.pid;
|
||||
|
@ -96,7 +96,7 @@ exports.createCredentials = function(options, context) {
|
||||
|
||||
if (options.crl) {
|
||||
if (Array.isArray(options.crl)) {
|
||||
for(var i = 0, len = options.crl.length; i < len; i++) {
|
||||
for (var i = 0, len = options.crl.length; i < len; i++) {
|
||||
c.context.addCRL(options.crl[i]);
|
||||
}
|
||||
} else {
|
||||
@ -162,7 +162,7 @@ exports.createDiffieHellman = function(size_or_key, enc) {
|
||||
return new DiffieHellman(size_or_key, enc);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
exports.pbkdf2 = PBKDF2;
|
||||
|
||||
|
@ -93,15 +93,15 @@ var channel = new dns.Channel({SOCK_STATE_CB: function(socket, read, write) {
|
||||
|
||||
// c-ares invokes a callback either synchronously or asynchronously,
|
||||
// but the dns API should always invoke a callback asynchronously.
|
||||
//
|
||||
//
|
||||
// This function makes sure that the callback is invoked asynchronously.
|
||||
// It returns a function that invokes the callback within nextTick().
|
||||
//
|
||||
//
|
||||
// To avoid invoking unnecessary nextTick(), `immediately` property of
|
||||
// returned function should be set to true after c-ares returned.
|
||||
//
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
//
|
||||
// function someAPI(callback) {
|
||||
// callback = makeAsync(callback);
|
||||
// channel.someAPI(..., callback);
|
||||
|
@ -54,15 +54,15 @@ function symToFamily(family) {
|
||||
|
||||
// c-ares invokes a callback either synchronously or asynchronously,
|
||||
// but the dns API should always invoke a callback asynchronously.
|
||||
//
|
||||
//
|
||||
// This function makes sure that the callback is invoked asynchronously.
|
||||
// It returns a function that invokes the callback within nextTick().
|
||||
//
|
||||
//
|
||||
// To avoid invoking unnecessary nextTick(), `immediately` property of
|
||||
// returned function should be set to true after c-ares returned.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// function someAPI(callback) {
|
||||
// callback = makeAsync(callback);
|
||||
// channel.someAPI(..., callback);
|
||||
@ -193,14 +193,14 @@ function resolver(bindingName) {
|
||||
|
||||
|
||||
var resolveMap = {};
|
||||
exports.resolve4 = resolveMap.A = resolver('queryA');
|
||||
exports.resolve6 = resolveMap.AAAA = resolver('queryAaaa');
|
||||
exports.resolve4 = resolveMap.A = resolver('queryA');
|
||||
exports.resolve6 = resolveMap.AAAA = resolver('queryAaaa');
|
||||
exports.resolveCname = resolveMap.CNAME = resolver('queryCname');
|
||||
exports.resolveMx = resolveMap.MX = resolver('queryMx');
|
||||
exports.resolveNs = resolveMap.NS = resolver('queryNs');
|
||||
exports.resolveTxt = resolveMap.TXT = resolver('queryTxt');
|
||||
exports.resolveSrv = resolveMap.SRV = resolver('querySrv');
|
||||
exports.reverse = resolveMap.PTR = resolver('getHostByAddr');
|
||||
exports.resolveMx = resolveMap.MX = resolver('queryMx');
|
||||
exports.resolveNs = resolveMap.NS = resolver('queryNs');
|
||||
exports.resolveTxt = resolveMap.TXT = resolver('queryTxt');
|
||||
exports.resolveSrv = resolveMap.SRV = resolver('querySrv');
|
||||
exports.reverse = resolveMap.PTR = resolver('getHostByAddr');
|
||||
|
||||
|
||||
exports.resolve = function(domain, type_, callback_) {
|
||||
|
17
lib/fs.js
17
lib/fs.js
@ -194,7 +194,7 @@ fs.closeSync = function(fd) {
|
||||
};
|
||||
|
||||
function modeNum(m, def) {
|
||||
switch(typeof m) {
|
||||
switch (typeof m) {
|
||||
case 'number': return m;
|
||||
case 'string': return parseInt(m, 8);
|
||||
default:
|
||||
@ -447,7 +447,7 @@ fs.fchmodSync = function(fd, mode) {
|
||||
if (constants.hasOwnProperty('O_SYMLINK')) {
|
||||
fs.lchmod = function(path, mode, callback) {
|
||||
callback = callback || noop;
|
||||
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function (err, fd) {
|
||||
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -474,7 +474,7 @@ fs.chmodSync = function(path, mode) {
|
||||
if (constants.hasOwnProperty('O_SYMLINK')) {
|
||||
fs.lchown = function(path, uid, gid, callback) {
|
||||
callback = callback || noop;
|
||||
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function (err, fd) {
|
||||
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
@ -514,7 +514,7 @@ function toUnixTimestamp(time) {
|
||||
// convert to 123.456 UNIX timestamp
|
||||
return time.getTime() / 1000;
|
||||
}
|
||||
throw new Error("Cannot parse time: " + time);
|
||||
throw new Error('Cannot parse time: ' + time);
|
||||
}
|
||||
|
||||
// exported for unit tests, not for public consumption
|
||||
@ -569,7 +569,8 @@ fs.writeFile = function(path, data, encoding_, callback) {
|
||||
if (openErr) {
|
||||
if (callback) callback(openErr);
|
||||
} else {
|
||||
var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data, encoding);
|
||||
var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data,
|
||||
encoding);
|
||||
writeAll(fd, buffer, 0, buffer.length, callback);
|
||||
}
|
||||
});
|
||||
@ -621,7 +622,7 @@ FSWatcher.prototype.start = function(filename, persistent) {
|
||||
|
||||
if (r) {
|
||||
this._handle.close();
|
||||
throw errnoException(errno, "watch")
|
||||
throw errnoException(errno, 'watch');
|
||||
}
|
||||
};
|
||||
|
||||
@ -663,11 +664,11 @@ function StatWatcher() {
|
||||
this._handle = new binding.StatWatcher();
|
||||
|
||||
this._handle.onchange = function(current, previous) {
|
||||
self.emit('change', current, previous);
|
||||
self.emit('change', current, previous);
|
||||
};
|
||||
|
||||
this._handle.onstop = function() {
|
||||
self.emit('stop');
|
||||
self.emit('stop');
|
||||
};
|
||||
}
|
||||
util.inherits(StatWatcher, EventEmitter);
|
||||
|
@ -459,7 +459,7 @@ Socket.prototype._writeOut = function(data, encoding, fd, cb) {
|
||||
|
||||
this.bytesWritten += bytesWritten;
|
||||
|
||||
debug('wrote ' + bytesWritten + ' bytes to socket.')
|
||||
debug('wrote ' + bytesWritten + ' bytes to socket.');
|
||||
debug('[fd, off, len] = ' + JSON.stringify([this.fd, off, len]));
|
||||
|
||||
timers.active(this);
|
||||
@ -509,7 +509,6 @@ Socket.prototype._writeOut = function(data, encoding, fd, cb) {
|
||||
|
||||
Socket.prototype._onBufferChange = function() {
|
||||
// Put DTrace hooks here.
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
|
@ -18,8 +18,8 @@ function createTCP() {
|
||||
|
||||
|
||||
/* Bit flags for socket._flags */
|
||||
var FLAG_GOT_EOF = 1 << 0;
|
||||
var FLAG_SHUTDOWN = 1 << 1;
|
||||
var FLAG_GOT_EOF = 1 << 0;
|
||||
var FLAG_SHUTDOWN = 1 << 1;
|
||||
var FLAG_DESTROY_SOON = 1 << 2;
|
||||
var FLAG_SHUTDOWNQUED = 1 << 3;
|
||||
|
||||
@ -378,7 +378,7 @@ Socket.prototype.write = function(data /* [encoding], [fd], [cb] */) {
|
||||
if (this._connectQueue) {
|
||||
this._connectQueue.push([data, encoding, fd, cb]);
|
||||
} else {
|
||||
this._connectQueue = [ [data, encoding, fd, cb] ];
|
||||
this._connectQueue = [[data, encoding, fd, cb]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -418,7 +418,7 @@ function afterWrite(status, handle, req, buffer) {
|
||||
|
||||
if (req.cb) req.cb();
|
||||
|
||||
if (self._writeRequests.length == 0 && self._flags & FLAG_DESTROY_SOON) {
|
||||
if (self._writeRequests.length == 0 && self._flags & FLAG_DESTROY_SOON) {
|
||||
self.destroy();
|
||||
}
|
||||
}
|
||||
@ -481,7 +481,7 @@ Socket.prototype.connect = function(port /* [host], [cb] */) {
|
||||
connect(self, /*pipe_name=*/port);
|
||||
|
||||
} else if (typeof host == 'string') {
|
||||
debug("connect: find host " + host);
|
||||
debug('connect: find host ' + host);
|
||||
require('dns').lookup(host, function(err, ip, addressType) {
|
||||
// It's possible we were destroyed while looking this up.
|
||||
// XXX it would be great if we could cancel the promise returned by
|
||||
@ -510,7 +510,7 @@ Socket.prototype.connect = function(port /* [host], [cb] */) {
|
||||
});
|
||||
|
||||
} else {
|
||||
debug("connect: missing host");
|
||||
debug('connect: missing host');
|
||||
connect(self, '127.0.0.1', port, 4);
|
||||
}
|
||||
};
|
||||
@ -526,7 +526,7 @@ function afterConnect(status, handle, req) {
|
||||
|
||||
assert.equal(handle, self._handle);
|
||||
|
||||
debug("afterConnect");
|
||||
debug('afterConnect');
|
||||
|
||||
assert.ok(self._connecting);
|
||||
self._connecting = false;
|
||||
@ -553,7 +553,7 @@ function afterConnect(status, handle, req) {
|
||||
self.end();
|
||||
}
|
||||
} else {
|
||||
self._connectQueueCleanUp()
|
||||
self._connectQueueCleanUp();
|
||||
self.destroy(errnoException(errno, 'connect'));
|
||||
}
|
||||
}
|
||||
@ -585,7 +585,7 @@ function Server(/* [ options, ] listener */) {
|
||||
self.on('connection', arguments[0]);
|
||||
} else {
|
||||
options = arguments[0] || {};
|
||||
|
||||
|
||||
if (typeof arguments[1] == 'function') {
|
||||
self.on('connection', arguments[1]);
|
||||
}
|
||||
@ -616,7 +616,7 @@ function listen(self, address, port, addressType) {
|
||||
self._handle.onconnection = onconnection;
|
||||
|
||||
if (address || port) {
|
||||
debug("bind to " + address);
|
||||
debug('bind to ' + address);
|
||||
if (addressType == 6) {
|
||||
r = self._handle.bind6(address, port);
|
||||
} else {
|
||||
@ -693,7 +693,7 @@ function onconnection(clientHandle) {
|
||||
var self = handle.socket;
|
||||
var peername;
|
||||
|
||||
debug("onconnection");
|
||||
debug('onconnection');
|
||||
|
||||
if (!clientHandle) {
|
||||
self.emit('error', errnoException(errno, 'accept'));
|
||||
@ -778,12 +778,13 @@ exports.isIP = function(input) {
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
} else if (/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/.test(input)) {
|
||||
} else if (/^::|^::1|^([a-fA-F0-9]{1,4}::?){1,7}([a-fA-F0-9]{1,4})$/.test(
|
||||
input)) {
|
||||
return 6;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.isIPv4 = function(input) {
|
||||
|
12
lib/path.js
12
lib/path.js
@ -30,7 +30,7 @@ var isWindows = process.platform === 'win32';
|
||||
function normalizeArray(parts, allowAboveRoot) {
|
||||
// if the path tries to go above the root, `up` ends up > 0
|
||||
var up = 0;
|
||||
for (var i = parts.length-1; i >= 0; i--) {
|
||||
for (var i = parts.length - 1; i >= 0; i--) {
|
||||
var last = parts[i];
|
||||
if (last == '.') {
|
||||
parts.splice(i, 1);
|
||||
@ -63,8 +63,8 @@ if (isWindows) {
|
||||
// Regex to split the tail part of the above into [*, dir, basename, ext]
|
||||
var splitTailRe = /^([\s\S]+[\\\/](?!$)|[\\\/])?((?:[\s\S]+?)?(\.[^.]*)?)$/;
|
||||
|
||||
// Function to split a filename into [root, dir, basename, ext]
|
||||
// windows version
|
||||
// Function to split a filename into [root, dir, basename, ext]
|
||||
// windows version
|
||||
var splitPath = function(filename) {
|
||||
// Separate device+slash from tail
|
||||
var result = splitDeviceRe.exec(filename),
|
||||
@ -76,7 +76,7 @@ if (isWindows) {
|
||||
basename = result2[2] || '',
|
||||
ext = result2[3] || '';
|
||||
return [device, dir, basename, ext];
|
||||
}
|
||||
};
|
||||
|
||||
// path.resolve([from ...], to)
|
||||
// windows version
|
||||
@ -85,7 +85,7 @@ if (isWindows) {
|
||||
resolvedTail = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = arguments.length-1; i >= -1; i--) {
|
||||
for (var i = arguments.length - 1; i >= -1; i--) {
|
||||
var path = (i >= 0) ? arguments[i] : process.cwd();
|
||||
|
||||
// Skip empty and invalid entries
|
||||
@ -272,7 +272,7 @@ if (isWindows) {
|
||||
var resolvedPath = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = arguments.length-1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
var path = (i >= 0) ? arguments[i] : process.cwd();
|
||||
|
||||
// Skip empty and invalid entries
|
||||
|
@ -292,7 +292,8 @@ Interface.prototype._tabComplete = function() {
|
||||
var item = group[idx];
|
||||
self.output.write(item);
|
||||
if (col < maxColumns - 1) {
|
||||
for (var s = 0, itemLen = item.length; s < width - itemLen; s++) {
|
||||
for (var s = 0, itemLen = item.length; s < width - itemLen;
|
||||
s++) {
|
||||
self.output.write(' ');
|
||||
}
|
||||
}
|
||||
|
29
lib/repl.js
29
lib/repl.js
@ -110,7 +110,8 @@ function REPLServer(prompt, stream, eval) {
|
||||
this.commands = {};
|
||||
defineDefaultCommands(this);
|
||||
|
||||
if (rli.enabled && !exports.disableColors && exports.writer === util.inspect) {
|
||||
if (rli.enabled && !exports.disableColors &&
|
||||
exports.writer === util.inspect) {
|
||||
// Turn on ANSI coloring.
|
||||
exports.writer = function(obj, showHidden, depth) {
|
||||
return util.inspect(obj, showHidden, depth, true);
|
||||
@ -175,15 +176,15 @@ function REPLServer(prompt, stream, eval) {
|
||||
self.context,
|
||||
'repl',
|
||||
function(e, ret) {
|
||||
if (e && !isSyntaxError(e)) return finish(e);
|
||||
if (e && !isSyntaxError(e)) return finish(e);
|
||||
|
||||
if (typeof ret === 'function' || e) {
|
||||
// Now as statement without parens.
|
||||
self.eval(evalCmd, self.context, 'repl', finish);
|
||||
} else {
|
||||
finish(null, ret);
|
||||
}
|
||||
});
|
||||
if (typeof ret === 'function' || e) {
|
||||
// Now as statement without parens.
|
||||
self.eval(evalCmd, self.context, 'repl', finish);
|
||||
} else {
|
||||
finish(null, ret);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
finish(null);
|
||||
@ -447,11 +448,11 @@ REPLServer.prototype.complete = function(line, callback) {
|
||||
// they just get in the way.
|
||||
if (filter) {
|
||||
completionGroups.push(['break', 'case', 'catch', 'const',
|
||||
'continue', 'debugger', 'default', 'delete', 'do', 'else', 'export',
|
||||
'false', 'finally', 'for', 'function', 'if', 'import', 'in',
|
||||
'instanceof', 'let', 'new', 'null', 'return', 'switch', 'this',
|
||||
'throw', 'true', 'try', 'typeof', 'undefined', 'var', 'void',
|
||||
'while', 'with', 'yield']);
|
||||
'continue', 'debugger', 'default', 'delete', 'do', 'else',
|
||||
'export', 'false', 'finally', 'for', 'function', 'if',
|
||||
'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
|
||||
'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined',
|
||||
'var', 'void', 'while', 'with', 'yield']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ exports.isatty = function(fd) {
|
||||
|
||||
|
||||
exports.setRawMode = function(flag) {
|
||||
assert.ok(stdinHandle, "stdin must be initialized before calling setRawMode");
|
||||
assert.ok(stdinHandle, 'stdin must be initialized before calling setRawMode');
|
||||
stdinHandle.setRawMode(flag);
|
||||
};
|
||||
|
||||
@ -46,7 +46,7 @@ exports.getWindowSize = function() {
|
||||
|
||||
|
||||
exports.setWindowSize = function() {
|
||||
throw new Error("implement me");
|
||||
throw new Error('implement me');
|
||||
};
|
||||
|
||||
|
||||
|
58
lib/util.js
58
lib/util.js
@ -54,7 +54,7 @@ exports.format = function(f) {
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.print = function() {
|
||||
@ -98,7 +98,7 @@ function inspect(obj, showHidden, depth, colors) {
|
||||
var ctx = {
|
||||
showHidden: showHidden,
|
||||
seen: [],
|
||||
stylize: colors ? stylizeWithColor : stylizeNoColor,
|
||||
stylize: colors ? stylizeWithColor : stylizeNoColor
|
||||
};
|
||||
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
||||
}
|
||||
@ -107,31 +107,31 @@ exports.inspect = inspect;
|
||||
|
||||
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
||||
var colors = {
|
||||
'bold' : [1, 22],
|
||||
'italic' : [3, 23],
|
||||
'underline' : [4, 24],
|
||||
'inverse' : [7, 27],
|
||||
'white' : [37, 39],
|
||||
'grey' : [90, 39],
|
||||
'black' : [30, 39],
|
||||
'blue' : [34, 39],
|
||||
'cyan' : [36, 39],
|
||||
'green' : [32, 39],
|
||||
'magenta' : [35, 39],
|
||||
'red' : [31, 39],
|
||||
'yellow' : [33, 39]
|
||||
'bold' : [1, 22],
|
||||
'italic' : [3, 23],
|
||||
'underline' : [4, 24],
|
||||
'inverse' : [7, 27],
|
||||
'white' : [37, 39],
|
||||
'grey' : [90, 39],
|
||||
'black' : [30, 39],
|
||||
'blue' : [34, 39],
|
||||
'cyan' : [36, 39],
|
||||
'green' : [32, 39],
|
||||
'magenta' : [35, 39],
|
||||
'red' : [31, 39],
|
||||
'yellow' : [33, 39]
|
||||
};
|
||||
|
||||
var styles = {
|
||||
'special': 'cyan',
|
||||
'number': 'blue',
|
||||
'boolean': 'yellow',
|
||||
'undefined': 'grey',
|
||||
'null': 'bold',
|
||||
'string': 'green',
|
||||
'date': 'magenta',
|
||||
// "name": intentionally not styling
|
||||
'regexp': 'red'
|
||||
'special': 'cyan',
|
||||
'number': 'blue',
|
||||
'boolean': 'yellow',
|
||||
'undefined': 'grey',
|
||||
'null': 'bold',
|
||||
'string': 'green',
|
||||
'date': 'magenta',
|
||||
// "name": intentionally not styling
|
||||
'regexp': 'red'
|
||||
};
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
||||
for (var i = 0, l = value.length; i < l; ++i) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
String(i), true));
|
||||
String(i), true));
|
||||
} else {
|
||||
output.push('');
|
||||
}
|
||||
@ -290,7 +290,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
||||
keys.forEach(function(key) {
|
||||
if (!key.match(/^\d+$/)) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
key, true));
|
||||
key, true));
|
||||
}
|
||||
});
|
||||
return output;
|
||||
@ -387,19 +387,19 @@ function isArray(ar) {
|
||||
|
||||
function isRegExp(re) {
|
||||
return re instanceof RegExp ||
|
||||
(typeof re === 'object' && objectToString(re) === '[object RegExp]');
|
||||
(typeof re === 'object' && objectToString(re) === '[object RegExp]');
|
||||
}
|
||||
|
||||
|
||||
function isDate(d) {
|
||||
return d instanceof Date ||
|
||||
(typeof d === 'object' && objectToString(d) === '[object Date]');
|
||||
(typeof d === 'object' && objectToString(d) === '[object Date]');
|
||||
}
|
||||
|
||||
|
||||
function isError(e) {
|
||||
return e instanceof Error ||
|
||||
(typeof e === 'object' && objectToString(e) === '[object Error]');
|
||||
(typeof e === 'object' && objectToString(e) === '[object Error]');
|
||||
}
|
||||
|
||||
|
||||
|
14
src/node.js
14
src/node.js
@ -227,7 +227,7 @@
|
||||
case 'TTY':
|
||||
var tty = NativeModule.require('tty');
|
||||
stdout = new tty.WriteStream(fd);
|
||||
stdout._type = "tty";
|
||||
stdout._type = 'tty';
|
||||
|
||||
// Hack to have stdout not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
@ -237,7 +237,7 @@
|
||||
case 'FILE':
|
||||
var fs = NativeModule.require('fs');
|
||||
stdout = new fs.WriteStream(null, {fd: fd});
|
||||
stdout._type = "fs";
|
||||
stdout._type = 'fs';
|
||||
break;
|
||||
|
||||
case 'PIPE':
|
||||
@ -249,7 +249,7 @@
|
||||
// we'll just add this hack and set the `readable` member to false.
|
||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||
stdout.readable = false;
|
||||
stdout._type = "pipe";
|
||||
stdout._type = 'pipe';
|
||||
|
||||
// FIXME Hack to have stdout not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
@ -258,7 +258,7 @@
|
||||
|
||||
default:
|
||||
// Probably an error on in uv_guess_handle()
|
||||
throw new Error("Implement me. Unknown stdout file type!");
|
||||
throw new Error('Implement me. Unknown stdout file type!');
|
||||
}
|
||||
|
||||
// For supporting legacy API we put the FD here.
|
||||
@ -301,7 +301,7 @@
|
||||
|
||||
default:
|
||||
// Probably an error on in uv_guess_handle()
|
||||
throw new Error("Implement me. Unknown stdin file type!");
|
||||
throw new Error('Implement me. Unknown stdin file type!');
|
||||
}
|
||||
|
||||
// For supporting legacy API we put the FD here.
|
||||
@ -403,7 +403,7 @@
|
||||
'mixin': 'process.mixin() has been removed.',
|
||||
'createChildProcess': 'childProcess API has changed. See doc/api.txt.',
|
||||
'inherits': 'process.inherits() has moved to sys.inherits.',
|
||||
'_byteLength': 'process._byteLength() has moved to Buffer.byteLength',
|
||||
'_byteLength': 'process._byteLength() has moved to Buffer.byteLength'
|
||||
};
|
||||
|
||||
startup.removedMethods = function() {
|
||||
@ -498,7 +498,7 @@
|
||||
throw new Error('No such native module ' + id);
|
||||
}
|
||||
|
||||
process.moduleLoadList.push("NativeModule " + id);
|
||||
process.moduleLoadList.push('NativeModule ' + id);
|
||||
|
||||
var nativeModule = new NativeModule(id);
|
||||
|
||||
|
@ -69,7 +69,7 @@ exports.ddCommand = function(filename, kilobytes) {
|
||||
exports.spawnPwd = function(options) {
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
if (process.platform == "win32") {
|
||||
if (process.platform == 'win32') {
|
||||
return spawn('cmd.exe', ['/c', 'cd'], options);
|
||||
} else {
|
||||
return spawn('pwd', [], options);
|
||||
|
@ -31,9 +31,7 @@ req.on('error', function(e) {
|
||||
function loadDom() {
|
||||
// Do a lot of computation to stall the process.
|
||||
// In the meantime the socket will be disconnected.
|
||||
for (var i = 0; i < 1e8; i++) {
|
||||
;
|
||||
}
|
||||
for (var i = 0; i < 1e8; i++);
|
||||
|
||||
console.log('Dom loaded.');
|
||||
}
|
||||
|
@ -22,15 +22,16 @@
|
||||
// libuv-broken
|
||||
|
||||
|
||||
var assert = require("assert");
|
||||
var spawn = require("child_process").spawn;
|
||||
var assert = require('assert');
|
||||
var spawn = require('child_process').spawn;
|
||||
var fs = require('fs');
|
||||
|
||||
var myUid = process.getuid();
|
||||
var myGid = process.getgid();
|
||||
|
||||
if (myUid != 0) {
|
||||
console.error('must be run as root, otherwise the gid/uid setting will fail.');
|
||||
console.error('must be run as root, otherwise the gid/uid setting will' +
|
||||
' fail.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@ -39,9 +40,9 @@ if (myUid != 0) {
|
||||
var passwd = fs.readFileSync('/etc/passwd', 'utf8');
|
||||
passwd = passwd.trim().split(/\n/);
|
||||
|
||||
for (var i = 0, l = passwd.length; i < l; i ++) {
|
||||
if (passwd[i].charAt(0) === "#") continue;
|
||||
passwd[i] = passwd[i].split(":");
|
||||
for (var i = 0, l = passwd.length; i < l; i++) {
|
||||
if (passwd[i].charAt(0) === '#') continue;
|
||||
passwd[i] = passwd[i].split(':');
|
||||
var otherName = passwd[i][0];
|
||||
var otherUid = +passwd[i][2];
|
||||
var otherGid = +passwd[i][3];
|
||||
@ -62,20 +63,20 @@ whoNumber.stdout.buf = 'byNumber:';
|
||||
whoName.stdout.buf = 'byName:';
|
||||
whoNumber.stdout.on('data', onData);
|
||||
whoName.stdout.on('data', onData);
|
||||
function onData (c) { this.buf += c; }
|
||||
function onData(c) { this.buf += c; }
|
||||
|
||||
whoNumber.on("exit", onExit);
|
||||
whoName.on("exit", onExit);
|
||||
whoNumber.on('exit', onExit);
|
||||
whoName.on('exit', onExit);
|
||||
|
||||
function onExit (code) {
|
||||
function onExit(code) {
|
||||
var buf = this.stdout.buf;
|
||||
console.log(buf);
|
||||
var expr = new RegExp("^(byName|byNumber):uid=" +
|
||||
var expr = new RegExp('^(byName|byNumber):uid=' +
|
||||
otherUid +
|
||||
"\\(" +
|
||||
'\\(' +
|
||||
otherName +
|
||||
"\\) gid=" +
|
||||
'\\) gid=' +
|
||||
otherGid +
|
||||
"\\(");
|
||||
assert.ok(buf.match(expr), "uid and gid should match " + otherName);
|
||||
'\\(');
|
||||
assert.ok(buf.match(expr), 'uid and gid should match ' + otherName);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ function mkListener() {
|
||||
if (receivedMessages.length == sendMessages.length) {
|
||||
listenSocket.dropMembership(LOCAL_BROADCAST_HOST);
|
||||
process.nextTick(function() { // TODO should be changed to below.
|
||||
// listenSocket.dropMembership(LOCAL_BROADCAST_HOST, function() {
|
||||
// listenSocket.dropMembership(LOCAL_BROADCAST_HOST, function() {
|
||||
listenSocket.close();
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ var reqEndCount = 0;
|
||||
|
||||
var server = http.Server(function(req, res) {
|
||||
res.writeHead(200);
|
||||
res.end("hello world\n");
|
||||
res.end('hello world\n');
|
||||
|
||||
var buffer = '';
|
||||
|
||||
@ -50,7 +50,7 @@ var responses = 0;
|
||||
var N = 10;
|
||||
var M = 10;
|
||||
|
||||
var body = ''
|
||||
var body = '';
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
body += 'hello world';
|
||||
}
|
||||
@ -63,7 +63,7 @@ var options = {
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
for (var i = 0; i < N; i++) {
|
||||
setTimeout(function () {
|
||||
setTimeout(function() {
|
||||
for (var j = 0; j < M; j++) {
|
||||
|
||||
var req = http.request(options, function(res) {
|
||||
|
@ -58,10 +58,10 @@ var proxy = http.createServer(function(req, res) {
|
||||
}
|
||||
|
||||
var proxy_req = http.request({
|
||||
host: 'localhost',
|
||||
port: 9000,
|
||||
method: req.method,
|
||||
path: req.url,
|
||||
host: 'localhost',
|
||||
port: 9000,
|
||||
method: req.method,
|
||||
path: req.url,
|
||||
headers: req.headers
|
||||
}, function(proxy_res) {
|
||||
res.writeHead(proxy_res.statusCode, proxy_res.headers);
|
||||
@ -96,9 +96,9 @@ function call_chargen(list) {
|
||||
var recved = 0;
|
||||
|
||||
var req = http.request({
|
||||
port: 9001,
|
||||
host: 'localhost',
|
||||
path: '/',
|
||||
port: 9001,
|
||||
host: 'localhost',
|
||||
path: '/',
|
||||
headers: {'x-len': len}
|
||||
}, function(res) {
|
||||
|
||||
|
@ -24,44 +24,44 @@
|
||||
|
||||
// This must be run as root.
|
||||
|
||||
var http = require("http"),
|
||||
https = require("https"),
|
||||
var http = require('http'),
|
||||
https = require('https'),
|
||||
PORT = 80,
|
||||
SSLPORT = 443,
|
||||
assert = require("assert"),
|
||||
hostExpect = "localhost",
|
||||
fs = require("fs"),
|
||||
path = require("path"),
|
||||
fixtures = path.resolve(__dirname, "../fixtures/keys"),
|
||||
assert = require('assert'),
|
||||
hostExpect = 'localhost',
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
fixtures = path.resolve(__dirname, '../fixtures/keys'),
|
||||
options = {
|
||||
key: fs.readFileSync(fixtures + '/agent1-key.pem'),
|
||||
cert: fs.readFileSync(fixtures + '/agent1-cert.pem')
|
||||
};
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
http.createServer(function(req, res) {
|
||||
console.error(req.headers);
|
||||
assert.equal(req.headers.host, hostExpect);
|
||||
res.writeHead(200);
|
||||
res.end("ok");
|
||||
res.end('ok');
|
||||
this.close();
|
||||
}).listen(PORT);
|
||||
|
||||
https.createServer(options, function (req, res) {
|
||||
https.createServer(options, function(req, res) {
|
||||
console.error(req.headers);
|
||||
assert.equal(req.headers.host, hostExpect);
|
||||
res.writeHead(200);
|
||||
res.end("ok");
|
||||
res.end('ok');
|
||||
this.close();
|
||||
}).listen(SSLPORT);
|
||||
|
||||
http
|
||||
.get({ host: "localhost",
|
||||
port: PORT,
|
||||
headers: { "x-port": PORT } })
|
||||
.on("response", function(res) {});
|
||||
.get({ host: 'localhost',
|
||||
port: PORT,
|
||||
headers: { 'x-port': PORT } })
|
||||
.on('response', function(res) {});
|
||||
|
||||
https
|
||||
.get({ host: "localhost",
|
||||
port: SSLPORT,
|
||||
headers: { "x-port": SSLPORT } })
|
||||
.on("response", function(res) {});
|
||||
.get({ host: 'localhost',
|
||||
port: SSLPORT,
|
||||
headers: { 'x-port': SSLPORT } })
|
||||
.on('response', function(res) {});
|
||||
|
@ -46,9 +46,9 @@ var gotEnd = false;
|
||||
|
||||
server.addListener('listening', function() {
|
||||
var request = http.request({
|
||||
port: common.PORT,
|
||||
port: common.PORT,
|
||||
method: 'HEAD',
|
||||
path: '/'
|
||||
path: '/'
|
||||
}, function(response) {
|
||||
console.log('got response');
|
||||
response.addListener('data', function() {
|
||||
|
@ -30,26 +30,26 @@
|
||||
|
||||
var https = require('https');
|
||||
|
||||
for(var i = 0; i < 10; ++i)
|
||||
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);
|
||||
});
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ var fs = require('fs');
|
||||
var body = '';
|
||||
|
||||
process.stdout.write('build body...');
|
||||
for (var i = 0; i < 10*1024*1024; i++) {
|
||||
for (var i = 0; i < 10 * 1024 * 1024; i++) {
|
||||
body += 'hello world\n';
|
||||
}
|
||||
process.stdout.write('done\n');
|
||||
|
@ -38,10 +38,10 @@ var key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString();
|
||||
var cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString();
|
||||
|
||||
s = tls.Server({ key: key,
|
||||
cert: cert,
|
||||
ca: [],
|
||||
requestCert: true,
|
||||
rejectUnauthorized: true });
|
||||
cert: cert,
|
||||
ca: [],
|
||||
requestCert: true,
|
||||
rejectUnauthorized: true });
|
||||
|
||||
s.listen(common.PORT, function() {
|
||||
console.log('TLS server on 127.0.0.1:%d', common.PORT);
|
||||
|
@ -30,13 +30,13 @@ var fs = require('fs');
|
||||
// most servers don't require certificates
|
||||
|
||||
var options = {
|
||||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
||||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem')
|
||||
};
|
||||
|
||||
|
||||
var s = tls.connect(443, "joyent.com", options, function() {
|
||||
var s = tls.connect(443, 'joyent.com', options, function() {
|
||||
if (!s.authorized) {
|
||||
console.error("CONNECTED: " + s.authorizationError);
|
||||
console.error('CONNECTED: ' + s.authorizationError);
|
||||
s.destroy();
|
||||
return;
|
||||
}
|
||||
|
2
test/fixtures/GH-892-request.js
vendored
2
test/fixtures/GH-892-request.js
vendored
@ -38,7 +38,7 @@ var options = {
|
||||
var req = https.request(options, function(res) {
|
||||
assert.equal(200, res.statusCode);
|
||||
gotResponse = true;
|
||||
console.error("DONE");
|
||||
console.error('DONE');
|
||||
});
|
||||
|
||||
req.end(new Buffer(bytesExpected));
|
||||
|
4
test/fixtures/breakpoints.js
vendored
4
test/fixtures/breakpoints.js
vendored
@ -6,10 +6,10 @@ function a(x) {
|
||||
while (--i != 0);
|
||||
debugger;
|
||||
return i;
|
||||
};
|
||||
}
|
||||
function b() {
|
||||
return ['hello', 'world'].join(' ');
|
||||
};
|
||||
}
|
||||
a();
|
||||
a(1);
|
||||
b();
|
||||
|
2
test/fixtures/child-process-channel.js
vendored
2
test/fixtures/child-process-channel.js
vendored
@ -1,6 +1,6 @@
|
||||
var assert = require('assert');
|
||||
|
||||
console.log("NODE_CHANNEL_FD", process.env.NODE_CHANNEL_FD);
|
||||
console.log('NODE_CHANNEL_FD', process.env.NODE_CHANNEL_FD);
|
||||
assert.ok(process.env.NODE_CHANNEL_FD);
|
||||
|
||||
var fd = parseInt(process.env.NODE_CHANNEL_FD);
|
||||
|
2
test/fixtures/node_modules/asdf.js
generated
vendored
2
test/fixtures/node_modules/asdf.js
generated
vendored
@ -20,5 +20,5 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n')+'\n');
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
throw new Error('Should not ever get here.');
|
||||
|
2
test/fixtures/node_modules/bar.js
generated
vendored
2
test/fixtures/node_modules/bar.js
generated
vendored
@ -20,4 +20,4 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n')+'\n');
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
|
2
test/fixtures/node_modules/baz/index.js
generated
vendored
2
test/fixtures/node_modules/baz/index.js
generated
vendored
@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n')+'\n');
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
// this should work, and get the one that doesn't throw
|
||||
var assert = require('assert');
|
||||
assert.equal(require('bar'), require('../bar.js'));
|
||||
|
2
test/fixtures/node_modules/baz/node_modules/asdf.js
generated
vendored
2
test/fixtures/node_modules/baz/node_modules/asdf.js
generated
vendored
@ -20,4 +20,4 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n')+'\n');
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
|
2
test/fixtures/node_modules/foo.js
generated
vendored
2
test/fixtures/node_modules/foo.js
generated
vendored
@ -20,6 +20,6 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n')+'\n');
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
var assert = require('assert');
|
||||
assert.equal(require('baz'), require('./baz/index.js'));
|
||||
|
2
test/fixtures/node_modules/node_modules/bar.js
generated
vendored
2
test/fixtures/node_modules/node_modules/bar.js
generated
vendored
@ -20,5 +20,5 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
console.error(__filename);
|
||||
console.error(module.paths.join('\n')+'\n');
|
||||
console.error(module.paths.join('\n') + '\n');
|
||||
throw new Error('Should not ever get here.');
|
||||
|
@ -19,4 +19,4 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
exports.ok = "ok"
|
||||
exports.ok = 'ok';
|
||||
|
@ -19,4 +19,4 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
exports.ok = "ok"
|
||||
exports.ok = 'ok';
|
||||
|
3
test/fixtures/test-init-index/index.js
vendored
3
test/fixtures/test-init-index/index.js
vendored
@ -21,4 +21,5 @@
|
||||
|
||||
(function() {
|
||||
require('util').print('Loaded successfully!');
|
||||
})();
|
||||
})();
|
||||
|
||||
|
3
test/fixtures/test-init-native/fs.js
vendored
3
test/fixtures/test-init-native/fs.js
vendored
@ -24,4 +24,5 @@
|
||||
if (fs.readFile) {
|
||||
require('util').print('fs loaded successfully');
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var assert = require('assert');
|
||||
var assert = require('assert'),
|
||||
dns = require('dns'),
|
||||
net = require('net_uv');
|
||||
net = require('net_uv'),
|
||||
isIP = net.isIP,
|
||||
isIPv4 = net.isIPv4,
|
||||
isIPv6 = net.isIPv6,
|
||||
@ -149,7 +149,7 @@ TEST(function test_reverse_bogus(done) {
|
||||
var req = dns.reverse('bogus ip', function() {
|
||||
assert.ok(false);
|
||||
});
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
@ -315,7 +315,7 @@ TEST(function test_lookup_ipv6_implicit(done) {
|
||||
TEST(function test_lookup_failure(done) {
|
||||
var req = dns.lookup('does.not.exist', 4, function(err, ip, family) {
|
||||
assert.ok(err instanceof Error);
|
||||
assert.strictEqual(err.errno, dns.NOTFOUND)
|
||||
assert.strictEqual(err.errno, dns.NOTFOUND);
|
||||
uv && assert.strictEqual(err.errno, 'ENOTFOUND');
|
||||
|
||||
done();
|
||||
|
@ -28,6 +28,6 @@ var assert = require('assert');
|
||||
common.error('before');
|
||||
|
||||
// custom error throwing
|
||||
throw { name: 'MyCustomError', message: 'This is a custom message' };
|
||||
throw { name: 'MyCustomError', message: 'This is a custom message' }
|
||||
|
||||
common.error('after');
|
||||
|
@ -28,6 +28,6 @@ var assert = require('assert');
|
||||
common.error('before');
|
||||
|
||||
// custom error throwing
|
||||
throw { foo : 'bar' };
|
||||
throw { foo: 'bar' }
|
||||
|
||||
common.error('after');
|
||||
|
@ -36,7 +36,7 @@ server.on('request', function(req, res) {
|
||||
req.on('end', function() {
|
||||
connections--;
|
||||
res.writeHead(200);
|
||||
res.end("done\n");
|
||||
res.end('done\n');
|
||||
if (connections == 0) {
|
||||
server.close();
|
||||
}
|
||||
@ -51,7 +51,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
|
||||
var request = http.request({
|
||||
port: common.PORT,
|
||||
method: 'POST',
|
||||
path: '/'
|
||||
path: '/'
|
||||
});
|
||||
|
||||
function ping() {
|
||||
|
@ -37,12 +37,12 @@ var reqCount = 0;
|
||||
var body = '';
|
||||
|
||||
process.stdout.write('build body...');
|
||||
for (var i = 0; i < 1024*1024; i++) {
|
||||
for (var i = 0; i < 1024 * 1024; i++) {
|
||||
body += 'hello world\n';
|
||||
}
|
||||
process.stdout.write('done\n');
|
||||
|
||||
var server = https.createServer(options, function (req, res) {
|
||||
var server = https.createServer(options, function(req, res) {
|
||||
reqCount++;
|
||||
console.log('got request');
|
||||
res.writeHead(200, { 'content-type': 'text/plain' });
|
||||
@ -52,23 +52,23 @@ var server = https.createServer(options, function (req, res) {
|
||||
var count = 0;
|
||||
var gotResEnd = false;
|
||||
|
||||
server.listen(common.PORT, function () {
|
||||
server.listen(common.PORT, function() {
|
||||
https.get({ port: common.PORT }, function(res) {
|
||||
console.log("response!");
|
||||
console.log('response!');
|
||||
|
||||
res.on('data', function(d) {
|
||||
process.stdout.write('.');
|
||||
count += d.length;
|
||||
res.pause();
|
||||
process.nextTick(function () {
|
||||
process.nextTick(function() {
|
||||
res.resume();
|
||||
});
|
||||
});
|
||||
|
||||
res.on('end', function(d) {
|
||||
process.stdout.write('\n');
|
||||
console.log("expected: ", body.length);
|
||||
console.log(" got: ", count);
|
||||
console.log('expected: ', body.length);
|
||||
console.log(' got: ', count);
|
||||
server.close();
|
||||
gotResEnd = true;
|
||||
});
|
||||
@ -76,7 +76,7 @@ server.listen(common.PORT, function () {
|
||||
});
|
||||
|
||||
|
||||
process.on('exit', function () {
|
||||
process.on('exit', function() {
|
||||
assert.equal(1, reqCount);
|
||||
assert.equal(body.length, count);
|
||||
assert.ok(gotResEnd);
|
||||
|
@ -28,11 +28,11 @@ var N = 500000;
|
||||
|
||||
var server = net.Server(function(socket) {
|
||||
socket.on('data', function(d) {
|
||||
console.error("got %d bytes", d.length);
|
||||
console.error('got %d bytes', d.length);
|
||||
});
|
||||
|
||||
socket.on('end', function() {
|
||||
console.error("end");
|
||||
console.error('end');
|
||||
socket.destroy();
|
||||
server.close();
|
||||
});
|
||||
@ -43,7 +43,7 @@ server.listen(common.PORT, function() {
|
||||
|
||||
client.on('connect', function() {
|
||||
for (var i = 0; i < N; i++) {
|
||||
client.write("hello world", function() {
|
||||
client.write('hello world', function() {
|
||||
cbcount++;
|
||||
});
|
||||
}
|
||||
|
@ -28,19 +28,20 @@ var assert = require('assert');
|
||||
// Regression test GH-511: https://github.com/ry/node/issues/issue/511
|
||||
// Make sure nextTick loops quickly
|
||||
|
||||
setTimeout(function () {
|
||||
t = Date.now() - t;
|
||||
STOP = 1;
|
||||
console.log(["ctr: ",ctr, ", t:", t, "ms -> ", (ctr/t).toFixed(2), "KHz"].join(''));
|
||||
assert.ok(ctr > 1000);
|
||||
setTimeout(function() {
|
||||
t = Date.now() - t;
|
||||
STOP = 1;
|
||||
console.log(['ctr: ', ctr, ', t:', t, 'ms -> ', (ctr / t).toFixed(2), 'KHz']
|
||||
.join(''));
|
||||
assert.ok(ctr > 1000);
|
||||
}, 2000);
|
||||
|
||||
var ctr = 0;
|
||||
var STOP = 0;
|
||||
var t = Date.now()+ 2;
|
||||
while (t > Date.now()) ; //get in sync with clock
|
||||
var t = Date.now() + 2;
|
||||
while (t > Date.now()); //get in sync with clock
|
||||
|
||||
(function foo () {
|
||||
(function foo() {
|
||||
if (STOP) return;
|
||||
process.nextTick(foo);
|
||||
ctr++;
|
||||
|
@ -33,7 +33,7 @@ var fs = require('fs');
|
||||
var body = '';
|
||||
|
||||
process.stdout.write('build body...');
|
||||
for (var i = 0; i < 1024*1024; i++) {
|
||||
for (var i = 0; i < 1024 * 1024; i++) {
|
||||
body += 'hello world\n';
|
||||
}
|
||||
process.stdout.write('done\n');
|
||||
@ -62,7 +62,7 @@ server.listen(common.PORT, function() {
|
||||
recvCount += d.length;
|
||||
|
||||
client.pause();
|
||||
process.nextTick(function () {
|
||||
process.nextTick(function() {
|
||||
client.resume();
|
||||
});
|
||||
});
|
||||
@ -82,7 +82,7 @@ function displayCounts() {
|
||||
}
|
||||
|
||||
|
||||
var timeout = setTimeout(displayCounts, 10*1000);
|
||||
var timeout = setTimeout(displayCounts, 10 * 1000);
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
|
@ -28,21 +28,21 @@ var maxMem = 0;
|
||||
var interval = setInterval(function() {
|
||||
try {
|
||||
require('vm').runInNewContext('throw 1;');
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
var rss = process.memoryUsage().rss;
|
||||
maxMem = Math.max(rss, maxMem);
|
||||
|
||||
|
||||
if (Date.now() - start > 5*1000) {
|
||||
if (Date.now() - start > 5 * 1000) {
|
||||
// wait 10 seconds.
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 1);
|
||||
|
||||
process.on('exit', function() {
|
||||
console.error('max mem: %dmb', Math.round(maxMem / (1024*1024)));
|
||||
console.error('max mem: %dmb', Math.round(maxMem / (1024 * 1024)));
|
||||
// make sure we stay below 100mb
|
||||
assert.ok(maxMem < 50 * 1024 * 1024);
|
||||
});
|
||||
|
@ -196,22 +196,22 @@ assert.doesNotThrow(function() {assert.ifError()});
|
||||
threw = false;
|
||||
try {
|
||||
assert.throws(
|
||||
function() {
|
||||
throw {};
|
||||
},
|
||||
Array
|
||||
function() {
|
||||
throw {}
|
||||
},
|
||||
Array
|
||||
);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
assert.ok(threw, "wrong constructor validation");
|
||||
assert.ok(threw, 'wrong constructor validation');
|
||||
|
||||
// use a RegExp to validate error message
|
||||
a.throws(makeBlock(thrower, TypeError), /test/);
|
||||
|
||||
// use a fn to validate error object
|
||||
a.throws(makeBlock(thrower, TypeError), function(err) {
|
||||
if ( (err instanceof TypeError) && /test/.test(err)) {
|
||||
if ((err instanceof TypeError) && /test/.test(err)) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -228,7 +228,7 @@ c.b = c;
|
||||
var gotError = false;
|
||||
try {
|
||||
assert.deepEqual(b, c);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
gotError = true;
|
||||
}
|
||||
|
||||
@ -257,12 +257,12 @@ testAssertionMessage(-Infinity, '"-Infinity"');
|
||||
testAssertionMessage('', '""');
|
||||
testAssertionMessage('foo', '"foo"');
|
||||
testAssertionMessage([], '[]');
|
||||
testAssertionMessage([1,2,3], '[1,2,3]');
|
||||
testAssertionMessage([1, 2, 3], '[1,2,3]');
|
||||
testAssertionMessage(/a/, '"/a/"');
|
||||
testAssertionMessage(/abc/gim, '"/abc/gim"');
|
||||
testAssertionMessage(function f() {}, '"function f() {}"');
|
||||
testAssertionMessage({}, '{}');
|
||||
testAssertionMessage({a:undefined, b:null}, '{"a":"undefined","b":null}');
|
||||
testAssertionMessage({a:NaN, b:Infinity, c:-Infinity},
|
||||
testAssertionMessage({a: undefined, b: null}, '{"a":"undefined","b":null}');
|
||||
testAssertionMessage({a: NaN, b: Infinity, c: -Infinity},
|
||||
'{"a":"NaN","b":"Infinity","c":"-Infinity"}');
|
||||
|
||||
|
@ -260,7 +260,8 @@ var f = new Buffer([0, 0, 0, 0, 0]);
|
||||
assert.equal(f.length, 5);
|
||||
var size = f.write('あいうえお', 'ucs2');
|
||||
console.error('bytes written to buffer: %d (should be 4)', size);
|
||||
console.error('chars written to buffer: %d (should be 2)', Buffer._charsWritten);
|
||||
console.error('chars written to buffer: %d (should be 2)',
|
||||
Buffer._charsWritten);
|
||||
assert.equal(size, 4);
|
||||
assert.equal(Buffer._charsWritten, 2);
|
||||
assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00]));
|
||||
@ -411,7 +412,7 @@ assert.equal(dot.toString('base64'), '//4uAA==');
|
||||
// Writing base64 at a position > 0 should not mangle the result.
|
||||
//
|
||||
// https://github.com/joyent/node/issues/402
|
||||
var segments = ['TWFkbmVzcz8h','IFRoaXM=','IGlz','IG5vZGUuanMh'];
|
||||
var segments = ['TWFkbmVzcz8h', 'IFRoaXM=', 'IGlz', 'IG5vZGUuanMh'];
|
||||
var buf = new Buffer(64);
|
||||
var pos = 0;
|
||||
|
||||
@ -455,37 +456,37 @@ assert.equal(0, Buffer('hello').slice(0, 0).length);
|
||||
// test hex toString
|
||||
console.log('Create hex string from buffer');
|
||||
var hexb = new Buffer(256);
|
||||
for (var i = 0; i < 256; i ++) {
|
||||
for (var i = 0; i < 256; i++) {
|
||||
hexb[i] = i;
|
||||
}
|
||||
var hexStr = hexb.toString('hex');
|
||||
assert.equal(hexStr,
|
||||
'000102030405060708090a0b0c0d0e0f'+
|
||||
'101112131415161718191a1b1c1d1e1f'+
|
||||
'202122232425262728292a2b2c2d2e2f'+
|
||||
'303132333435363738393a3b3c3d3e3f'+
|
||||
'404142434445464748494a4b4c4d4e4f'+
|
||||
'505152535455565758595a5b5c5d5e5f'+
|
||||
'606162636465666768696a6b6c6d6e6f'+
|
||||
'707172737475767778797a7b7c7d7e7f'+
|
||||
'808182838485868788898a8b8c8d8e8f'+
|
||||
'909192939495969798999a9b9c9d9e9f'+
|
||||
'a0a1a2a3a4a5a6a7a8a9aaabacadaeaf'+
|
||||
'b0b1b2b3b4b5b6b7b8b9babbbcbdbebf'+
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf'+
|
||||
'd0d1d2d3d4d5d6d7d8d9dadbdcdddedf'+
|
||||
'e0e1e2e3e4e5e6e7e8e9eaebecedeeef'+
|
||||
'000102030405060708090a0b0c0d0e0f' +
|
||||
'101112131415161718191a1b1c1d1e1f' +
|
||||
'202122232425262728292a2b2c2d2e2f' +
|
||||
'303132333435363738393a3b3c3d3e3f' +
|
||||
'404142434445464748494a4b4c4d4e4f' +
|
||||
'505152535455565758595a5b5c5d5e5f' +
|
||||
'606162636465666768696a6b6c6d6e6f' +
|
||||
'707172737475767778797a7b7c7d7e7f' +
|
||||
'808182838485868788898a8b8c8d8e8f' +
|
||||
'909192939495969798999a9b9c9d9e9f' +
|
||||
'a0a1a2a3a4a5a6a7a8a9aaabacadaeaf' +
|
||||
'b0b1b2b3b4b5b6b7b8b9babbbcbdbebf' +
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf' +
|
||||
'd0d1d2d3d4d5d6d7d8d9dadbdcdddedf' +
|
||||
'e0e1e2e3e4e5e6e7e8e9eaebecedeeef' +
|
||||
'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff');
|
||||
|
||||
console.log('Create buffer from hex string');
|
||||
var hexb2 = new Buffer(hexStr, 'hex');
|
||||
for (var i = 0; i < 256; i ++) {
|
||||
for (var i = 0; i < 256; i++) {
|
||||
assert.equal(hexb2[i], hexb[i]);
|
||||
}
|
||||
|
||||
// test an invalid slice end.
|
||||
console.log('Try to slice off the end of the buffer');
|
||||
var b = new Buffer([1,2,3,4,5]);
|
||||
var b = new Buffer([1, 2, 3, 4, 5]);
|
||||
var b2 = b.toString('hex', 1, 10000);
|
||||
var b3 = b.toString('hex', 1, 5);
|
||||
var b4 = b.toString('hex', 1);
|
||||
@ -496,25 +497,25 @@ assert.equal(b2, b4);
|
||||
// Test slice on SlowBuffer GH-843
|
||||
var SlowBuffer = process.binding('buffer').SlowBuffer;
|
||||
|
||||
function buildSlowBuffer (data) {
|
||||
function buildSlowBuffer(data) {
|
||||
if (Array.isArray(data)) {
|
||||
var buffer = new SlowBuffer(data.length);
|
||||
data.forEach(function(v,k) {
|
||||
data.forEach(function(v, k) {
|
||||
buffer[k] = v;
|
||||
});
|
||||
return buffer;
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var x = buildSlowBuffer([0x81,0xa3,0x66,0x6f,0x6f,0xa3,0x62,0x61,0x72]);
|
||||
var x = buildSlowBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]);
|
||||
|
||||
console.log(x.inspect())
|
||||
console.log(x.inspect());
|
||||
assert.equal('<SlowBuffer 81 a3 66 6f 6f a3 62 61 72>', x.inspect());
|
||||
|
||||
var z = x.slice(4);
|
||||
console.log(z.inspect())
|
||||
console.log(z.length)
|
||||
console.log(z.inspect());
|
||||
console.log(z.length);
|
||||
assert.equal(5, z.length);
|
||||
assert.equal(0x6f, z[0]);
|
||||
assert.equal(0xa3, z[1]);
|
||||
@ -523,41 +524,41 @@ assert.equal(0x61, z[3]);
|
||||
assert.equal(0x72, z[4]);
|
||||
|
||||
var z = x.slice(0);
|
||||
console.log(z.inspect())
|
||||
console.log(z.length)
|
||||
console.log(z.inspect());
|
||||
console.log(z.length);
|
||||
assert.equal(z.length, x.length);
|
||||
|
||||
var z = x.slice(0, 4);
|
||||
console.log(z.inspect())
|
||||
console.log(z.length)
|
||||
console.log(z.inspect());
|
||||
console.log(z.length);
|
||||
assert.equal(4, z.length);
|
||||
assert.equal(0x81, z[0]);
|
||||
assert.equal(0xa3, z[1]);
|
||||
|
||||
var z = x.slice(0, 9);
|
||||
console.log(z.inspect())
|
||||
console.log(z.length)
|
||||
console.log(z.inspect());
|
||||
console.log(z.length);
|
||||
assert.equal(9, z.length);
|
||||
|
||||
var z = x.slice(1, 4);
|
||||
console.log(z.inspect())
|
||||
console.log(z.length)
|
||||
console.log(z.inspect());
|
||||
console.log(z.length);
|
||||
assert.equal(3, z.length);
|
||||
assert.equal(0xa3, z[0]);
|
||||
|
||||
var z = x.slice(2, 4);
|
||||
console.log(z.inspect())
|
||||
console.log(z.length)
|
||||
console.log(z.inspect());
|
||||
console.log(z.length);
|
||||
assert.equal(2, z.length);
|
||||
assert.equal(0x66, z[0]);
|
||||
assert.equal(0x6f, z[1]);
|
||||
|
||||
assert.equal(0, Buffer('hello').slice(0, 0).length)
|
||||
assert.equal(0, Buffer('hello').slice(0, 0).length);
|
||||
|
||||
b = new Buffer(50);
|
||||
b.fill("h");
|
||||
b.fill('h');
|
||||
for (var i = 0; i < b.length; i++) {
|
||||
assert.equal("h".charCodeAt(0), b[i]);
|
||||
assert.equal('h'.charCodeAt(0), b[i]);
|
||||
}
|
||||
|
||||
b.fill(0);
|
||||
@ -577,13 +578,13 @@ assert.equal(b.toString('ucs2'), 'あいうえお');
|
||||
// Binary encoding should write only one byte per character.
|
||||
var b = Buffer([0xde, 0xad, 0xbe, 0xef]);
|
||||
var s = String.fromCharCode(0xffff);
|
||||
b.write(s, 0, 'binary')
|
||||
b.write(s, 0, 'binary');
|
||||
assert.equal(0xff, b[0]);
|
||||
assert.equal(0xad, b[1]);
|
||||
assert.equal(0xbe, b[2]);
|
||||
assert.equal(0xef, b[3]);
|
||||
s = String.fromCharCode(0xaaee);
|
||||
b.write(s, 0, 'binary')
|
||||
b.write(s, 0, 'binary');
|
||||
assert.equal(0xee, b[0]);
|
||||
assert.equal(0xad, b[1]);
|
||||
assert.equal(0xbe, b[2]);
|
||||
@ -592,7 +593,7 @@ assert.equal(0xef, b[3]);
|
||||
|
||||
// This should not segfault the program.
|
||||
assert.throws(function() {
|
||||
new Buffer('"pong"', 0, 6, 8031, '127.0.0.1')
|
||||
new Buffer('"pong"', 0, 6, 8031, '127.0.0.1');
|
||||
});
|
||||
|
||||
// #1210 Test UTF-8 string includes null character
|
||||
@ -696,9 +697,9 @@ Buffer(3.3).toString(); // throws bad argument error in commit 43cb4ec
|
||||
assert.equal(Buffer(-1).length, 0);
|
||||
assert.equal(Buffer(NaN).length, 0);
|
||||
assert.equal(Buffer(3.3).length, 4);
|
||||
assert.equal(Buffer({length:3.3}).length, 4);
|
||||
assert.equal(Buffer({length:"BAM"}).length, 0);
|
||||
assert.equal(Buffer({length: 3.3}).length, 4);
|
||||
assert.equal(Buffer({length: 'BAM'}).length, 0);
|
||||
|
||||
// Make sure that strings are not coerced to numbers.
|
||||
assert.equal(Buffer("99").length, 2);
|
||||
assert.equal(Buffer("13.37").length, 5);
|
||||
assert.equal(Buffer('99').length, 2);
|
||||
assert.equal(Buffer('13.37').length, 5);
|
||||
|
@ -4,12 +4,12 @@ var common = require('../common');
|
||||
|
||||
var sub = common.fixturesDir + '/child-process-channel.js';
|
||||
|
||||
var child = spawn(process.execPath, [ sub ], {
|
||||
var child = spawn(process.execPath, [sub], {
|
||||
customFds: [0, 1, 2],
|
||||
wantChannel: true
|
||||
});
|
||||
|
||||
console.log("fds", child.fds);
|
||||
console.log('fds', child.fds);
|
||||
|
||||
assert.ok(child.fds.length == 4);
|
||||
assert.ok(child.fds[3] >= 0);
|
||||
|
@ -3,6 +3,6 @@ var common = require('../common');
|
||||
var bigish = Array(200);
|
||||
|
||||
for (var i = 0, il = bigish.length; i < il; ++i)
|
||||
bigish[i] = -1;
|
||||
bigish[i] = -1;
|
||||
|
||||
common.spawnPwd({ customFds: bigish });
|
||||
|
@ -53,7 +53,7 @@ function testCwd(options, forCode, forData) {
|
||||
}
|
||||
|
||||
// Assume these exist, and 'pwd' gives us the right directory back
|
||||
if (process.platform == "win32") {
|
||||
if (process.platform == 'win32') {
|
||||
testCwd({cwd: process.env.windir}, 0, process.env.windir);
|
||||
testCwd({cwd: 'c:\\'}, 0, 'c:\\');
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ var echo = spawn('echo', ['hello\nnode\nand\nworld\n']),
|
||||
|
||||
// pipe echo | grep
|
||||
echo.stdout.on('data', function(data) {
|
||||
console.error("grep stdin write " + data.length);
|
||||
console.error('grep stdin write ' + data.length);
|
||||
if (!grep.stdin.write(data)) {
|
||||
echo.stdout.pause();
|
||||
}
|
||||
@ -63,22 +63,22 @@ echo.stdout.on('end', function(code) {
|
||||
});
|
||||
|
||||
echo.on('exit', function() {
|
||||
console.error("echo exit");
|
||||
})
|
||||
console.error('echo exit');
|
||||
});
|
||||
|
||||
grep.on('exit', function() {
|
||||
console.error("grep exit");
|
||||
})
|
||||
console.error('grep exit');
|
||||
});
|
||||
|
||||
sed.on('exit', function() {
|
||||
console.error("sed exit");
|
||||
})
|
||||
console.error('sed exit');
|
||||
});
|
||||
|
||||
|
||||
|
||||
// pipe grep | sed
|
||||
grep.stdout.on('data', function(data) {
|
||||
console.error("grep stdout " + data.length);
|
||||
console.error('grep stdout ' + data.length);
|
||||
if (!sed.stdin.write(data)) {
|
||||
grep.stdout.pause();
|
||||
}
|
||||
@ -90,7 +90,7 @@ sed.stdin.on('drain', function(data) {
|
||||
|
||||
// propagate end from grep to sed
|
||||
grep.stdout.on('end', function(code) {
|
||||
console.error("grep stdout end");
|
||||
console.error('grep stdout end');
|
||||
sed.stdin.end();
|
||||
});
|
||||
|
||||
|
@ -31,7 +31,7 @@ var env = {
|
||||
};
|
||||
env.__proto__ = {
|
||||
'FOO': 'BAR'
|
||||
}
|
||||
};
|
||||
|
||||
if (isWindows) {
|
||||
var child = spawn('cmd.exe', ['/c', 'set'], {env: env});
|
||||
|
@ -29,10 +29,10 @@ var error_count = 0;
|
||||
var pwdcommand, dir;
|
||||
|
||||
if (process.platform == 'win32') {
|
||||
pwdcommand = 'echo %cd%';
|
||||
pwdcommand = 'echo %cd%';
|
||||
dir = 'c:\\windows';
|
||||
} else {
|
||||
pwdcommand = 'pwd';
|
||||
pwdcommand = 'pwd';
|
||||
dir = '/dev';
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ child.stdout.addListener('data', function(chunk) {
|
||||
});
|
||||
|
||||
process.addListener('exit', function() {
|
||||
console.log("response: ", response);
|
||||
console.log('response: ', response);
|
||||
assert.equal(1, success_count);
|
||||
assert.equal(0, error_count);
|
||||
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
|
||||
|
@ -21,16 +21,16 @@
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
var ch = require("child_process")
|
||||
var ch = require('child_process');
|
||||
|
||||
var SIZE = 100000
|
||||
var SIZE = 100000;
|
||||
var childGone = false;
|
||||
|
||||
var cp = ch.spawn("python", ['-c', 'print ' + SIZE + ' * "C"'], {
|
||||
var cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
|
||||
customFds: [0, 1, 2]
|
||||
});
|
||||
|
||||
cp.on("exit", function (code) {
|
||||
cp.on('exit', function(code) {
|
||||
childGone = true;
|
||||
assert.equal(0, code);
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ child.exec(nodejs + ' --eval 42',
|
||||
// assert that "42\n" is written to stderr
|
||||
child.exec(nodejs + ' --eval "console.error(42)"',
|
||||
function(err, stdout, stderr) {
|
||||
assert.equal(stderr, "42\n");
|
||||
assert.equal(stderr, '42\n');
|
||||
});
|
||||
|
||||
// assert that module loading works
|
||||
|
@ -25,9 +25,9 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
var func = function () {};
|
||||
var func = function() {};
|
||||
var toStringCalled = false;
|
||||
func.toString = function () {
|
||||
func.toString = function() {
|
||||
toStringCalled = true;
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,7 @@ global.process.stdout.write = function(string) {
|
||||
console.log('foo');
|
||||
console.log('foo', 'bar');
|
||||
console.log('%s %s', 'foo', 'bar', 'hop');
|
||||
console.log({slashes: '\\\\'})
|
||||
console.log({slashes: '\\\\'});
|
||||
|
||||
global.process.stdout.write = stdout_write;
|
||||
assert.equal('foo\n', strings.shift());
|
||||
@ -49,4 +49,4 @@ assert.equal('foo bar\n', strings.shift());
|
||||
assert.equal('foo bar hop\n', strings.shift());
|
||||
assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
|
||||
|
||||
assert.equal(true, process.stderr.write("hello world"));
|
||||
assert.equal(true, process.stderr.write('hello world'));
|
||||
|
@ -32,10 +32,10 @@ try {
|
||||
// bump, we register a lot of exit listeners
|
||||
process.setMaxListeners(256);
|
||||
|
||||
[ crypto.randomBytes,
|
||||
[crypto.randomBytes,
|
||||
crypto.pseudoRandomBytes
|
||||
].forEach(function(f) {
|
||||
[ -1,
|
||||
[-1,
|
||||
undefined,
|
||||
null,
|
||||
false,
|
||||
@ -44,7 +44,7 @@ process.setMaxListeners(256);
|
||||
[]
|
||||
].forEach(function(value) {
|
||||
assert.throws(function() { f(value); });
|
||||
assert.throws(function() { f(value, function(){}); });
|
||||
assert.throws(function() { f(value, function() {}); });
|
||||
});
|
||||
|
||||
[0, 1, 2, 4, 16, 256, 1024].forEach(function(len) {
|
||||
|
@ -39,8 +39,10 @@ var path = require('path');
|
||||
var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
|
||||
var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
|
||||
var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
|
||||
var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', 'ascii');
|
||||
var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', 'ascii');
|
||||
var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
|
||||
'ascii');
|
||||
var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
|
||||
'ascii');
|
||||
|
||||
try {
|
||||
var credentials = crypto.createCredentials(
|
||||
@ -69,8 +71,8 @@ var rfc4231 = [
|
||||
sha224: '896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22',
|
||||
sha256: 'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7',
|
||||
sha384: 'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6',
|
||||
sha512: '87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854',
|
||||
},
|
||||
sha512: '87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('4a656665', 'hex'), // 'Jefe'
|
||||
@ -79,8 +81,8 @@ var rfc4231 = [
|
||||
sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44',
|
||||
sha256: '5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843',
|
||||
sha384: 'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649',
|
||||
sha512: '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737',
|
||||
},
|
||||
sha512: '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
@ -89,8 +91,8 @@ var rfc4231 = [
|
||||
sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
|
||||
sha256: '773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe',
|
||||
sha384: '88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27',
|
||||
sha512: 'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb',
|
||||
},
|
||||
sha512: 'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||
@ -99,8 +101,8 @@ var rfc4231 = [
|
||||
sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
|
||||
sha256: '82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b',
|
||||
sha384: '3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb',
|
||||
sha512: 'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd',
|
||||
},
|
||||
sha512: 'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||
@ -109,9 +111,9 @@ var rfc4231 = [
|
||||
sha224: '0e2aea68a90c8d37c988bcdb9fca6fa8',
|
||||
sha256: 'a3b6167473100ee06e0c796c2955552b',
|
||||
sha384: '3abf34c3503b2a23a46efc619baef897',
|
||||
sha512: '415fad6271580a531d4179bc891d87a6',
|
||||
sha512: '415fad6271580a531d4179bc891d87a6'
|
||||
},
|
||||
truncate: true,
|
||||
truncate: true
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
@ -120,8 +122,8 @@ var rfc4231 = [
|
||||
sha224: '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e',
|
||||
sha256: '60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54',
|
||||
sha384: '4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952',
|
||||
sha512: '80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598',
|
||||
},
|
||||
sha512: '80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
@ -130,9 +132,9 @@ var rfc4231 = [
|
||||
sha224: '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1',
|
||||
sha256: '9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2',
|
||||
sha384: '6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e',
|
||||
sha512: 'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58',
|
||||
},
|
||||
},
|
||||
sha512: 'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
for (var i = 0, l = rfc4231.length; i < l; i++) {
|
||||
@ -145,7 +147,7 @@ for (var i = 0, l = rfc4231.length; i < l; i++) {
|
||||
}
|
||||
assert.equal(rfc4231[i]['hmac'][hash],
|
||||
result,
|
||||
"Test HMAC-" + hash + ": Test case " + (i+1) + " rfc 4231");
|
||||
'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' rfc 4231');
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,75 +156,75 @@ var rfc2202_md5 = [
|
||||
{
|
||||
key: new Buffer('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
|
||||
data: 'Hi There',
|
||||
hmac: '9294727a3638bb1c13f48ef8158bfc9d',
|
||||
hmac: '9294727a3638bb1c13f48ef8158bfc9d'
|
||||
},
|
||||
{
|
||||
key: 'Jefe',
|
||||
data: 'what do ya want for nothing?',
|
||||
hmac: '750c783e6ab0b503eaa86e310a5db738',
|
||||
hmac: '750c783e6ab0b503eaa86e310a5db738'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||
hmac: '56be34521d144c88dbb8c733f0e8b3f6',
|
||||
hmac: '56be34521d144c88dbb8c733f0e8b3f6'
|
||||
},
|
||||
{
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||
hmac: '697eaf0aca3a3aea3a75164746ffaa79',
|
||||
hmac: '697eaf0aca3a3aea3a75164746ffaa79'
|
||||
},
|
||||
{
|
||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||
data: 'Test With Truncation',
|
||||
hmac: '56461ef2342edc00f9bab995690efd4c',
|
||||
hmac: '56461ef2342edc00f9bab995690efd4c'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
||||
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd',
|
||||
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
||||
hmac: '6f630fad67cda0ee1fb1f562db3aa53e',
|
||||
},
|
||||
hmac: '6f630fad67cda0ee1fb1f562db3aa53e'
|
||||
}
|
||||
];
|
||||
var rfc2202_sha1 = [
|
||||
{
|
||||
key: new Buffer('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
|
||||
data: 'Hi There',
|
||||
hmac: 'b617318655057264e28bc0b6fb378c8ef146be00',
|
||||
hmac: 'b617318655057264e28bc0b6fb378c8ef146be00'
|
||||
},
|
||||
{
|
||||
key: 'Jefe',
|
||||
data: 'what do ya want for nothing?',
|
||||
hmac: 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79',
|
||||
hmac: 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3',
|
||||
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3'
|
||||
},
|
||||
{
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da',
|
||||
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da'
|
||||
},
|
||||
{
|
||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||
data: 'Test With Truncation',
|
||||
hmac: '4c1a03424b55e07fe7f27be1d58bb9324a9a5a04',
|
||||
hmac: '4c1a03424b55e07fe7f27be1d58bb9324a9a5a04'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
||||
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112',
|
||||
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
||||
hmac: 'e8e99d0f45237d786d6bbaa7965c7808bbff1a91',
|
||||
},
|
||||
hmac: 'e8e99d0f45237d786d6bbaa7965c7808bbff1a91'
|
||||
}
|
||||
];
|
||||
|
||||
for (var i = 0, l = rfc2202_md5.length; i < l; i++) {
|
||||
@ -230,14 +232,14 @@ for (var i = 0, l = rfc2202_md5.length; i < l; i++) {
|
||||
crypto.createHmac('md5', rfc2202_md5[i]['key'])
|
||||
.update(rfc2202_md5[i]['data'])
|
||||
.digest('hex'),
|
||||
"Test HMAC-MD5 : Test case " + (i+1) + " rfc 2202");
|
||||
'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202');
|
||||
}
|
||||
for (var i = 0, l = rfc2202_sha1.length; i < l; i++) {
|
||||
assert.equal(rfc2202_sha1[i]['hmac'],
|
||||
crypto.createHmac('sha1', rfc2202_sha1[i]['key'])
|
||||
.update(rfc2202_sha1[i]['data'])
|
||||
.digest('hex'),
|
||||
"Test HMAC-SHA1 : Test case " + (i+1) + " rfc 2202");
|
||||
'Test HMAC-SHA1 : Test case ' + (i + 1) + ' rfc 2202');
|
||||
}
|
||||
|
||||
// Test hashing
|
||||
@ -314,8 +316,8 @@ assert.equal(txt, plaintext, 'encryption and decryption');
|
||||
// encryption and decryption with Base64
|
||||
// reported in https://github.com/joyent/node/issues/738
|
||||
var plaintext =
|
||||
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
|
||||
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJjAfaFg**';
|
||||
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
|
||||
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJjAfaFg**';
|
||||
var cipher = crypto.createCipher('aes256', '0123456789abcdef');
|
||||
|
||||
// encrypt plaintext which is in utf8 format
|
||||
@ -394,22 +396,22 @@ assert.equal(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), 1);
|
||||
|
||||
// Test PBKDF2 with RFC 6070 test vectors (except #4)
|
||||
|
||||
crypto.pbkdf2('password', 'salt', 1, 20, function (err, result) {
|
||||
crypto.pbkdf2('password', 'salt', 1, 20, function(err, result) {
|
||||
assert.equal(result, '\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6', 'pbkdf1 test vector 1');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('password', 'salt', 2, 20, function (err, result) {
|
||||
crypto.pbkdf2('password', 'salt', 2, 20, function(err, result) {
|
||||
assert.equal(result, '\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57', 'pbkdf1 test vector 2');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('password', 'salt', 4096, 20, function (err, result) {
|
||||
crypto.pbkdf2('password', 'salt', 4096, 20, function(err, result) {
|
||||
assert.equal(result, '\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1', 'pbkdf1 test vector 3');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25, function (err, result) {
|
||||
crypto.pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25, function(err, result) {
|
||||
assert.equal(result, '\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38', 'pbkdf1 test vector 5');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('pass\0word', 'sa\0lt', 4096, 16, function (err, result) {
|
||||
crypto.pbkdf2('pass\0word', 'sa\0lt', 4096, 16, function(err, result) {
|
||||
assert.equal(result, '\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34\x25\xe0\xc3', 'pbkdf1 test vector 6');
|
||||
});
|
||||
|
@ -31,15 +31,15 @@ var spawn = require('child_process').spawn;
|
||||
|
||||
var resCount = 0;
|
||||
var p = new debug.Protocol();
|
||||
p.onResponse = function (res) {
|
||||
p.onResponse = function(res) {
|
||||
resCount++;
|
||||
};
|
||||
|
||||
p.execute("Type: connect\r\n" +
|
||||
"V8-Version: 3.0.4.1\r\n" +
|
||||
"Protocol-Version: 1\r\n" +
|
||||
"Embedding-Host: node v0.3.3-pre\r\n" +
|
||||
"Content-Length: 0\r\n\r\n");
|
||||
p.execute('Type: connect\r\n' +
|
||||
'V8-Version: 3.0.4.1\r\n' +
|
||||
'Protocol-Version: 1\r\n' +
|
||||
'Embedding-Host: node v0.3.3-pre\r\n' +
|
||||
'Content-Length: 0\r\n\r\n');
|
||||
assert.equal(1, resCount);
|
||||
|
||||
// Make sure split messages go in.
|
||||
@ -93,26 +93,26 @@ assert.equal(4, resCount);
|
||||
|
||||
var expectedConnections = 0;
|
||||
var tests = [];
|
||||
function addTest (cb) {
|
||||
function addTest(cb) {
|
||||
expectedConnections++;
|
||||
tests.push(cb);
|
||||
}
|
||||
|
||||
addTest(function (client, done) {
|
||||
console.error("requesting version");
|
||||
client.reqVersion(function (err, v) {
|
||||
addTest(function(client, done) {
|
||||
console.error('requesting version');
|
||||
client.reqVersion(function(err, v) {
|
||||
assert.ok(!err);
|
||||
console.log("version: %s", v);
|
||||
console.log('version: %s', v);
|
||||
assert.equal(process.versions.v8, v);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
addTest(function (client, done) {
|
||||
console.error("requesting scripts");
|
||||
client.reqScripts(function (err) {
|
||||
addTest(function(client, done) {
|
||||
console.error('requesting scripts');
|
||||
client.reqScripts(function(err) {
|
||||
assert.ok(!err);
|
||||
console.error("got %d scripts", Object.keys(client.scripts).length);
|
||||
console.error('got %d scripts', Object.keys(client.scripts).length);
|
||||
|
||||
var foundMainScript = false;
|
||||
for (var k in client.scripts) {
|
||||
@ -127,9 +127,9 @@ addTest(function (client, done) {
|
||||
});
|
||||
});
|
||||
|
||||
addTest(function (client, done) {
|
||||
console.error("eval 2+2");
|
||||
client.reqEval("2+2", function (err, res) {
|
||||
addTest(function(client, done) {
|
||||
console.error('eval 2+2');
|
||||
client.reqEval('2+2', function(err, res) {
|
||||
console.error(res);
|
||||
assert.ok(!err);
|
||||
assert.equal('4', res.text);
|
||||
@ -145,16 +145,16 @@ function doTest(cb, done) {
|
||||
var nodeProcess = spawn(process.execPath,
|
||||
['-e', 'setInterval(function () { console.log("blah"); }, 100);']);
|
||||
|
||||
nodeProcess.stdout.once('data', function () {
|
||||
console.log(">>> new node process: %d", nodeProcess.pid);
|
||||
process.kill(nodeProcess.pid, "SIGUSR1");
|
||||
console.log(">>> signaling it with SIGUSR1");
|
||||
nodeProcess.stdout.once('data', function() {
|
||||
console.log('>>> new node process: %d', nodeProcess.pid);
|
||||
process.kill(nodeProcess.pid, 'SIGUSR1');
|
||||
console.log('>>> signaling it with SIGUSR1');
|
||||
});
|
||||
|
||||
var didTryConnect = false;
|
||||
nodeProcess.stderr.setEncoding('utf8');
|
||||
var b = ''
|
||||
nodeProcess.stderr.on('data', function (data) {
|
||||
var b = '';
|
||||
nodeProcess.stderr.on('data', function(data) {
|
||||
b += data;
|
||||
if (didTryConnect == false && /debugger listening on port/.test(b)) {
|
||||
didTryConnect = true;
|
||||
@ -162,13 +162,13 @@ function doTest(cb, done) {
|
||||
setTimeout(function() {
|
||||
// Wait for some data before trying to connect
|
||||
var c = new debug.Client();
|
||||
process.stdout.write(">>> connecting...");
|
||||
c.connect(debug.port)
|
||||
c.on('ready', function () {
|
||||
process.stdout.write('>>> connecting...');
|
||||
c.connect(debug.port);
|
||||
c.on('ready', function() {
|
||||
connectCount++;
|
||||
console.log("ready!");
|
||||
cb(c, function () {
|
||||
console.error(">>> killing node process %d\n\n", nodeProcess.pid);
|
||||
console.log('ready!');
|
||||
cb(c, function() {
|
||||
console.error('>>> killing node process %d\n\n', nodeProcess.pid);
|
||||
nodeProcess.kill();
|
||||
done();
|
||||
});
|
||||
@ -179,11 +179,11 @@ function doTest(cb, done) {
|
||||
}
|
||||
|
||||
|
||||
function run () {
|
||||
function run() {
|
||||
var t = tests[0];
|
||||
if (!t) return;
|
||||
|
||||
doTest(t, function () {
|
||||
doTest(t, function() {
|
||||
tests.shift();
|
||||
run();
|
||||
});
|
||||
|
@ -73,7 +73,7 @@ function addTest(input, output) {
|
||||
}
|
||||
};
|
||||
expected.push({input: input, lines: output, callback: next});
|
||||
};
|
||||
}
|
||||
|
||||
// Initial lines
|
||||
addTest(null, [
|
||||
@ -140,13 +140,13 @@ addTest('c, bt', [
|
||||
|
||||
function finish() {
|
||||
process.exit(0);
|
||||
};
|
||||
}
|
||||
|
||||
function quit() {
|
||||
if (quit.called) return;
|
||||
quit.called = true;
|
||||
child.stdin.write('quit');
|
||||
};
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
throw new Error('timeout!');
|
||||
|
@ -30,7 +30,8 @@ var path = require('path');
|
||||
var exits = 0;
|
||||
|
||||
function errExec(script, callback) {
|
||||
var cmd = '"' + process.argv[0] + '" "' + path.join(common.fixturesDir, script) + '"';
|
||||
var cmd = '"' + process.argv[0] + '" "' +
|
||||
path.join(common.fixturesDir, script) + '"';
|
||||
return exec(cmd, function(err, stdout, stderr) {
|
||||
// There was some error
|
||||
assert.ok(err);
|
||||
|
@ -30,8 +30,9 @@ var exec = require('child_process').exec;
|
||||
var success_count = 0;
|
||||
var error_count = 0;
|
||||
|
||||
var cmd = [process.execPath, '-e', '"console.error(process.argv)"', 'foo', 'bar'].join(' ');
|
||||
var expected = util.format([process.execPath, 'foo', 'bar']) + "\n";
|
||||
var cmd = [process.execPath, '-e', '"console.error(process.argv)"', 'foo', 'bar']
|
||||
.join(' ');
|
||||
var expected = util.format([process.execPath, 'foo', 'bar']) + '\n';
|
||||
var child = exec(cmd, function(err, stdout, stderr) {
|
||||
if (err) {
|
||||
console.log(err.toString());
|
||||
|
@ -36,7 +36,7 @@ e.emit('hello', 'a', 'b');
|
||||
e.emit('hello', 'a', 'b');
|
||||
|
||||
var remove = function() {
|
||||
assert.fail(1,0, 'once->foo should not be emitted', '!');
|
||||
assert.fail(1, 0, 'once->foo should not be emitted', '!');
|
||||
};
|
||||
|
||||
e.once('foo', remove);
|
||||
|
@ -40,13 +40,13 @@ var countDrains = 0;
|
||||
|
||||
process.on('exit', function() {
|
||||
removeTestFile();
|
||||
if ( cb_occurred !== cb_expected) {
|
||||
if (cb_occurred !== cb_expected) {
|
||||
console.log(' Test callback events missing or out of order:');
|
||||
console.log(' expected: %j', cb_expected);
|
||||
console.log(' occurred: %j', cb_occurred);
|
||||
assert.strictEqual(cb_occurred, cb_expected,
|
||||
'events missing or out of order: "' +
|
||||
cb_occurred + '" !== "' + cb_expected + '"');
|
||||
'events missing or out of order: "' +
|
||||
cb_occurred + '" !== "' + cb_expected + '"');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -42,13 +42,13 @@ var fileDataExpected_3 = 'abcdefghij\u2026\u2026qrstuvwxyz';
|
||||
|
||||
process.on('exit', function() {
|
||||
removeTestFile();
|
||||
if ( cb_occurred !== cb_expected) {
|
||||
if (cb_occurred !== cb_expected) {
|
||||
console.log(' Test callback events missing or out of order:');
|
||||
console.log(' expected: %j', cb_expected);
|
||||
console.log(' occurred: %j', cb_occurred);
|
||||
assert.strictEqual(cb_occurred, cb_expected,
|
||||
'events missing or out of order: "' +
|
||||
cb_occurred + '" !== "' + cb_expected + '"');
|
||||
'events missing or out of order: "' +
|
||||
cb_occurred + '" !== "' + cb_expected + '"');
|
||||
}
|
||||
});
|
||||
|
||||
@ -195,10 +195,10 @@ function run_test_4() {
|
||||
|
||||
// Error: start must be >= zero
|
||||
assert.throws(
|
||||
function() {
|
||||
file = fs.createWriteStream(filepath, options);
|
||||
},
|
||||
/start must be/
|
||||
function() {
|
||||
file = fs.createWriteStream(filepath, options);
|
||||
},
|
||||
/start must be/
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ var fs = require('fs');
|
||||
|
||||
var caughtException = false;
|
||||
try {
|
||||
// should throw ENOENT, not EBADF - see https://github.com/joyent/node/pull/1228
|
||||
// should throw ENOENT, not EBADF
|
||||
// see https://github.com/joyent/node/pull/1228
|
||||
fs.openSync('/path/to/file/that/does/not/exist', 'r');
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -49,53 +49,53 @@ process.addListener('exit', function() {
|
||||
});
|
||||
|
||||
|
||||
fs.writeFileSync(filepathOne, "hello");
|
||||
fs.writeFileSync(filepathOne, 'hello');
|
||||
|
||||
assert.throws(
|
||||
function() {
|
||||
fs.watchFile(filepathOne);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watchFile requires a listener function';
|
||||
}
|
||||
function() {
|
||||
fs.watchFile(filepathOne);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watchFile requires a listener function';
|
||||
}
|
||||
);
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
fs.watchFile(filepathOne, function(curr, prev) {
|
||||
fs.unwatchFile(filepathOne);
|
||||
++watchSeenOne;
|
||||
});
|
||||
}
|
||||
function() {
|
||||
fs.watchFile(filepathOne, function(curr, prev) {
|
||||
fs.unwatchFile(filepathOne);
|
||||
++watchSeenOne;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(function() {
|
||||
fs.writeFileSync(filepathOne, "world");
|
||||
fs.writeFileSync(filepathOne, 'world');
|
||||
}, 1000);
|
||||
|
||||
|
||||
process.chdir(testDir);
|
||||
|
||||
fs.writeFileSync(filepathTwoAbs, "howdy");
|
||||
fs.writeFileSync(filepathTwoAbs, 'howdy');
|
||||
|
||||
assert.throws(
|
||||
function() {
|
||||
fs.watchFile(filepathTwo);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watchFile requires a listener function';
|
||||
}
|
||||
function() {
|
||||
fs.watchFile(filepathTwo);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watchFile requires a listener function';
|
||||
}
|
||||
);
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
fs.watchFile(filepathTwo, function(curr, prev) {
|
||||
fs.unwatchFile(filepathTwo);
|
||||
++watchSeenTwo;
|
||||
});
|
||||
}
|
||||
function() {
|
||||
fs.watchFile(filepathTwo, function(curr, prev) {
|
||||
fs.unwatchFile(filepathTwo);
|
||||
++watchSeenTwo;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(function() {
|
||||
fs.writeFileSync(filepathTwoAbs, "pardner");
|
||||
fs.writeFileSync(filepathTwoAbs, 'pardner');
|
||||
}, 1000);
|
||||
|
@ -56,88 +56,88 @@ process.addListener('exit', function() {
|
||||
});
|
||||
|
||||
|
||||
fs.writeFileSync(filepathOne, "hello");
|
||||
fs.writeFileSync(filepathOne, 'hello');
|
||||
|
||||
assert.throws(
|
||||
function() {
|
||||
fs.watch(filepathOne);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watch requires a listener function';
|
||||
}
|
||||
function() {
|
||||
fs.watch(filepathOne);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watch requires a listener function';
|
||||
}
|
||||
);
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
var watcher = fs.watch(filepathOne, function(event, filename) {
|
||||
assert.equal('change', event);
|
||||
if (expectFilePath) {
|
||||
assert.equal('watch.txt', filename);
|
||||
} else {
|
||||
assert.equal(null, filename);
|
||||
}
|
||||
watcher.close();
|
||||
++watchSeenOne;
|
||||
});
|
||||
}
|
||||
function() {
|
||||
var watcher = fs.watch(filepathOne, function(event, filename) {
|
||||
assert.equal('change', event);
|
||||
if (expectFilePath) {
|
||||
assert.equal('watch.txt', filename);
|
||||
} else {
|
||||
assert.equal(null, filename);
|
||||
}
|
||||
watcher.close();
|
||||
++watchSeenOne;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(function() {
|
||||
fs.writeFileSync(filepathOne, "world");
|
||||
fs.writeFileSync(filepathOne, 'world');
|
||||
}, 1000);
|
||||
|
||||
|
||||
process.chdir(testDir);
|
||||
|
||||
fs.writeFileSync(filepathTwoAbs, "howdy");
|
||||
fs.writeFileSync(filepathTwoAbs, 'howdy');
|
||||
|
||||
assert.throws(
|
||||
function() {
|
||||
fs.watch(filepathTwo);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watch requires a listener function';
|
||||
}
|
||||
function() {
|
||||
fs.watch(filepathTwo);
|
||||
},
|
||||
function(e) {
|
||||
return e.message === 'watch requires a listener function';
|
||||
}
|
||||
);
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
var watcher = fs.watch(filepathTwo, function(event, filename) {
|
||||
assert.equal('change', event);
|
||||
if (expectFilePath) {
|
||||
assert.equal('hasOwnProperty', filename);
|
||||
} else {
|
||||
assert.equal(null, filename);
|
||||
}
|
||||
watcher.close();
|
||||
++watchSeenTwo;
|
||||
});
|
||||
}
|
||||
function() {
|
||||
var watcher = fs.watch(filepathTwo, function(event, filename) {
|
||||
assert.equal('change', event);
|
||||
if (expectFilePath) {
|
||||
assert.equal('hasOwnProperty', filename);
|
||||
} else {
|
||||
assert.equal(null, filename);
|
||||
}
|
||||
watcher.close();
|
||||
++watchSeenTwo;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(function() {
|
||||
fs.writeFileSync(filepathTwoAbs, "pardner");
|
||||
fs.writeFileSync(filepathTwoAbs, 'pardner');
|
||||
}, 1000);
|
||||
|
||||
try { fs.unlinkSync(filepathThree); } catch(e) {}
|
||||
try { fs.mkdirSync(testsubdir, 0700); } catch(e) {}
|
||||
try { fs.unlinkSync(filepathThree); } catch (e) {}
|
||||
try { fs.mkdirSync(testsubdir, 0700); } catch (e) {}
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
var watcher = fs.watch(testsubdir, function(event, filename) {
|
||||
assert.equal('rename', event);
|
||||
if (expectFilePath) {
|
||||
assert.equal('newfile.txt', filename);
|
||||
} else {
|
||||
assert.equal(null, filename);
|
||||
}
|
||||
watcher.close();
|
||||
++watchSeenThree;
|
||||
});
|
||||
}
|
||||
function() {
|
||||
var watcher = fs.watch(testsubdir, function(event, filename) {
|
||||
assert.equal('rename', event);
|
||||
if (expectFilePath) {
|
||||
assert.equal('newfile.txt', filename);
|
||||
} else {
|
||||
assert.equal(null, filename);
|
||||
}
|
||||
watcher.close();
|
||||
++watchSeenThree;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout(function() {
|
||||
var fd = fs.openSync(filepathThree, 'w');
|
||||
fs.closeSync(fd);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
|
@ -105,25 +105,25 @@ function test(handler, request_generator, response_validator) {
|
||||
assert.equal(1, req.httpVersionMajor);
|
||||
assert.equal(0, req.httpVersionMinor);
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
res.write("Hello, "); res._send('');
|
||||
res.write("world!"); res._send('');
|
||||
res.write('Hello, '); res._send('');
|
||||
res.write('world!'); res._send('');
|
||||
res.end();
|
||||
}
|
||||
|
||||
function request_generator() {
|
||||
return ("GET / HTTP/1.0\r\n"
|
||||
+ "User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n"
|
||||
+ "Host: 127.0.0.1:1337\r\n"
|
||||
+ "Accept: */*\r\n"
|
||||
+ "\r\n");
|
||||
return ('GET / HTTP/1.0\r\n' +
|
||||
'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' +
|
||||
'Host: 127.0.0.1:1337\r\n' +
|
||||
'Accept: */*\r\n' +
|
||||
'\r\n');
|
||||
}
|
||||
|
||||
function response_validator(server_response, client_got_eof, timed_out) {
|
||||
var expected_response = ("HTTP/1.1 200 OK\r\n"
|
||||
+ "Content-Type: text/plain\r\n"
|
||||
+ "Connection: close\r\n"
|
||||
+ "\r\n"
|
||||
+ "Hello, world!");
|
||||
var expected_response = ('HTTP/1.1 200 OK\r\n' +
|
||||
'Content-Type: text/plain\r\n' +
|
||||
'Connection: close\r\n' +
|
||||
'\r\n' +
|
||||
'Hello, world!');
|
||||
|
||||
assert.equal(expected_response, server_response.data);
|
||||
assert.equal(1, server_response.chunks.length);
|
||||
@ -140,32 +140,32 @@ function test(handler, request_generator, response_validator) {
|
||||
assert.equal(1, req.httpVersionMajor);
|
||||
assert.equal(1, req.httpVersionMinor);
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
res.write("Hello, "); res._send('');
|
||||
res.write("world!"); res._send('');
|
||||
res.write('Hello, '); res._send('');
|
||||
res.write('world!'); res._send('');
|
||||
res.end();
|
||||
}
|
||||
|
||||
function request_generator() {
|
||||
return ("GET / HTTP/1.1\r\n"
|
||||
+ "User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n"
|
||||
+ "Connection: close\r\n"
|
||||
+ "Host: 127.0.0.1:1337\r\n"
|
||||
+ "Accept: */*\r\n"
|
||||
+ "\r\n");
|
||||
return ('GET / HTTP/1.1\r\n' +
|
||||
'User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\n' +
|
||||
'Connection: close\r\n' +
|
||||
'Host: 127.0.0.1:1337\r\n' +
|
||||
'Accept: */*\r\n' +
|
||||
'\r\n');
|
||||
}
|
||||
|
||||
function response_validator(server_response, client_got_eof, timed_out) {
|
||||
var expected_response = ("HTTP/1.1 200 OK\r\n"
|
||||
+ "Content-Type: text/plain\r\n"
|
||||
+ "Connection: close\r\n"
|
||||
+ "Transfer-Encoding: chunked\r\n"
|
||||
+ "\r\n"
|
||||
+ "7\r\n"
|
||||
+ "Hello, \r\n"
|
||||
+ "6\r\n"
|
||||
+ "world!\r\n"
|
||||
+ "0\r\n"
|
||||
+ "\r\n");
|
||||
var expected_response = ('HTTP/1.1 200 OK\r\n' +
|
||||
'Content-Type: text/plain\r\n' +
|
||||
'Connection: close\r\n' +
|
||||
'Transfer-Encoding: chunked\r\n' +
|
||||
'\r\n' +
|
||||
'7\r\n' +
|
||||
'Hello, \r\n' +
|
||||
'6\r\n' +
|
||||
'world!\r\n' +
|
||||
'0\r\n' +
|
||||
'\r\n');
|
||||
|
||||
assert.equal(expected_response, server_response.data);
|
||||
assert.equal(1, server_response.chunks.length);
|
||||
@ -174,4 +174,4 @@ function test(handler, request_generator, response_validator) {
|
||||
}
|
||||
|
||||
test(handler, request_generator, response_validator);
|
||||
})();
|
||||
})();
|
||||
|
@ -19,43 +19,43 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require("../common");
|
||||
var http = require("http");
|
||||
var assert = require("assert");
|
||||
var common = require('../common');
|
||||
var http = require('http');
|
||||
var assert = require('assert');
|
||||
|
||||
var server = http.Server(function (req, res) {
|
||||
console.log("Server accepted request.");
|
||||
var server = http.Server(function(req, res) {
|
||||
console.log('Server accepted request.');
|
||||
res.writeHead(200);
|
||||
res.write("Part of my res.");
|
||||
res.write('Part of my res.');
|
||||
|
||||
res.destroy();
|
||||
});
|
||||
|
||||
var responseClose = false
|
||||
var responseClose = false;
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
var client = http.get({
|
||||
port: common.PORT,
|
||||
headers: { connection: "keep-alive" }
|
||||
headers: { connection: 'keep-alive' }
|
||||
|
||||
}, function(res) {
|
||||
server.close();
|
||||
|
||||
console.log("Got res: " + res.statusCode);
|
||||
console.log('Got res: ' + res.statusCode);
|
||||
console.dir(res.headers);
|
||||
|
||||
res.on("data", function (chunk) {
|
||||
console.log("Read " + chunk.length + " bytes");
|
||||
res.on('data', function(chunk) {
|
||||
console.log('Read ' + chunk.length + ' bytes');
|
||||
console.log(chunk.toString());
|
||||
});
|
||||
|
||||
res.on("end", function () {
|
||||
console.log("Response ended.");
|
||||
res.on('end', function() {
|
||||
console.log('Response ended.');
|
||||
});
|
||||
|
||||
// it would be nice if this worked:
|
||||
res.on("close", function () {
|
||||
console.log("Response aborted");
|
||||
res.on('close', function() {
|
||||
console.log('Response aborted');
|
||||
responseClose = true;
|
||||
});
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ var http = require('http');
|
||||
|
||||
var server = http.Server(function(req, res) {
|
||||
res.writeHead(200);
|
||||
res.end("hello world\n");
|
||||
res.end('hello world\n');
|
||||
});
|
||||
|
||||
var responses = 0;
|
||||
@ -37,9 +37,9 @@ var M = 10;
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
for (var i = 0; i < N; i++) {
|
||||
setTimeout(function () {
|
||||
setTimeout(function() {
|
||||
for (var j = 0; j < M; j++) {
|
||||
http.get({ port: common.PORT, path: '/', }, function(res) {
|
||||
http.get({ port: common.PORT, path: '/' }, function(res) {
|
||||
console.log(res.statusCode);
|
||||
if (++responses == N * M) server.close();
|
||||
}).on('error', function(e) {
|
||||
|
@ -43,9 +43,9 @@ function nextRequest() {
|
||||
console.error('writing request: %s', method);
|
||||
|
||||
var request = http.request({
|
||||
port: common.PORT,
|
||||
port: common.PORT,
|
||||
method: method,
|
||||
path: '/'
|
||||
path: '/'
|
||||
}, function(response) {
|
||||
response.on('end', function() {
|
||||
if (methods.length == 0) {
|
||||
|
@ -69,9 +69,9 @@ web.listen(common.PORT, function() {
|
||||
console.log('Making request');
|
||||
|
||||
var req = http.request({
|
||||
port: common.PORT,
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
port: common.PORT,
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
headers: { 'content-length': buffer.length }
|
||||
}, function(res) {
|
||||
console.log('Got response');
|
||||
|
@ -39,21 +39,25 @@ var server = http.createServer(function(req, res) {
|
||||
});
|
||||
server.listen(common.PORT, function() {
|
||||
var data = '';
|
||||
var get = http.get({path:'/', host:'localhost', port:common.PORT}, function (x) {
|
||||
x.setEncoding('utf8')
|
||||
x.on('data', function (c) {data += c});
|
||||
x.on('error', function (e) {
|
||||
var get = http.get({
|
||||
path: '/',
|
||||
host: 'localhost',
|
||||
port: common.PORT
|
||||
}, function(x) {
|
||||
x.setEncoding('utf8');
|
||||
x.on('data', function(c) {data += c});
|
||||
x.on('error', function(e) {
|
||||
throw e;
|
||||
})
|
||||
x.on('end', function () {
|
||||
});
|
||||
x.on('end', function() {
|
||||
assert.equal('string', typeof data);
|
||||
console.log('here is the response:');
|
||||
assert.equal(UTF8_STRING, data);
|
||||
console.log(data);
|
||||
server.close();
|
||||
})
|
||||
})
|
||||
get.on('error', function (e) {throw e});
|
||||
});
|
||||
});
|
||||
get.on('error', function(e) {throw e});
|
||||
get.end();
|
||||
|
||||
});
|
||||
|
@ -26,26 +26,26 @@ var http = require('http');
|
||||
var clientAborts = 0;
|
||||
|
||||
var server = http.Server(function(req, res) {
|
||||
console.log("Got connection");
|
||||
console.log('Got connection');
|
||||
res.writeHead(200);
|
||||
res.write("Working on it...");
|
||||
res.write('Working on it...');
|
||||
|
||||
// I would expect an error event from req or res that the client aborted
|
||||
// before completing the HTTP request / response cycle, or maybe a new
|
||||
// event like "aborted" or something.
|
||||
req.on("aborted", function () {
|
||||
req.on('aborted', function() {
|
||||
clientAborts++;
|
||||
console.log("Got abort " + clientAborts);
|
||||
console.log('Got abort ' + clientAborts);
|
||||
if (clientAborts === N) {
|
||||
console.log("All aborts detected, you win.");
|
||||
console.log('All aborts detected, you win.');
|
||||
server.close();
|
||||
}
|
||||
});
|
||||
|
||||
// since there is already clientError, maybe that would be appropriate,
|
||||
// since "error" is magical
|
||||
req.on("clientError", function () {
|
||||
console.log("Got clientError");
|
||||
req.on('clientError', function() {
|
||||
console.log('Got clientError');
|
||||
});
|
||||
});
|
||||
|
||||
@ -54,18 +54,18 @@ var N = http.Agent.defaultMaxSockets - 1;
|
||||
var requests = [];
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
console.log("Server listening.");
|
||||
console.log('Server listening.');
|
||||
|
||||
for (var i = 0; i < N; i++) {
|
||||
console.log("Making client " + i);
|
||||
console.log('Making client ' + i);
|
||||
var options = { port: common.PORT, path: '/?id=' + i };
|
||||
var req = http.get(options, function(res) {
|
||||
console.log("Client response code " + res.statusCode);
|
||||
console.log('Client response code ' + res.statusCode);
|
||||
|
||||
if (++responses == N) {
|
||||
console.log("All clients connected, destroying.");
|
||||
requests.forEach(function (outReq) {
|
||||
console.log("abort");
|
||||
console.log('All clients connected, destroying.');
|
||||
requests.forEach(function(outReq) {
|
||||
console.log('abort');
|
||||
outReq.abort();
|
||||
});
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ var parseError = false;
|
||||
|
||||
srv.listen(common.PORT, '127.0.0.1', function() {
|
||||
var req = http.request({
|
||||
host: '127.0.0.1',
|
||||
port: common.PORT,
|
||||
host: '127.0.0.1',
|
||||
port: common.PORT,
|
||||
method: 'GET',
|
||||
path: '/'});
|
||||
path: '/'});
|
||||
req.end();
|
||||
|
||||
req.on('error', function(e) {
|
||||
|
@ -47,9 +47,9 @@ server.listen(common.PORT);
|
||||
|
||||
server.addListener('listening', function() {
|
||||
var req = http.request({
|
||||
port: common.PORT,
|
||||
port: common.PORT,
|
||||
method: 'POST',
|
||||
path: '/'
|
||||
path: '/'
|
||||
}, function(res) {
|
||||
res.setEncoding('utf8');
|
||||
res.addListener('data', function(chunk) {
|
||||
|
@ -48,9 +48,9 @@ server.listen(common.PORT);
|
||||
|
||||
server.addListener('listening', function() {
|
||||
var req = http.request({
|
||||
port: common.PORT,
|
||||
port: common.PORT,
|
||||
method: 'POST',
|
||||
path: '/'
|
||||
path: '/'
|
||||
}, function(res) {
|
||||
res.setEncoding('utf8');
|
||||
res.addListener('data', function(chunk) {
|
||||
|
@ -53,4 +53,5 @@ function onListen() {
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(caughtError, true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
if (!process.versions.openssl) {
|
||||
console.error("Skipping because node compiled without OpenSSL.");
|
||||
console.error('Skipping because node compiled without OpenSSL.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ function maybeMakeRequest() {
|
||||
|
||||
|
||||
var ddcmd = common.ddCommand(filename, 10240);
|
||||
console.log("dd command: ", ddcmd);
|
||||
console.log('dd command: ', ddcmd);
|
||||
|
||||
cp.exec(ddcmd, function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
|
@ -40,7 +40,7 @@ var server = http.Server(function(req, res) {
|
||||
}, 100);
|
||||
|
||||
res.writeHead(200);
|
||||
res.end("hello world\n");
|
||||
res.end('hello world\n');
|
||||
});
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
|
@ -36,7 +36,7 @@ host += host;
|
||||
host += host;
|
||||
|
||||
function do_not_call() {
|
||||
throw new Error("This function should not have been called.");
|
||||
throw new Error('This function should not have been called.');
|
||||
}
|
||||
|
||||
function test(mod) {
|
||||
@ -44,17 +44,17 @@ function test(mod) {
|
||||
|
||||
// Bad host name should not throw an uncatchable exception.
|
||||
// Ensure that there is time to attach an error listener.
|
||||
var req = mod.get({host:host, port:42}, do_not_call);
|
||||
var req = mod.get({host: host, port: 42}, do_not_call);
|
||||
req.on('error', function(err) {
|
||||
assert.equal(err.code, 'EBADNAME');
|
||||
actual_bad_requests++;
|
||||
assert.equal(err.code, 'EBADNAME');
|
||||
actual_bad_requests++;
|
||||
});
|
||||
// http.get() called req.end() for us
|
||||
|
||||
var req = mod.request({method:'GET', host:host, port:42}, do_not_call);
|
||||
var req = mod.request({method: 'GET', host: host, port: 42}, do_not_call);
|
||||
req.on('error', function(err) {
|
||||
assert.equal(err.code, 'EBADNAME');
|
||||
actual_bad_requests++;
|
||||
assert.equal(err.code, 'EBADNAME');
|
||||
actual_bad_requests++;
|
||||
});
|
||||
req.end();
|
||||
}
|
||||
@ -67,4 +67,5 @@ test(http);
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(actual_bad_requests, expected_bad_requests);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
/*
|
||||
/*
|
||||
* Repeated requests for a domain that fails to resolve
|
||||
* should trigger the error event after each attempt.
|
||||
*/
|
||||
@ -28,32 +28,32 @@ var common = require('../common');
|
||||
var assert = require('assert');
|
||||
var http = require('http');
|
||||
|
||||
var resDespiteError = false
|
||||
var hadError = 0
|
||||
var resDespiteError = false;
|
||||
var hadError = 0;
|
||||
|
||||
function httpreq(count) {
|
||||
if ( 1 < count ) return
|
||||
if (1 < count) return;
|
||||
|
||||
var req = http.request({
|
||||
host:'not-a-real-domain-name.nobody-would-register-this-as-a-tld',
|
||||
host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld',
|
||||
port: 80,
|
||||
path: '/',
|
||||
method: 'GET'
|
||||
}, function(res) {
|
||||
resDespiteError = true
|
||||
resDespiteError = true;
|
||||
});
|
||||
|
||||
req.on('error', function(e){
|
||||
req.on('error', function(e) {
|
||||
console.log(e.message);
|
||||
assert.strictEqual(e.code, 'ENOTFOUND');
|
||||
hadError++
|
||||
httpreq(count + 1)
|
||||
})
|
||||
hadError++;
|
||||
httpreq(count + 1);
|
||||
});
|
||||
|
||||
req.end()
|
||||
req.end();
|
||||
}
|
||||
|
||||
httpreq(0)
|
||||
httpreq(0);
|
||||
|
||||
|
||||
process.on('exit', function() {
|
||||
|
@ -52,9 +52,9 @@ server.listen(common.PORT);
|
||||
|
||||
server.addListener('listening', function() {
|
||||
var req = http.request({
|
||||
port: common.PORT,
|
||||
method: 'POST',
|
||||
path: '/world',
|
||||
port: common.PORT,
|
||||
method: 'POST',
|
||||
path: '/world',
|
||||
headers: { 'Expect': '100-continue' }
|
||||
});
|
||||
common.debug('Client sending request...');
|
||||
|
@ -30,25 +30,25 @@ var net = require('net');
|
||||
|
||||
var body = 'hello world\r\n';
|
||||
var fullResponse =
|
||||
'HTTP/1.1 500 Internal Server Error\r\n' +
|
||||
'Content-Length: ' + body.length + '\r\n' +
|
||||
'Content-Type: text/plain\r\n' +
|
||||
'Date: Fri + 18 Feb 2011 06:22:45 GMT\r\n' +
|
||||
'Host: 10.20.149.2\r\n' +
|
||||
'Access-Control-Allow-Credentials: true\r\n' +
|
||||
'Server: badly broken/0.1 (OS NAME)\r\n' +
|
||||
'\r\n' +
|
||||
body;
|
||||
'HTTP/1.1 500 Internal Server Error\r\n' +
|
||||
'Content-Length: ' + body.length + '\r\n' +
|
||||
'Content-Type: text/plain\r\n' +
|
||||
'Date: Fri + 18 Feb 2011 06:22:45 GMT\r\n' +
|
||||
'Host: 10.20.149.2\r\n' +
|
||||
'Access-Control-Allow-Credentials: true\r\n' +
|
||||
'Server: badly broken/0.1 (OS NAME)\r\n' +
|
||||
'\r\n' +
|
||||
body;
|
||||
|
||||
var gotResponse = false;
|
||||
|
||||
|
||||
var server = net.createServer(function (socket) {
|
||||
var server = net.createServer(function(socket) {
|
||||
var postBody = '';
|
||||
|
||||
socket.setEncoding('utf8');
|
||||
|
||||
socket.on('data', function (chunk) {
|
||||
socket.on('data', function(chunk) {
|
||||
postBody += chunk;
|
||||
|
||||
if (postBody.indexOf('\r\n') > -1) {
|
||||
@ -66,11 +66,11 @@ server.listen(common.PORT, function() {
|
||||
console.log('Got res code: ' + res.statusCode);
|
||||
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', function (chunk) {
|
||||
res.on('data', function(chunk) {
|
||||
buffer += chunk;
|
||||
});
|
||||
|
||||
res.on('end', function () {
|
||||
res.on('end', function() {
|
||||
console.log('Response ended, read ' + buffer.length + ' bytes');
|
||||
assert.equal(body, buffer);
|
||||
server.close();
|
||||
|
@ -32,7 +32,7 @@ var fs = require('fs');
|
||||
|
||||
var image = fs.readFileSync(common.fixturesDir + '/person.jpg');
|
||||
|
||||
console.log("image.length = " + image.length);
|
||||
console.log('image.length = ' + image.length);
|
||||
|
||||
var total = 100;
|
||||
var requests = 0, responses = 0;
|
||||
@ -64,20 +64,20 @@ server.listen(common.PORT, function() {
|
||||
};
|
||||
|
||||
http.get(opts, function(res) {
|
||||
console.error("recv " + x);
|
||||
var s = fs.createWriteStream(common.tmpDir + '/' + x + ".jpg");
|
||||
console.error('recv ' + x);
|
||||
var s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg');
|
||||
res.pipe(s);
|
||||
|
||||
// TODO there should be a callback to pipe() that will allow
|
||||
// us to get a callback when the pipe is finished.
|
||||
res.on('end', function() {
|
||||
console.error("done " + x);
|
||||
console.error('done ' + x);
|
||||
if (++responses == total) {
|
||||
s.on('close', checkFiles);
|
||||
}
|
||||
});
|
||||
}).on('error', function(e) {
|
||||
console.error('error! ', e.message)
|
||||
console.error('error! ', e.message);
|
||||
throw e;
|
||||
});
|
||||
})();
|
||||
@ -97,7 +97,7 @@ function checkFiles() {
|
||||
var stat = fs.statSync(common.tmpDir + '/' + fn);
|
||||
assert.equal(image.length, stat.size,
|
||||
"size doesn't match on '" + fn +
|
||||
"'. Got " + stat.size + " bytes");
|
||||
"'. Got " + stat.size + ' bytes');
|
||||
}
|
||||
|
||||
checkedFiles = true;
|
||||
|
@ -38,9 +38,9 @@ var gotEnd = false;
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
var request = http.request({
|
||||
port: common.PORT,
|
||||
port: common.PORT,
|
||||
method: 'HEAD',
|
||||
path: '/'
|
||||
path: '/'
|
||||
}, function(response) {
|
||||
common.error('response start');
|
||||
response.addListener('end', function() {
|
||||
|
@ -41,9 +41,9 @@ var responseComplete = false;
|
||||
|
||||
server.addListener('listening', function() {
|
||||
var req = http.request({
|
||||
port: common.PORT,
|
||||
port: common.PORT,
|
||||
method: 'HEAD',
|
||||
path: '/'
|
||||
path: '/'
|
||||
}, function(res) {
|
||||
common.error('response');
|
||||
res.addListener('end', function() {
|
||||
|
@ -35,9 +35,9 @@ var s = http.createServer(function(req, res) {
|
||||
// This checks that after the headers have been sent, getHeader works
|
||||
// and does not throw an exception (Issue 752)
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
assert.equal(plain, res.getHeader(contentType));
|
||||
}
|
||||
function() {
|
||||
assert.equal(plain, res.getHeader(contentType));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -153,7 +153,7 @@ function testHttps() {
|
||||
host: 'localhost',
|
||||
//agent: false,
|
||||
port: common.PORT }, cb).on('error', thrower).end();
|
||||
|
||||
|
||||
https.get({ method: 'GET',
|
||||
path: '/setHostFalse' + (counter++),
|
||||
host: 'localhost',
|
||||
|
@ -37,37 +37,55 @@ var connectCount = 0;
|
||||
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
var agent = new http.Agent({maxSockets:1})
|
||||
var request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function () {
|
||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
||||
var agent = new http.Agent({ maxSockets: 1 });
|
||||
var request = http.request({
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
headers: headers,
|
||||
port: common.PORT,
|
||||
agent: agent
|
||||
}, function() {
|
||||
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||
});
|
||||
request.on('socket', function (s) {
|
||||
s.on('connect', function () {
|
||||
request.on('socket', function(s) {
|
||||
s.on('connect', function() {
|
||||
connectCount++;
|
||||
})
|
||||
})
|
||||
request.end();
|
||||
|
||||
request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function () {
|
||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
||||
});
|
||||
});
|
||||
request.on('socket', function (s) {
|
||||
s.on('connect', function () {
|
||||
connectCount++;
|
||||
})
|
||||
})
|
||||
request.end();
|
||||
request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function(response) {
|
||||
|
||||
request = http.request({
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
headers: headers,
|
||||
port: common.PORT,
|
||||
agent: agent
|
||||
}, function() {
|
||||
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||
});
|
||||
request.on('socket', function(s) {
|
||||
s.on('connect', function() {
|
||||
connectCount++;
|
||||
});
|
||||
});
|
||||
request.end();
|
||||
request = http.request({
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
headers: headers,
|
||||
port: common.PORT,
|
||||
agent: agent
|
||||
}, function(response) {
|
||||
response.addListener('end', function() {
|
||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
||||
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
request.on('socket', function (s) {
|
||||
s.on('connect', function () {
|
||||
request.on('socket', function(s) {
|
||||
s.on('connect', function() {
|
||||
connectCount++;
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
request.end();
|
||||
});
|
||||
|
||||
|
@ -36,19 +36,19 @@ var server = http.createServer(function(req, res) {
|
||||
var connectCount = 0;
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
var agent = new http.Agent({maxSockets:1})
|
||||
var request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function () {
|
||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
||||
var agent = new http.Agent({maxSockets: 1});
|
||||
var request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function() {
|
||||
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||
});
|
||||
request.end();
|
||||
|
||||
request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function () {
|
||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
||||
|
||||
request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function() {
|
||||
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||
});
|
||||
request.end();
|
||||
request = http.request({method:'GET', path:'/', headers:headers, port:common.PORT, agent:agent}, function(response) {
|
||||
request = http.request({method: 'GET', path: '/', headers: headers, port: common.PORT, agent: agent}, function(response) {
|
||||
response.addListener('end', function() {
|
||||
assert.equal(1, agent.sockets['localhost:'+common.PORT].length)
|
||||
assert.equal(1, agent.sockets['localhost:' + common.PORT].length);
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
|
@ -32,7 +32,7 @@ var server = http.Server(function(req, res) {
|
||||
requests++;
|
||||
assert.equal(req.connection, connection);
|
||||
res.writeHead(200);
|
||||
res.end("hello world\n");
|
||||
res.end('hello world\n');
|
||||
});
|
||||
|
||||
server.once('connection', function(c) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user