Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
tests: fix more lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Jan 17, 2012
1 parent 4865063 commit 892056b
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 69 deletions.
2 changes: 1 addition & 1 deletion test/common.js
Expand Up @@ -55,7 +55,7 @@ exports.indirectInstanceOf = function(obj, cls) {
exports.ddCommand = function(filename, kilobytes) {
if (process.platform == 'win32') {
return '"' + process.argv[0] + '" "' + path.resolve(exports.fixturesDir,
'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024);
'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024);
} else {
return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes;
}
Expand Down
15 changes: 10 additions & 5 deletions test/simple/test-child-process-double-pipe.js
Expand Up @@ -28,11 +28,16 @@ var assert = require('assert'),
// We're trying to reproduce:
// $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/

var echo = is_windows ? spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo',
'node&&', 'echo', 'and&&', 'echo', 'world']) :
spawn('echo', ['hello\nnode\nand\nworld\n']),
grep = spawn('grep', ['o']),
sed = spawn('sed', ['s/o/O/']);
var grep = spawn('grep', ['o']),
sed = spawn('sed', ['s/o/O/']),
echo;

if (is_windows) {
echo = spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo',
'node&&', 'echo', 'and&&', 'echo', 'world']);
} else {
echo = spawn('echo', ['hello\nnode\nand\nworld\n']);
}

/*
* grep and sed hang if the spawn function leaks file descriptors to child
Expand Down
16 changes: 8 additions & 8 deletions test/simple/test-executable-path.js
Expand Up @@ -26,14 +26,14 @@ var match = false;

var isDebug = process.features.debug;

var debugPaths = [ path.normalize(path.join(__dirname, '..', '..',
'out', 'Debug', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Debug', 'node'))];
var defaultPaths = [ path.normalize(path.join(__dirname, '..', '..',
'out', 'Release', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Release', 'node'))];
var debugPaths = [path.normalize(path.join(__dirname, '..', '..',
'out', 'Debug', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Debug', 'node'))];
var defaultPaths = [path.normalize(path.join(__dirname, '..', '..',
'out', 'Release', 'node')),
path.normalize(path.join(__dirname, '..', '..',
'Release', 'node'))];

console.error('debugPaths: ' + debugPaths);
console.error('defaultPaths: ' + defaultPaths);
Expand Down
6 changes: 4 additions & 2 deletions test/simple/test-http-1.0.js
Expand Up @@ -112,7 +112,8 @@ function test(handler, request_generator, response_validator) {

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' +
'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');
Expand Down Expand Up @@ -147,7 +148,8 @@ function test(handler, request_generator, response_validator) {

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' +
'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' +
Expand Down
8 changes: 4 additions & 4 deletions test/simple/test-path-makelong.js
Expand Up @@ -26,13 +26,13 @@ if (process.platform === 'win32') {

var file = path.join(common.fixturesDir, 'a.js');
var resolvedFile = path.resolve(file);
var networkFile = '\\\\someserver\\someshare\\somefile';

assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file));
assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file));
assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile',
path._makeLong('\\\\someserver\\someshare\\somefile'));
path._makeLong('\\\\someserver\\someshare\\somefile'));
assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile',
path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile'));
assert.equal('\\\\.\\pipe\\somepipe', path._makeLong('\\\\.\\pipe\\somepipe'));
path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile'));
assert.equal('\\\\.\\pipe\\somepipe',
path._makeLong('\\\\.\\pipe\\somepipe'));
}
101 changes: 55 additions & 46 deletions test/simple/test-repl-tab-complete.js
Expand Up @@ -26,21 +26,21 @@ var repl = require('repl');

// A stream to push an array into a REPL
function ArrayStream() {
this.run = function (data) {
this.run = function(data) {
var self = this;
data.forEach(function (line) {
data.forEach(function(line) {
self.emit('data', line);
});
}
}
util.inherits(ArrayStream, require('stream').Stream);
ArrayStream.prototype.readable = true;
ArrayStream.prototype.writable = true;
ArrayStream.prototype.resume = function () {};
ArrayStream.prototype.write = function () {};
ArrayStream.prototype.resume = function() {};
ArrayStream.prototype.write = function() {};

var works = [ [ 'inner.one' ], 'inner.o' ];
var doesNotBreak = [ [], 'inner.o' ];
var works = [['inner.one'], 'inner.o'];
var doesNotBreak = [[], 'inner.o'];

var putIn = new ArrayStream();
var testMe = repl.start('', putIn);
Expand All @@ -49,14 +49,15 @@ var testMe = repl.start('', putIn);
putIn.run(['.clear']);
putIn.run([
'var inner = {',
'one:1']);
testMe.complete('inner.o', function (error, data) {
'one:1'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

// Tab Complete will return globaly scoped variables
putIn.run(['};']);
testMe.complete('inner.o', function (error, data) {
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});

Expand All @@ -66,8 +67,9 @@ putIn.run(['.clear']);
putIn.run([
'var inner = ( true ' ,
'?',
'{one: 1} : ']);
testMe.complete('inner.o', function (error, data) {
'{one: 1} : '
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

Expand All @@ -76,15 +78,16 @@ putIn.run(['.clear']);
// Tab Complete will return a simple local variable
putIn.run([
'var top = function () {',
'var inner = {one:1};']);
testMe.complete('inner.o', function (error, data) {
'var inner = {one:1};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});

// When you close the function scope tab complete will not return the
// locally scoped variable
putIn.run(['};']);
testMe.complete('inner.o', function (error, data) {
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

Expand All @@ -93,10 +96,11 @@ putIn.run(['.clear']);
// Tab Complete will return a complex local variable
putIn.run([
'var top = function () {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});

Expand All @@ -106,10 +110,11 @@ putIn.run(['.clear']);
// has paramaters
putIn.run([
'var top = function (one, two) {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});

Expand All @@ -119,11 +124,12 @@ putIn.run(['.clear']);
// scope is nested inside an immediately executed function
putIn.run([
'var top = function () {',
'(function test () {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'(function test () {',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, works);
});

Expand All @@ -133,12 +139,13 @@ putIn.run(['.clear']);
// def has the params and { on a seperate line
putIn.run([
'var top = function () {',
'r = function test (',
' one, two) {',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'r = function test (',
' one, two) {',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

Expand All @@ -147,12 +154,13 @@ putIn.run(['.clear']);
// currently does not work, but should not break, not the {
putIn.run([
'var top = function () {',
'r = function test ()',
'{',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'r = function test ()',
'{',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

Expand All @@ -161,13 +169,14 @@ putIn.run(['.clear']);
// currently does not work, but should not break
putIn.run([
'var top = function () {',
'r = function test (',
')',
'{',
'var inner = {',
' one:1',
'};']);
testMe.complete('inner.o', function (error, data) {
'r = function test (',
')',
'{',
'var inner = {',
' one:1',
'};'
]);
testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

6 changes: 4 additions & 2 deletions test/simple/test-script-context.js
Expand Up @@ -54,9 +54,11 @@ try {
}
catch (e) {
gh1140Exception = e;
assert.ok(/expected-filename/.test(e.stack), 'expected appearance of filename in Error stack');
assert.ok(/expected-filename/.test(e.stack),
'expected appearance of filename in Error stack');
}
assert.ok(gh1140Exception, 'expected exception from runInContext signature test');
assert.ok(gh1140Exception,
'expected exception from runInContext signature test');

// GH-558, non-context argument segfaults / raises assertion
function isTypeError(o) {
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-stdin-child-proc.js
Expand Up @@ -24,4 +24,4 @@
var child_process = require('child_process');
var path = require('path');
child_process.spawn(process.execPath,
[ path.resolve(__dirname, 'test-stdin-pause-resume.js') ]);
[path.resolve(__dirname, 'test-stdin-pause-resume.js')]);

0 comments on commit 892056b

Please sign in to comment.