Browse Source

Fix global leaks

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
a0159b4b29
  1. 2
      lib/http.js
  2. 2
      lib/string_decoder.js
  3. 4
      test/disabled/test-dns.js
  4. 4
      test/disabled/test-eio-race3.js
  5. 4
      test/disabled/test-fs-sendfile.js
  6. 4
      test/disabled/test-http-big-proxy-responses.js
  7. 4
      test/disabled/test-http-head-request.js
  8. 4
      test/disabled/test-http-stress.js
  9. 4
      test/disabled/test-http-tls.js
  10. 4
      test/disabled/test-idle-watcher.js
  11. 4
      test/disabled/test-net-tls-pummel.js
  12. 4
      test/disabled/test-net-tls.js
  13. 4
      test/disabled/test-readline.js
  14. 4
      test/disabled/test-remote-module-loading.js
  15. 4
      test/disabled/test-setuidgid.js
  16. 4
      test/disabled/tls_client.js
  17. 4
      test/disabled/tls_server.js
  18. 2
      test/fixtures/a.js
  19. 2
      test/fixtures/b/c.js
  20. 2
      test/fixtures/b/d.js
  21. 2
      test/fixtures/b/package/index.js
  22. 4
      test/fixtures/echo.js
  23. 4
      test/fixtures/print-chars-from-buffer.js
  24. 4
      test/fixtures/print-chars.js
  25. 4
      test/pummel/test-child-process-spawn-loop.js
  26. 4
      test/pummel/test-http-client-reconnect-bug.js
  27. 4
      test/pummel/test-keep-alive.js
  28. 4
      test/pummel/test-net-many-clients.js
  29. 4
      test/pummel/test-net-pingpong-delay.js
  30. 4
      test/pummel/test-net-pingpong.js
  31. 4
      test/pummel/test-net-throttle.js
  32. 4
      test/pummel/test-net-timeout.js
  33. 4
      test/pummel/test-timers.js
  34. 4
      test/pummel/test-watch-file.js
  35. 7
      test/simple/test-assert.js
  36. 4
      test/simple/test-c-ares.js
  37. 4
      test/simple/test-chdir.js
  38. 4
      test/simple/test-child-process-buffering.js
  39. 4
      test/simple/test-child-process-custom-fds.js
  40. 8
      test/simple/test-child-process-cwd.js
  41. 2
      test/simple/test-child-process-deprecated-api.js
  42. 8
      test/simple/test-child-process-env.js
  43. 4
      test/simple/test-child-process-exec-cwd.js
  44. 12
      test/simple/test-child-process-exec-env.js
  45. 18
      test/simple/test-child-process-exit-code.js
  46. 4
      test/simple/test-child-process-ipc.js
  47. 4
      test/simple/test-child-process-kill.js
  48. 4
      test/simple/test-child-process-stdin.js
  49. 6
      test/simple/test-child-process-stdout-flush.js
  50. 4
      test/simple/test-console.js
  51. 6
      test/simple/test-crypto.js
  52. 5
      test/simple/test-delayed-require.js
  53. 6
      test/simple/test-dgram-multicast.js
  54. 4
      test/simple/test-dgram-pingpong.js
  55. 4
      test/simple/test-dgram-udp4.js
  56. 4
      test/simple/test-dgram-unix-anon.js
  57. 20
      test/simple/test-dgram-unix.js
  58. 4
      test/simple/test-eio-race.js
  59. 6
      test/simple/test-eio-race2.js
  60. 4
      test/simple/test-eio-race4.js
  61. 10
      test/simple/test-error-reporting.js
  62. 4
      test/simple/test-event-emitter-add-listeners.js
  63. 4
      test/simple/test-event-emitter-modify-in-emit.js
  64. 4
      test/simple/test-event-emitter-num-args.js
  65. 4
      test/simple/test-event-emitter-once.js
  66. 12
      test/simple/test-event-emitter-remove-listeners.js
  67. 4
      test/simple/test-exception-handler.js
  68. 4
      test/simple/test-exception-handler2.js
  69. 8
      test/simple/test-exec.js
  70. 12
      test/simple/test-executable-path.js
  71. 4
      test/simple/test-file-read-noexist.js
  72. 4
      test/simple/test-file-write-stream.js
  73. 4
      test/simple/test-fs-chmod.js
  74. 4
      test/simple/test-fs-error-messages.js
  75. 4
      test/simple/test-fs-fsync.js
  76. 4
      test/simple/test-fs-read-buffer.js
  77. 4
      test/simple/test-fs-read-file-sync-hostname.js
  78. 10
      test/simple/test-fs-read-file-sync.js
  79. 19
      test/simple/test-fs-read-stream.js
  80. 4
      test/simple/test-fs-read.js
  81. 4
      test/simple/test-fs-readfile-empty.js
  82. 4
      test/simple/test-fs-realpath.js
  83. 4
      test/simple/test-fs-stat.js
  84. 2
      test/simple/test-fs-symlink.js
  85. 4
      test/simple/test-fs-write-buffer.js
  86. 20
      test/simple/test-fs-write-file.js
  87. 4
      test/simple/test-fs-write-stream.js
  88. 17
      test/simple/test-fs-write-sync.js
  89. 4
      test/simple/test-global.js
  90. 8
      test/simple/test-http-1.0.js
  91. 10
      test/simple/test-http-304.js
  92. 13
      test/simple/test-http-blank-header.js
  93. 3
      test/simple/test-http-buffer-sanity.js
  94. 6
      test/simple/test-http-cat.js
  95. 6
      test/simple/test-http-chunked.js
  96. 8
      test/simple/test-http-client-race-2.js
  97. 8
      test/simple/test-http-client-race.js
  98. 6
      test/simple/test-http-client-upload.js
  99. 8
      test/simple/test-http-eof-on-connect.js
  100. 6
      test/simple/test-http-exceptions.js

2
lib/http.js

@ -426,6 +426,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
if (headers) {
var keys = Object.keys(headers);
var isArray = (Array.isArray(headers));
var field, value;
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
@ -526,6 +527,7 @@ OutgoingMessage.prototype.addTrailers = function(headers) {
this._trailer = '';
var keys = Object.keys(headers);
var isArray = (Array.isArray(headers));
var field, value;
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
if (isArray) {

2
lib/string_decoder.js

@ -49,7 +49,7 @@ StringDecoder.prototype.write = function(buffer) {
// Figure out if one of the last i bytes of our buffer announces an
// incomplete char.
for (; i > 0; i--) {
c = buffer[buffer.length - i];
var c = buffer[buffer.length - i];
// See http://en.wikipedia.org/wiki/UTF-8#Description

4
test/disabled/test-dns.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var dns = require("dns"),
child_process = require("child_process");

4
test/disabled/test-eio-race3.js

@ -1,7 +1,7 @@
/* XXX Can this test be modified to not call the now-removed wait()? */
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
console.log('first stat ...');

4
test/disabled/test-fs-sendfile.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
tcp = require("tcp");
util = require("util");

4
test/disabled/test-http-big-proxy-responses.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var util = require("util"),
fs = require("fs"),
http = require("http"),

4
test/disabled/test-http-head-request.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var assert = require("assert");
var http = require("http");

4
test/disabled/test-http-stress.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
http = require("http");

4
test/disabled/test-http-tls.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
net = require("net");
http = require("http");
url = require("url");

4
test/disabled/test-idle-watcher.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var complete = false;
var idle = new process.IdleWatcher();

4
test/disabled/test-net-tls-pummel.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
net = require("net");
fs=require("fs");

4
test/disabled/test-net-tls.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var net = require('net');

4
test/disabled/test-readline.js

@ -1,7 +1,7 @@
// Can't test this when 'make test' doesn't assign a tty to the stdout.
// Yet another use-case for require('tty').spawn ?
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var readline = require("readline");
var key = {

4
test/disabled/test-remote-module-loading.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var http = require('http');
var util = require('util');

4
test/disabled/test-setuidgid.js

@ -1,6 +1,6 @@
// Requires special privlages
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var assert = require('assert');
var oldgid = process.getgid();

4
test/disabled/tls_client.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var util=require('util');
var net=require('net');
var fs=require('fs');

4
test/disabled/tls_server.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var util=require('util');
var net=require('net');

2
test/fixtures/a.js

@ -1,6 +1,6 @@
var c = require('./b/c');
common.debug('load fixtures/a.js');
console.error('load fixtures/a.js');
var string = 'A';

2
test/fixtures/b/c.js

@ -6,7 +6,7 @@ var package = require('./package');
assert.equal('world', package.hello);
common.debug('load fixtures/b/c.js');
console.error('load fixtures/b/c.js');
var string = 'C';

2
test/fixtures/b/d.js

@ -1,4 +1,4 @@
common.debug('load fixtures/b/d.js');
console.error('load fixtures/b/d.js');
var string = 'D';

2
test/fixtures/b/package/index.js

@ -1,2 +1,2 @@
exports.hello = 'world';
common.debug('load package/index.js');
console.error('load package/index.js');

4
test/fixtures/echo.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
common.print('hello world\r\n');

4
test/fixtures/print-chars-from-buffer.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
Buffer = require('buffer').Buffer;
var n = parseInt(process.argv[2]);

4
test/fixtures/print-chars.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');
var n = parseInt(process.argv[2]);

4
test/pummel/test-child-process-spawn-loop.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var spawn = require('child_process').spawn;

4
test/pummel/test-http-client-reconnect-bug.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var net = require('net'),
util = require('util'),

4
test/pummel/test-keep-alive.js

@ -1,6 +1,6 @@
// This test requires the program 'ab'
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
http = require('http');
exec = require('child_process').exec;

4
test/pummel/test-net-many-clients.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
net = require('net');
// settings
var bytes = 1024 * 40;

4
test/pummel/test-net-pingpong-delay.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
net = require('net');

4
test/pummel/test-net-pingpong.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
net = require('net');
var tests_run = 0;

4
test/pummel/test-net-throttle.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
net = require('net');
N = 160 * 1024; // 30kb

4
test/pummel/test-net-timeout.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
net = require('net');
exchanges = 0;
starttime = null;

4
test/pummel/test-timers.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert
var common = require('../common');
var assert = require('assert');
assert = require('assert');

4
test/pummel/test-watch-file.js

@ -1,5 +1,5 @@
common = require('../common');
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var path = require('path');

7
test/simple/test-assert.js

@ -1,6 +1,5 @@
common = require("../common");
assert = common.assert
var common = require("../common");
var assert = require('assert');
var a = require('assert');
function makeBlock (f) {
@ -115,7 +114,7 @@ assert.throws(makeBlock(a.deepEqual, 'a', {}), a.AssertionError);
function thrower (errorConstructor){
throw new errorConstructor('test');
}
aethrow = makeBlock(thrower, a.AssertionError);
var aethrow = makeBlock(thrower, a.AssertionError);
aethrow = makeBlock(thrower, a.AssertionError);
// the basic calls work

4
test/simple/test-c-ares.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var dns = require("dns");

4
test/simple/test-chdir.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
assert.equal(true, process.cwd() !== __dirname);

4
test/simple/test-child-process-buffering.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

4
test/simple/test-child-process-custom-fds.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require("../common");
var assert = require('assert');
var assert = require('assert');
var spawn = require('child_process').spawn;

8
test/simple/test-child-process-cwd.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
spawn = require('child_process').spawn,
path = require('path');
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var path = require('path');
var returns = 0;

2
test/simple/test-child-process-deprecated-api.js

@ -56,4 +56,4 @@ var exits = 0;
// Check if all child processes exited
process.addListener('exit', function () {
assert.equal(2, exits);
});
});

8
test/simple/test-child-process-env.js

@ -1,10 +1,10 @@
common = require("../common");
assert = common.assert
var common = require("../common");
var assert = require('assert');
var spawn = require('child_process').spawn;
child = spawn('/usr/bin/env', [], {env: {'HELLO' : 'WORLD'}});
var child = spawn('/usr/bin/env', [], {env: {'HELLO' : 'WORLD'}});
response = "";
var response = "";
child.stdout.setEncoding('utf8');

4
test/simple/test-child-process-exec-cwd.js

@ -5,7 +5,7 @@ var exec = require('child_process').exec;
var success_count = 0;
var error_count = 0;
child = exec('pwd', {cwd: "/dev"}, function (err, stdout, stderr) {
var child = exec('pwd', {cwd: "/dev"}, function (err, stdout, stderr) {
if (err) {
error_count++;
console.log('error!: ' + err.code);
@ -21,4 +21,4 @@ child = exec('pwd', {cwd: "/dev"}, function (err, stdout, stderr) {
process.addListener('exit', function () {
assert.equal(1, success_count);
assert.equal(0, error_count);
});
});

12
test/simple/test-child-process-exec-env.js

@ -1,11 +1,11 @@
common = require('../common');
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var exec = require('child_process').exec;
success_count = 0;
error_count = 0;
response = "";
var success_count = 0;
var error_count = 0;
var response = "";
child = exec('/usr/bin/env', { env: {'HELLO' : 'WORLD'}}, function (err, stdout, stderr) {
var child = exec('/usr/bin/env', { env: {'HELLO' : 'WORLD'}}, function (err, stdout, stderr) {
if (err) {
error_count++;
console.log('error!: ' + err.code);

18
test/simple/test-child-process-exit-code.js

@ -1,12 +1,12 @@
common = require("../common");
assert = common.assert
spawn = require('child_process').spawn,
path = require('path');
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var path = require('path');
exits = 0;
var exits = 0;
exitScript = path.join(common.fixturesDir, 'exit.js')
exitChild = spawn(process.argv[0], [exitScript, 23]);
var exitScript = path.join(common.fixturesDir, 'exit.js')
var exitChild = spawn(process.argv[0], [exitScript, 23]);
exitChild.addListener('exit', function(code, signal) {
assert.strictEqual(code, 23);
assert.strictEqual(signal, null);
@ -16,8 +16,8 @@ exitChild.addListener('exit', function(code, signal) {
errorScript = path.join(common.fixturesDir, 'child_process_should_emit_error.js')
errorChild = spawn(process.argv[0], [errorScript]);
var errorScript = path.join(common.fixturesDir, 'child_process_should_emit_error.js')
var errorChild = spawn(process.argv[0], [errorScript]);
errorChild.addListener('exit', function(code, signal) {
assert.ok(code !== 0);
assert.strictEqual(signal, null);

4
test/simple/test-child-process-ipc.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

4
test/simple/test-child-process-kill.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

4
test/simple/test-child-process-stdin.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;

6
test/simple/test-child-process-stdout-flush.js

@ -1,10 +1,10 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path');
var spawn = require('child_process').spawn;
var sub = path.join(common.fixturesDir, 'print-chars.js');
n = 500000;
var n = 500000;
var child = spawn(process.argv[0], [sub, n]);

4
test/simple/test-console.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert;
var common = require('../common');
var assert = require('assert');;
var stdout_write = global.process.stdout.write;
var strings = [];

6
test/simple/test-crypto.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
try {
var crypto = require('crypto');
@ -45,7 +45,7 @@ var h2 = crypto.createHash("sha1").update("Test").update("123").digest("hex");
assert.equal(h1, h2, "multipled updates");
// Test hashing for binary files
fn = path.join(common.fixturesDir, 'sample.png');
var fn = path.join(common.fixturesDir, 'sample.png');
var sha1Hash = crypto.createHash('sha1');
var fileStream = fs.createReadStream(fn);
fileStream.addListener('data', function(data){

5
test/simple/test-delayed-require.js

@ -1,6 +1,7 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var a;
setTimeout(function () {
a = require("../fixtures/a");
}, 50);

6
test/simple/test-dgram-multicast.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var dgram = require("dgram"),
util = require('util'),
@ -41,7 +41,7 @@ sendSocket.sendNext = function () {
});
};
listener_count = 0;
var listener_count = 0;
function mkListener() {
var receivedMessages = [];

4
test/simple/test-dgram-pingpong.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var Buffer = require('buffer').Buffer;
var dgram = require("dgram");

4
test/simple/test-dgram-udp4.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var Buffer = require("buffer").Buffer,
fs = require("fs"),

4
test/simple/test-dgram-unix-anon.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var Buffer = require("buffer").Buffer,
fs = require("fs"),

20
test/simple/test-dgram-unix.js

@ -1,14 +1,16 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
fs = require("fs");
dgram = require("dgram");
var fs = require("fs");
var dgram = require("dgram");
serverPath = "/tmp/dgram_server_sock";
clientPath = "/tmp/dgram_client_sock";
msgToSend = new Buffer("A message to send");
// TODO use common.tmpDir here
var serverPath = "/tmp/dgram_server_sock";
var clientPath = "/tmp/dgram_client_sock";
server = dgram.createSocket("unix_dgram");
var msgToSend = new Buffer("A message to send");
var server = dgram.createSocket("unix_dgram");
server.on("message", function (msg, rinfo) {
console.log("server got: " + msg + " from " + rinfo.address);
assert.strictEqual(rinfo.address, clientPath);
@ -19,7 +21,7 @@ server.on("message", function (msg, rinfo) {
server.on("listening", function () {
console.log("server is listening");
client = dgram.createSocket("unix_dgram");
var client = dgram.createSocket("unix_dgram");
client.on("message", function (msg, rinfo) {
console.log("client got: " + msg + " from " + rinfo.address);

4
test/simple/test-eio-race.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var count = 100;
var fs = require('fs');

6
test/simple/test-eio-race2.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path');
var testTxt = path.join(common.fixturesDir, "x.txt");
var fs = require('fs');
@ -7,7 +7,7 @@ var fs = require('fs');
setTimeout(function () {
// put this in a timeout, just so it doesn't get bunched up with the
// require() calls..
N = 30;
var N = 30;
for (var i=0; i < N; i++) {
console.log("start " + i);
fs.readFile(testTxt, function(err, data) {

4
test/simple/test-eio-race4.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var N = 100;
var j = 0;

10
test/simple/test-error-reporting.js

@ -1,9 +1,9 @@
common = require("../common");
assert = common.assert
exec = require('child_process').exec,
path = require('path');
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var path = require('path');
exits = 0;
var exits = 0;
function errExec (script, callback) {
var cmd = process.argv[0] + ' ' + path.join(common.fixturesDir, script);

4
test/simple/test-event-emitter-add-listeners.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var events = require('events');
var e = new events.EventEmitter();

4
test/simple/test-event-emitter-modify-in-emit.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var events = require('events');
var callbacks_called = [ ];

4
test/simple/test-event-emitter-num-args.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var events = require('events');
var e = new events.EventEmitter(),

4
test/simple/test-event-emitter-once.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var events = require('events');
var e = new events.EventEmitter();

12
test/simple/test-event-emitter-remove-listeners.js

@ -1,9 +1,9 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var events = require('events');
count = 0;
var count = 0;
function listener1 () {
console.log('listener1');
@ -20,17 +20,17 @@ function listener3 () {
count++;
}
e1 = new events.EventEmitter();
var e1 = new events.EventEmitter();
e1.addListener("hello", listener1);
e1.removeListener("hello", listener1);
assert.deepEqual([], e1.listeners('hello'));
e2 = new events.EventEmitter();
var e2 = new events.EventEmitter();
e2.addListener("hello", listener1);
e2.removeListener("hello", listener2);
assert.deepEqual([listener1], e2.listeners('hello'));
e3 = new events.EventEmitter();
var e3 = new events.EventEmitter();
e3.addListener("hello", listener1);
e3.addListener("hello", listener2);
e3.removeListener("hello", listener1);

4
test/simple/test-exception-handler.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var MESSAGE = 'catch me if you can';
var caughtException = false;

4
test/simple/test-exception-handler2.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);

8
test/simple/test-exec.js

@ -1,8 +1,8 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
success_count = 0;
error_count = 0;
var success_count = 0;
var error_count = 0;
exec("ls /", function (err, stdout, stderr) {
if (err) {

12
test/simple/test-executable-path.js

@ -1,11 +1,11 @@
common = require("../common");
assert = common.assert;
path = require("path");
var common = require('../common');
var assert = require('assert');;
var path = require("path");
isDebug = (process.version.indexOf('debug') >= 0);
var isDebug = (process.version.indexOf('debug') >= 0);
debugPath = path.normalize(path.join(__dirname, '..', '..', 'build', 'debug', 'node_g'));
defaultPath = path.normalize(path.join(__dirname, '..', '..', 'build', 'default', 'node'));
var debugPath = path.normalize(path.join(__dirname, '..', '..', 'build', 'debug', 'node_g'));
var defaultPath = path.normalize(path.join(__dirname, '..', '..', 'build', 'default', 'node'));
console.log('debugPath: ' + debugPath);
console.log('defaultPath: ' + defaultPath);

4
test/simple/test-file-read-noexist.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var got_error = false;

4
test/simple/test-file-write-stream.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var
path = require('path'),

4
test/simple/test-fs-chmod.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var got_error = false;

4
test/simple/test-fs-error-messages.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path'),
fs = require('fs'),

4
test/simple/test-fs-fsync.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');

4
test/simple/test-fs-read-buffer.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path'),
Buffer = require('buffer').Buffer,
fs = require('fs'),

4
test/simple/test-fs-read-file-sync-hostname.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
// test reading from hostname

10
test/simple/test-fs-read-file-sync.js

@ -1,9 +1,9 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
path = require('path');
fs = require('fs');
fn = path.join(common.fixturesDir, 'elipses.txt');
var fn = path.join(common.fixturesDir, 'elipses.txt');
var s = fs.readFileSync(fn, 'utf8');
for (var i = 0; i < s.length; i++) {

19
test/simple/test-fs-read-stream.js

@ -1,21 +1,20 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
// TODO Improved this test. test_ca.pem is too small. A proper test would
// great a large utf8 (with multibyte chars) file and stream it in,
// performing sanity checks throughout.
Buffer = require('buffer').Buffer;
path = require('path');
fs = require('fs');
fn = path.join(common.fixturesDir, 'elipses.txt');
rangeFile = path.join(common.fixturesDir, 'x.txt');
var path = require('path');
var fs = require('fs');
var fn = path.join(common.fixturesDir, 'elipses.txt');
var rangeFile = path.join(common.fixturesDir, 'x.txt');
callbacks = { open: 0, end: 0, close: 0, destroy: 0 };
var callbacks = { open: 0, end: 0, close: 0, destroy: 0 };
paused = false;
var paused = false;
file = fs.ReadStream(fn);
var file = fs.ReadStream(fn);
file.addListener('open', function(fd) {
file.length = 0;

4
test/simple/test-fs-read.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path'),
fs = require('fs'),
filepath = path.join(common.fixturesDir, 'x.txt'),

4
test/simple/test-fs-readfile-empty.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var
path = require('path'),

4
test/simple/test-fs-realpath.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;

4
test/simple/test-fs-stat.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var got_error = false;
var success_count = 0;

2
test/simple/test-fs-symlink.js

@ -1,4 +1,4 @@
common = require("../common");
var common = require('../common');
var assert = common.assert;
var path = require('path');
var fs = require('fs');

4
test/simple/test-fs-write-buffer.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path'),
Buffer = require('buffer').Buffer,
fs = require('fs'),

20
test/simple/test-fs-write-file.js

@ -1,17 +1,15 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var join = require('path').join;
join = require('path').join;
fs = require('fs');
Buffer = require('buffer').Buffer;
filename = join(common.fixturesDir, 'test.txt');
var filename = join(common.fixturesDir, 'test.txt');
common.error('writing to ' + filename);
s = "南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n";
var s = "南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n";
ncallbacks = 0;
var ncallbacks = 0;
fs.writeFile(filename, s, function (e) {
if (e) throw e;
@ -28,8 +26,8 @@ fs.writeFile(filename, s, function (e) {
});
// test that writeFile accepts buffers
filename2 = join(common.fixturesDir, 'test2.txt');
buf = new Buffer(s, 'utf8');
var filename2 = join(common.fixturesDir, 'test2.txt');
var buf = new Buffer(s, 'utf8');
common.error('writing to ' + filename2);
fs.writeFile(filename2, buf, function (e) {

4
test/simple/test-fs-write-stream.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var path = require('path'),
fs = require('fs');

17
test/simple/test-fs-write-sync.js

@ -1,20 +1,19 @@
common = require("../common");
assert = common.assert
path = require('path'),
Buffer = require('buffer').Buffer
fs = require('fs')
fn = path.join(common.tmpDir, 'write.txt');
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var fn = path.join(common.tmpDir, 'write.txt');
foo = 'foo'
var foo = 'foo'
var fd = fs.openSync(fn, 'w');
written = fs.writeSync(fd, '');
var written = fs.writeSync(fd, '');
assert.strictEqual(0, written);
fs.writeSync(fd, foo);
bar = 'bár'
var bar = 'bár'
written = fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
assert.ok(written > 3);
fs.closeSync(fd);

4
test/simple/test-global.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
baseFoo = "foo";
global.baseBar = "bar";

8
test/simple/test-http-1.0.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
net = require("net");
http = require("http");
var common = require('../common');
var assert = require('assert');
var net = require("net");
var http = require("http");
var body = "hello world\n";
var server_response = "";

10
test/simple/test-http-304.js

@ -1,10 +1,10 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
http = require('http');
childProcess = require('child_process');
var http = require('http');
var childProcess = require('child_process');
s = http.createServer(function (request, response) {
var s = http.createServer(function (request, response) {
response.writeHead(304);
response.end();
});

13
test/simple/test-http-blank-header.js

@ -1,12 +1,11 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var http = require('http');
var net = require('net');
http = require('http');
net = require('net');
var gotReq = false;
gotReq = false;
server = http.createServer(function (req, res) {
var server = http.createServer(function (req, res) {
common.error('got req');
gotReq = true;
assert.equal('GET', req.method);

3
test/simple/test-http-buffer-sanity.js

@ -42,6 +42,8 @@ var web = http.Server(function (req, res) {
});
});
var gotThanks = false;
web.listen(common.PORT, function () {
console.log("Making request");
@ -62,4 +64,5 @@ web.listen(common.PORT, function () {
process.on('exit', function () {
assert.equal(bufferSize, measuredSize);
assert.ok(gotThanks);
});

6
test/simple/test-http-cat.js

@ -1,6 +1,6 @@
common = require("../common");
assert = common.assert
http = require("http");
var common = require("../common");
var assert = require('assert');
var http = require("http");
var body = "exports.A = function() { return 'A';}";
var server = http.createServer(function (req, res) {

6
test/simple/test-http-chunked.js

@ -1,5 +1,5 @@
common = require("../common");
assert = common.assert
var common = require('../common');
var assert = require('assert');
var http = require("http");
var UTF8_STRING = "南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、经济现状。";
@ -19,4 +19,4 @@ server.addListener("listening", function() {
console.log(data);
server.close();
});
});
});

8
test/simple/test-http-client-race-2.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
http = require("http");
url = require("url");
var common = require('../common');
var assert = require('assert');
var http = require('http');
var url = require("url");
//
// Slight variation on test-http-client-race to test for another race

8
test/simple/test-http-client-race.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
http = require("http");
url = require("url");
var common = require('../common');
var assert = require('assert');
var http = require('http');
var url = require("url");
var body1_s = "1111111111111111";
var body2_s = "22222";

6
test/simple/test-http-client-upload.js

@ -1,6 +1,6 @@
common = require("../common");
assert = common.assert
http = require("http");
var common = require('../common');
var assert = require('assert');
var http = require('http');
var sent_body = "";
var server_req_complete = false;

8
test/simple/test-http-eof-on-connect.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
net = require("net");
http = require("http");
var common = require('../common');
var assert = require('assert');
var net = require('net');
var http = require('http');
// This is a regression test for http://github.com/ry/node/issues/#issue/44
// It is separate from test-http-malformed-request.js because it is only

6
test/simple/test-http-exceptions.js

@ -1,6 +1,6 @@
common = require("../common");
assert = common.assert;
http = require("http");
var common = require('../common');
var assert = require('assert');;
var http = require('http');
server = http.createServer(function (req, res) {
intentionally_not_defined();

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save