This commit is contained in:
Blake Mizerany 2010-06-29 23:12:46 -07:00 коммит произвёл Ryan Dahl
Родитель f8ca6b383c
Коммит 8c8534046c
38 изменённых файлов: 96 добавлений и 96 удалений

Просмотреть файл

@ -28,7 +28,7 @@ http.createServer(function (req, res) {
if (command == "bytes") {
var n = parseInt(arg, 10)
if (n <= 0)
throw "bytes called with n <= 0"
throw "bytes called with n <= 0"
if (stored[n] === undefined) {
console.log("create stored[n]");
stored[n] = "";
@ -64,7 +64,7 @@ http.createServer(function (req, res) {
var content_length = body.length.toString();
res.writeHead( status
res.writeHead( status
, { "Content-Type": "text/plain"
, "Content-Length": content_length
}

Просмотреть файл

@ -7,45 +7,45 @@ end
def wait(seconds)
n = (seconds / 0.01).to_i
n.times do
n.times do
sleep(0.01)
#File.read(DIR + '/yahoo.html')
#File.read(DIR + '/yahoo.html')
end
end
class SimpleApp
@@responses = {}
def initialize
@count = 0
end
def deferred?(env)
false
end
def call(env)
path = env['PATH_INFO'] || env['REQUEST_URI']
commands = path.split('/')
@count += 1
if commands.include?('periodical_activity') and @count % 10 != 1
return [200, {'Content-Type'=>'text/plain'}, "quick response!\r\n"]
end
if commands.include?('fibonacci')
n = commands.last.to_i
raise "fibonacci called with n <= 0" if n <= 0
body = (1..n).to_a.map { |i| fib(i).to_s }.join(' ')
status = 200
elsif commands.include?('wait')
n = commands.last.to_f
raise "wait called with n <= 0" if n <= 0
wait(n)
body = "waited about #{n} seconds"
status = 200
elsif commands.include?('bytes')
n = commands.last.to_i
raise "bytes called with n <= 0" if n <= 0
@ -56,17 +56,17 @@ class SimpleApp
n = 20 * 1024;
body = @@responses[n] || "C"*n
status = 200
elsif commands.include?('test_post_length')
input_body = ""
while chunk = env['rack.input'].read(512)
input_body << chunk
input_body << chunk
end
if env['CONTENT_LENGTH'].to_i == input_body.length
body = "Content-Length matches input length"
status = 200
else
body = "Content-Length doesn't matches input length!
body = "Content-Length doesn't matches input length!
content_length = #{env['CONTENT_LENGTH'].to_i}
input_body.length = #{input_body.length}"
status = 500
@ -75,7 +75,7 @@ class SimpleApp
status = 404
body = "Undefined url"
end
body += "\r\n"
headers = {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }
[status, headers, [body]]
@ -90,6 +90,6 @@ if $0 == __FILE__
require 'thin'
require 'ebb'
# Rack::Handler::Mongrel.run(SimpleApp.new, :Port => 8000)
Thin::Server.start("0.0.0.0", 8000, SimpleApp.new)
Thin::Server.start("0.0.0.0", 8000, SimpleApp.new)
# Ebb::start_server(SimpleApp.new, :port => 8000)
end

Просмотреть файл

@ -3596,7 +3596,7 @@ try {
var Verify = binding.Verify;
var crypto = true;
} catch (e) {
var crypto = false;
}

Просмотреть файл

@ -363,7 +363,7 @@ function setImplmentationMethods (self) {
return bytesWritten;
};
var oldRead = self._readImpl;
self._readImpl = function(buf, off, len, calledByIOWatcher) {
assert(self.secure);

Просмотреть файл

@ -164,7 +164,7 @@ Interface.prototype._ttyWrite = function (b) {
if (this.cursor === 0 && this.line.length === 0) {
this.close();
} else if (this.cursor < this.line.length) {
this.line = this.line.slice(0, this.cursor)
this.line = this.line.slice(0, this.cursor)
+ this.line.slice(this.cursor+1, this.line.length)
;
this._refreshLine();

Просмотреть файл

@ -137,14 +137,14 @@ REPLServer.prototype.readline = function (cmd) {
/**
* Used to parse and execute the Node REPL commands.
*
*
* @param {cmd} cmd The command entered to check
* @returns {Boolean} If true it means don't continue parsing the command
* @returns {Boolean} If true it means don't continue parsing the command
*/
REPLServer.prototype.parseREPLKeyword = function (cmd) {
var self = this;
switch (cmd) {
case ".break":
self.buffered_cmd = '';
@ -171,7 +171,7 @@ REPLServer.prototype.parseREPLKeyword = function (cmd) {
};
function trimWhitespace (cmd) {
var trimmer = /^\s*(.+)\s*$/m,
var trimmer = /^\s*(.+)\s*$/m,
matches = trimmer.exec(cmd);
if (matches && matches.length === 2) {
@ -183,7 +183,7 @@ function trimWhitespace (cmd) {
* Converts commands that use var and function <name>() to use the
* local exports.context when evaled. This provides a local context
* on the REPL.
*
*
* @param {String} cmd The cmd to convert
* @returns {String} The converted command
*/
@ -191,18 +191,18 @@ REPLServer.prototype.convertToContext = function (cmd) {
var self = this, matches,
scopeVar = /^\s*var\s*([_\w\$]+)(.*)$/m,
scopeFunc = /^\s*function\s*([_\w\$]+)/;
// Replaces: var foo = "bar"; with: self.context.foo = bar;
matches = scopeVar.exec(cmd);
if (matches && matches.length === 3) {
return "self.context." + matches[1] + matches[2];
}
// Replaces: function foo() {}; with: foo = function foo() {};
matches = scopeFunc.exec(self.buffered_cmd);
if (matches && matches.length === 2) {
return matches[1] + " = " + self.buffered_cmd;
}
return cmd;
};

Просмотреть файл

@ -11,7 +11,7 @@ var StringDecoder = exports.StringDecoder = function (encoding) {
StringDecoder.prototype.write = function (buffer) {
// If not utf8...
// If not utf8...
if (this.encoding !== 'utf8') {
return buffer.toString(this.encoding);
}

Просмотреть файл

@ -1166,7 +1166,7 @@ static Handle<Value> SetGid(const Arguments& args) {
}
int gid;
if (args[0]->IsNumber()) {
gid = args[0]->Int32Value();
} else if (args[0]->IsString()) {

Просмотреть файл

@ -509,8 +509,8 @@ Handle<Value> Buffer::ByteLength(const Arguments &args) {
enum encoding e = ParseEncoding(args[1], UTF8);
Local<Integer> length =
Integer::New(e == UTF8 ? s->Utf8Length() : s->Length());
Integer::New(e == UTF8 ? s->Utf8Length() : s->Length());
return scope.Close(length);
}

Просмотреть файл

@ -24,7 +24,7 @@ using namespace v8;
static Handle<Value> IsIP(const Arguments& args) {
HandleScope scope;
if (!args[0]->IsString()) {
return scope.Close(Integer::New(4));
}

Просмотреть файл

@ -1004,7 +1004,7 @@ class Cipher : public ObjectWrap {
delete [] buf;
Local<Value> outString;
if (out_len==0) {
if (out_len==0) {
outString=String::New("");
} else {
if (args.Length() <= 2 || !args[2]->IsString()) {

Просмотреть файл

@ -432,7 +432,7 @@ static Handle<Value> MKDir(const Arguments& args) {
static Handle<Value> SendFile(const Arguments& args) {
HandleScope scope;
if (args.Length() < 4 ||
if (args.Length() < 4 ||
!args[0]->IsInt32() ||
!args[1]->IsInt32() ||
!args[3]->IsNumber()) {
@ -704,7 +704,7 @@ void File::Initialize(Handle<Object> target) {
NODE_SET_METHOD(target, "readlink", ReadLink);
NODE_SET_METHOD(target, "unlink", Unlink);
NODE_SET_METHOD(target, "write", Write);
NODE_SET_METHOD(target, "chmod", Chmod);
NODE_SET_METHOD(target, "chown", Chown);

Просмотреть файл

@ -21,7 +21,7 @@
// No copying is performed when slicing the buffer, only small reference
// allocations.
namespace node {
using namespace v8;
@ -194,7 +194,7 @@ class Parser : public ObjectWrap {
String::Utf8Value type(args[0]->ToString());
Parser *parser;
Parser *parser;
if (0 == strcasecmp(*type, "request")) {
parser = new Parser(HTTP_REQUEST);
@ -257,7 +257,7 @@ class Parser : public ObjectWrap {
if (parser->got_exception_) return Local<Value>();
Local<Integer> nparsed_obj = Integer::New(nparsed);
// If there was a parse error in one of the callbacks
// If there was a parse error in one of the callbacks
// TODO What if there is an error on EOF?
if (!parser->parser_.upgrade && nparsed != len) {
Local<Value> e = Exception::Error(String::NewSymbol("Parse Error"));
@ -333,7 +333,7 @@ static Handle<Value> UrlDecode (const Arguments& args) {
enum { CHAR, HEX0, HEX1 } state = CHAR;
int n, m, hexchar;
int n, m, hexchar;
size_t in_index = 0, out_index = 0;
char c;
for (; in_index <= l; in_index++) {

Просмотреть файл

@ -38,7 +38,7 @@ Handle<Value> IdleWatcher::SetPriority(const Arguments& args) {
HandleScope scope;
int priority = args[0]->Int32Value();
ev_set_priority(&idle->watcher_, priority);
return Undefined();
@ -71,7 +71,7 @@ void IdleWatcher::Callback(EV_P_ ev_idle *w, int revents) {
}
//
//
// var idle = new process.IdleWatcher();
// idle.callback = function () { /* ... */ };
// idle.start();

Просмотреть файл

@ -61,7 +61,7 @@ void IOWatcher::Callback(EV_P_ ev_io *w, int revents) {
}
//
//
// var io = new process.IOWatcher();
// process.callback = function (readable, writable) { ... };
// io.set(fd, true, false);

Просмотреть файл

@ -214,7 +214,7 @@ static inline Handle<Value> ParseAddressArgs(Handle<Value> first,
memset(&in6, 0, sizeof in6);
int port = first->Int32Value();
in.sin_port = in6.sin6_port = htons(port);
in.sin_port = in6.sin6_port = htons(port);
in.sin_family = AF_INET;
in6.sin6_family = AF_INET6;
@ -241,7 +241,7 @@ static inline Handle<Value> ParseAddressArgs(Handle<Value> first,
}
// Bind with UNIX
// Bind with UNIX
// t.bind(fd, "/tmp/socket")
// Bind with TCP
// t.bind(fd, 80, "192.168.11.2")
@ -486,7 +486,7 @@ static Handle<Value> SocketError(const Arguments& args) {
return ThrowException(ErrnoException(errno, "getsockopt"));
}
return scope.Close(Integer::New(error));
return scope.Close(Integer::New(error));
}
@ -572,7 +572,7 @@ static Handle<Value> RecvFrom(const Arguments& args) {
struct sockaddr_storage address_storage;
socklen_t addrlen = sizeof(struct sockaddr_storage);
ssize_t bytes_read = recvfrom(fd, (char*)buffer->data() + off, len, flags,
ssize_t bytes_read = recvfrom(fd, (char*)buffer->data() + off, len, flags,
(struct sockaddr*) &address_storage, &addrlen);
if (bytes_read < 0) {
@ -653,7 +653,7 @@ static Handle<Value> RecvMsg(const Arguments& args) {
//
// XXX: Some implementations can send multiple file descriptors in a
// single message. We should be using CMSG_NXTHDR() to walk the
// chain to get at them all. This would require changing the
// chain to get at them all. This would require changing the
// API to hand these back up the caller, is a pain.
int received_fd = -1;
@ -696,7 +696,7 @@ static Handle<Value> Write(const Arguments& args) {
FD_ARG(args[0])
if (!Buffer::HasInstance(args[1])) {
if (!Buffer::HasInstance(args[1])) {
return ThrowException(Exception::TypeError(
String::New("Second argument should be a buffer")));
}
@ -1177,7 +1177,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
static Handle<Value> IsIP(const Arguments& args) {
HandleScope scope;
if (!args[0]->IsString()) {
return scope.Close(Integer::New(4));
}
@ -1206,7 +1206,7 @@ static Handle<Value> CreateErrnoException(const Arguments& args) {
int errorno = args[0]->Int32Value();
String::Utf8Value syscall(args[1]->ToString());
Local<Value> exception = ErrnoException(errorno, *syscall);
Local<Value> exception = ErrnoException(errorno, *syscall);
return scope.Close(exception);
}

Просмотреть файл

@ -181,7 +181,7 @@ template <node::Script::EvalInputFlags iFlag,
}
const int fnIndex = sbIndex + (cFlag == newContext ? 1 : 0);
Local<String> filename = args.Length() > fnIndex
Local<String> filename = args.Length() > fnIndex
? args[fnIndex]->ToString()
: String::New("evalmachine.<anonymous>");
@ -253,7 +253,7 @@ template <node::Script::EvalInputFlags iFlag,
if (!nScript) {
return ThrowException(Exception::Error(
String::New("Must be called as a method of Script.")));
}
}
nScript->script_ = Persistent<v8::Script>::New(script);
result = args.This();
}

Просмотреть файл

@ -22,7 +22,7 @@ void SignalWatcher::Initialize(Handle<Object> target) {
target->Set(String::NewSymbol("SignalWatcher"),
constructor_template->GetFunction());
callback_symbol = NODE_PSYMBOL("callback");
}

Просмотреть файл

@ -21,7 +21,7 @@ class SignalWatcher : ObjectWrap {
ev_signal_init(&watcher_, SignalWatcher::Callback, sig);
watcher_.data = this;
}
~SignalWatcher() {
ev_signal_stop(EV_DEFAULT_UC_ &watcher_);
}
@ -32,10 +32,10 @@ class SignalWatcher : ObjectWrap {
private:
static void Callback(EV_P_ ev_signal *watcher, int revents);
void Start();
void Stop();
ev_signal watcher_;
};

Просмотреть файл

@ -21,7 +21,7 @@ var hosts = ['example.com',
'google.com', // MX, multiple A records
'_xmpp-client._tcp.google.com', // SRV
'oakalynhall.co.uk' // Multiple PTR replies
];
];
var records = ['A', 'AAAA', 'MX', 'TXT', 'SRV'];
@ -58,12 +58,12 @@ function checkDnsRecord(host, record) {
while (ll--) {
var ip = result[ll];
var reverseCmd = "host " + ip +
"| cut -d \" \" -f 5-" +
"| cut -d \" \" -f 5-" +
"| sed -e 's/\\.$//'";
child_process.exec(reverseCmd, checkReverse(ip));
}
});
});
break;
case "MX":
dns.resolve(myHost, myRecord, function (error, result, ttl, cname) {

2
test/fixtures/b/c.js поставляемый
Просмотреть файл

@ -11,7 +11,7 @@ debug("load fixtures/b/c.js");
var string = "C";
exports.SomeClass = function() {
};
exports.C = function () {

Просмотреть файл

@ -1,4 +1,4 @@
var exec = require('child_process').exec,
var exec = require('child_process').exec,
puts = require('sys').puts;
[0, 1].forEach(function(i) {

Просмотреть файл

@ -102,7 +102,7 @@ try {
have_tls=true;
} catch (e) {
have_tls=false;
}
}
if (have_tls) {
var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem");

Просмотреть файл

@ -5,7 +5,7 @@ try {
} catch (e) {
console.log("Not compiled with OPENSSL support.");
process.exit();
}
}
var fs = require('fs');
var sys = require('sys');
@ -68,7 +68,7 @@ var encryption_key = '0123456789abcd0123456789';
var iv = '12345678';
var cipher = crypto.createCipheriv("des-ede3-cbc", encryption_key, iv);
var ciph = cipher.update(plaintext, 'utf8', 'hex');
var ciph = cipher.update(plaintext, 'utf8', 'hex');
ciph += cipher.final('hex');
var decipher = crypto.createDecipheriv("des-ede3-cbc",encryption_key,iv);

Просмотреть файл

@ -12,7 +12,7 @@ for (var i = 0; i < N; i++) {
} else {
throw new Error("this shouldn't be called");
}
});
});
}
process.addListener("exit", function () {

Просмотреть файл

@ -43,7 +43,7 @@ assert.equal(2, e.listeners("foo").length)
e.removeAllListeners("foo")
assert.equal(0, e.listeners("foo").length)
// Verify that removing callbacks while in emit allows emits to propagate to
// Verify that removing callbacks while in emit allows emits to propagate to
// all listeners
callbacks_called = [ ];

Просмотреть файл

@ -12,7 +12,7 @@ fs.chmod(file, 0777, function (err) {
} else {
console.log(fs.statSync(file).mode);
assert.equal(0777, fs.statSync(file).mode & 0777);
fs.chmodSync(file, 0644);
assert.equal(0644, fs.statSync(file).mode & 0777);
success_count++;

Просмотреть файл

@ -158,6 +158,6 @@ try {
}
process.addListener('exit', function () {
assert.equal(expected, errors.length,
assert.equal(expected, errors.length,
'Test fs sync exceptions raised, got ' + errors.length + ' expected ' + expected);
});

Просмотреть файл

@ -9,7 +9,7 @@ function asynctest(testBlock, args, callback, assertBlock) {
var ignoreError = false;
if (assertBlock) {
try {
ignoreError = assertBlock.apply(assertBlock,
ignoreError = assertBlock.apply(assertBlock,
Array.prototype.slice.call(arguments));
}
catch (e) {
@ -106,7 +106,7 @@ function test_deep_relative_dir_symlink(callback) {
unlink.push(entry);
assert.equal(fs.realpathSync(entry), expected);
asynctest(fs.realpath, [entry], callback, function(err, result){
assert.equal(result, expected,
'got '+inspect(result)+' expected '+inspect(expected));
@ -168,9 +168,9 @@ function test_deep_symlink_mix(callback) {
/tmp/node-test-realpath-f1 -> ../tmp/node-test-realpath-d1/foo
/tmp/node-test-realpath-d1 -> ../node-test-realpath-d2
/tmp/node-test-realpath-d2/foo -> ../node-test-realpath-f2
/tmp/node-test-realpath-f2
/tmp/node-test-realpath-f2
-> /node/test/fixtures/nested-index/one/realpath-c
/node/test/fixtures/nested-index/one/realpath-c
/node/test/fixtures/nested-index/one/realpath-c
-> /node/test/fixtures/nested-index/two/realpath-c
/node/test/fixtures/nested-index/two/realpath-c -> ../../cycles/root.js
/node/test/fixtures/cycles/root.js (hard)

Просмотреть файл

@ -27,10 +27,10 @@ server.listen(PORT, function () {
});
http.cat("http://localhost:12312/", "utf8", function (err, content) {
if (err) {
if (err) {
console.log("got error (this should happen)");
bad_server_got_error = true;
}
}
});
});

Просмотреть файл

@ -16,7 +16,7 @@ try {
have_openssl=false;
console.log("Not compiled with OPENSSL support.");
process.exit();
}
}
var request_number = 0;
var requests_sent = 0;

Просмотреть файл

@ -31,7 +31,7 @@ var parseHeaders = function(data) {
return o;
};
// Create a TCP server
// Create a TCP server
var srv = net.createServer(function(c) {
var data = '';
c.addListener('data', function(d) {

Просмотреть файл

@ -10,7 +10,7 @@ server = http.createServer(function (req, res) {
server.addListener('upgrade', function (req, socket, upgradeHead) {
error('got upgrade event');
// test that throwing an error from upgrade gets
// test that throwing an error from upgrade gets
// is uncaught
throw new Error('upgrade error');
});

Просмотреть файл

@ -4,17 +4,17 @@ http = require("http");
// wget sends an HTTP/1.0 request with Connection: Keep-Alive
//
// Sending back a chunked response to an HTTP/1.0 client would be wrong,
// so what has to happen in this case is that the connection is closed
// by the server after the entity body if the Content-Length was not
// Sending back a chunked response to an HTTP/1.0 client would be wrong,
// so what has to happen in this case is that the connection is closed
// by the server after the entity body if the Content-Length was not
// sent.
//
// If the Content-Length was sent, we can probably safely honor the
// keep-alive request, even though HTTP 1.0 doesn't say that the
// connection can be kept open. Presumably any client sending this
// header knows that it is extending HTTP/1.0 and can handle the
// response. We don't test that here however, just that if the
// content-length is not provided, that the connection is in fact
// If the Content-Length was sent, we can probably safely honor the
// keep-alive request, even though HTTP 1.0 doesn't say that the
// connection can be kept open. Presumably any client sending this
// header knows that it is extending HTTP/1.0 and can handle the
// response. We don't test that here however, just that if the
// content-length is not provided, that the connection is in fact
// closed.
var server_response = "";

Просмотреть файл

@ -9,7 +9,7 @@ for (var i = 255; i >= 0; i--) {
+ " "
+ JSON.stringify(S)
+ " "
+ JSON.stringify(String.fromCharCode(i))
+ JSON.stringify(String.fromCharCode(i))
+ " "
+ S.charCodeAt(0)
);

Просмотреть файл

@ -11,7 +11,7 @@ try {
have_openssl=false;
console.log("Not compiled with OPENSSL support.");
process.exit();
}
}
var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem", 'ascii');
var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem", 'ascii');

Просмотреть файл

@ -59,7 +59,7 @@ var logChild = function(d) {
};
// Create a pipe
//
//
// We establish a listener on the read end of the pipe so that we can
// validate any data sent back by the child. We send the write end of the
// pipe to the child and close it off in our process.

Просмотреть файл

@ -169,10 +169,10 @@ for (var u in parseTests) {
a = JSON.stringify(actual[i]);
assert.equal(e, a, "parse(" + u + ")."+i+" == "+e+"\nactual: "+a);
}
var expected = u,
actual = url.format(parseTests[u]);
assert.equal(expected, actual, "format("+u+") == "+u+"\nactual:"+actual);
}
@ -250,13 +250,13 @@ for (var u in formatTests) {
});
//
//
// Tests below taken from Chiron
// http://code.google.com/p/chironjs/source/browse/trunk/src/test/http/url.js
//
//
// Copyright (c) 2002-2008 Kris Kowal <http://cixar.com/~kris.kowal>
// used with permission under MIT License
//
//
// Changes marked with @isaacs
var bases = [
@ -392,7 +392,7 @@ var bases = [
['./' , bases[3], 'fred:///s//a/b/'],
['../' , bases[3], 'fred:///s//a/'],
['../g' , bases[3], 'fred:///s//a/g'],
['../../' , bases[3], 'fred:///s//'],
['../../g' , bases[3], 'fred:///s//g'],
['../../../g', bases[3], 'fred:///s/g'],
@ -512,5 +512,5 @@ var bases = [
assert.equal(e, a,
"resolve("+[relativeTest[1], relativeTest[0]]+") == "+e+
"\n actual="+a);
});
});