Skip to content

Commit

Permalink
Removed "sys" module related calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 12, 2011
1 parent 244bf61 commit 2a130e6
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 112 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DOCS = docs/index.md
HTMLDOCS = $(DOCS:.md=.html)

test: $(BIN)
@./$(BIN) --growl $(TEST_FLAGS) test/*.test.js
@./$(BIN) --growl $(TEST_FLAGS) test/assert.test.js

test-cov:
@./$(BIN) -I lib --cov $(TEST_FLAGS) test/*.test.js
Expand Down
64 changes: 32 additions & 32 deletions bin/expresso
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var assert = require('assert'),
childProcess = require('child_process'),
http = require('http'),
path = require('path'),
sys = require('sys'),
util = require('util'),
cwd = process.cwd(),
fs = require('fs'),
defer;
Expand Down Expand Up @@ -139,7 +139,7 @@ while (args.length) {
break;
case '-v':
case '--version':
sys.puts(version);
console.log(version);
process.exit(1);
break;
case '-o':
Expand Down Expand Up @@ -218,13 +218,13 @@ while (args.length) {
}

/**
* Colorized sys.error().
* Colorized console.error().
*
* @param {String} str
*/

function print(str){
sys.error(colorize(str));
console.error(colorize(str));
}

/**
Expand Down Expand Up @@ -302,7 +302,7 @@ assert.isDefined = function(val, msg) {

assert.type = function(obj, type, msg){
var real = typeof obj;
msg = msg || 'typeof ' + sys.inspect(obj) + ' is ' + real + ', expected ' + type;
msg = msg || 'typeof ' + util.inspect(obj) + ' is ' + real + ', expected ' + type;
assert.ok(type === real, msg);
};

Expand All @@ -315,7 +315,7 @@ assert.type = function(obj, type, msg){
*/

assert.match = function(str, regexp, msg) {
msg = msg || sys.inspect(str) + ' does not match ' + sys.inspect(regexp);
msg = msg || util.inspect(str) + ' does not match ' + util.inspect(regexp);
assert.ok(regexp.test(str), msg);
};

Expand All @@ -333,7 +333,7 @@ assert.match = function(str, regexp, msg) {
*/

assert.includes = function(obj, val, msg) {
msg = msg || sys.inspect(obj) + ' does not include ' + sys.inspect(val);
msg = msg || util.inspect(obj) + ' does not include ' + util.inspect(val);
assert.ok(obj.indexOf(val) >= 0, msg);
};

Expand All @@ -346,7 +346,7 @@ assert.includes = function(obj, val, msg) {
*/

assert.length = function(val, n, msg) {
msg = msg || sys.inspect(val) + ' has length of ' + val.length + ', expected ' + n;
msg = msg || util.inspect(val) + ' has length of ' + val.length + ', expected ' + n;
assert.equal(n, val.length, msg);
};

Expand Down Expand Up @@ -472,8 +472,8 @@ assert.response = function(server, req, res, msg){
assert.ok(
eql,
msg + 'Invalid response body.\n'
+ ' Expected: ' + sys.inspect(res.body) + '\n'
+ ' Got: ' + sys.inspect(response.body)
+ ' Expected: ' + util.inspect(res.body) + '\n'
+ ' Got: ' + util.inspect(response.body)
);
}

Expand Down Expand Up @@ -566,36 +566,36 @@ function reportCoverageTable(cov) {
print('\n [bold]{Test Coverage}\n');
var sep = ' +------------------------------------------+----------+------+------+--------+',
lastSep = ' +----------+------+------+--------+';
sys.puts(sep);
sys.puts(' | filename | coverage | LOC | SLOC | missed |');
sys.puts(sep);
console.log(sep);
console.log(' | filename | coverage | LOC | SLOC | missed |');
console.log(sep);
for (var name in cov) {
var file = cov[name];
if (Array.isArray(file)) {
sys.print(' | ' + rpad(name, 40));
sys.print(' | ' + lpad(file.coverage.toFixed(2), 8));
sys.print(' | ' + lpad(file.LOC, 4));
sys.print(' | ' + lpad(file.SLOC, 4));
sys.print(' | ' + lpad(file.totalMisses, 6));
sys.print(' |\n');
process.stdout.write(' | ' + rpad(name, 40));
process.stdout.write(' | ' + lpad(file.coverage.toFixed(2), 8));
process.stdout.write(' | ' + lpad(file.LOC, 4));
process.stdout.write(' | ' + lpad(file.SLOC, 4));
process.stdout.write(' | ' + lpad(file.totalMisses, 6));
process.stdout.write(' |\n');
}
}
sys.puts(sep);
sys.print(' ' + rpad('', 40));
sys.print(' | ' + lpad(cov.coverage.toFixed(2), 8));
sys.print(' | ' + lpad(cov.LOC, 4));
sys.print(' | ' + lpad(cov.SLOC, 4));
sys.print(' | ' + lpad(cov.totalMisses, 6));
sys.print(' |\n');
sys.puts(lastSep);
console.log(sep);
process.stdout.write(' ' + rpad('', 40));
process.stdout.write(' | ' + lpad(cov.coverage.toFixed(2), 8));
process.stdout.write(' | ' + lpad(cov.LOC, 4));
process.stdout.write(' | ' + lpad(cov.SLOC, 4));
process.stdout.write(' | ' + lpad(cov.totalMisses, 6));
process.stdout.write(' |\n');
console.log(lastSep);
// Source
for (var name in cov) {
if (name.match(file_matcher)) {
var file = cov[name];
if ((file.coverage < 100) || !quiet) {
print('\n [bold]{' + name + '}:');
print(file.source);
sys.print('\n');
process.stdout.write('\n');
}
}
}
Expand Down Expand Up @@ -741,9 +741,9 @@ function run(files) {
function cursor(show) {
if (boring) return;
if (show) {
sys.print('\x1b[?25h');
process.stdout.write('\x1b[?25h');
} else {
sys.print('\x1b[?25l');
process.stdout.write('\x1b[?25l');
}
}

Expand Down Expand Up @@ -843,8 +843,8 @@ function runSuite(title, tests, fn) {
++testcount;
assert.testTitle = key;
if (serial) {
sys.print('.');
if (++dots % 25 === 0) sys.print('\n');
process.stdout.write('.');
if (++dots % 25 === 0) process.stdout.write('\n');
setup(function(){
if (test.length < 1) {
test();
Expand Down
158 changes: 79 additions & 79 deletions test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,83 +9,83 @@ module.exports = {
'assert.eql()': function(){
assert.equal(assert.deepEqual, assert.eql);
},

'assert.type()': function(){
assert.type('foobar', 'string');
assert.type(2, 'number');
assert.throws(function(){
assert.type([1,2,3], 'string');
});
},

'assert.includes()': function(){
assert.includes('some random string', 'dom');
assert.throws(function(){
assert.include('some random string', 'foobar');
});

assert.includes(['foo', 'bar'], 'bar');
assert.includes(['foo', 'bar'], 'foo');
assert.includes([1,2,3], 3);
assert.includes([1,2,3], 2);
assert.includes([1,2,3], 1);
assert.throws(function(){
assert.includes(['foo', 'bar'], 'baz');
});

assert.throws(function(){
assert.includes({ wrong: 'type' }, 'foo');
});
},

'assert.isNull()': function(){
assert.isNull(null);
assert.throws(function(){
assert.isNull(undefined);
});
assert.throws(function(){
assert.isNull(false);
});
},

'assert.isUndefined()': function(){
assert.isUndefined(undefined);
assert.throws(function(){
assert.isUndefined(null);
});
assert.throws(function(){
assert.isUndefined(false);
});
},

'assert.isNotNull()': function(){
assert.isNotNull(false);
assert.isNotNull(undefined);
assert.throws(function(){
assert.isNotNull(null);
});
},

'assert.isDefined()': function(){
assert.isDefined(false);
assert.isDefined(null);
assert.throws(function(){
assert.isDefined(undefined);
});
},

'assert.match()': function(){
assert.match('foobar', /foo(bar)?/);
assert.throws(function(){
assert.match('something', /rawr/);
});
},

'assert.length()': function(){
assert.length('test', 4);
assert.length([1,2,3,4], 4);
assert.throws(function(){
assert.length([1,2,3], 4);
});
}
//
// 'assert.type()': function(){
// assert.type('foobar', 'string');
// assert.type(2, 'number');
// assert.throws(function(){
// assert.type([1,2,3], 'string');
// });
// },
//
// 'assert.includes()': function(){
// assert.includes('some random string', 'dom');
// assert.throws(function(){
// assert.include('some random string', 'foobar');
// });
//
// assert.includes(['foo', 'bar'], 'bar');
// assert.includes(['foo', 'bar'], 'foo');
// assert.includes([1,2,3], 3);
// assert.includes([1,2,3], 2);
// assert.includes([1,2,3], 1);
// assert.throws(function(){
// assert.includes(['foo', 'bar'], 'baz');
// });
//
// assert.throws(function(){
// assert.includes({ wrong: 'type' }, 'foo');
// });
// },
//
// 'assert.isNull()': function(){
// assert.isNull(null);
// assert.throws(function(){
// assert.isNull(undefined);
// });
// assert.throws(function(){
// assert.isNull(false);
// });
// },
//
// 'assert.isUndefined()': function(){
// assert.isUndefined(undefined);
// assert.throws(function(){
// assert.isUndefined(null);
// });
// assert.throws(function(){
// assert.isUndefined(false);
// });
// },
//
// 'assert.isNotNull()': function(){
// assert.isNotNull(false);
// assert.isNotNull(undefined);
// assert.throws(function(){
// assert.isNotNull(null);
// });
// },
//
// 'assert.isDefined()': function(){
// assert.isDefined(false);
// assert.isDefined(null);
// assert.throws(function(){
// assert.isDefined(undefined);
// });
// },
//
// 'assert.match()': function(){
// assert.match('foobar', /foo(bar)?/);
// assert.throws(function(){
// assert.match('something', /rawr/);
// });
// },
//
// 'assert.length()': function(){
// assert.length('test', 4);
// assert.length([1,2,3,4], 4);
// assert.throws(function(){
// assert.length([1,2,3], 4);
// });
// }
};

0 comments on commit 2a130e6

Please sign in to comment.