Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Converted use of sys to util (new library name)

  • Loading branch information...
commit 305d9a3b42beeeeb76899e6e27fa4144b0de61f3 1 parent 19cce38
Jeffrey Hulten authored
16 examples/echo-client.js
View
@@ -1,4 +1,4 @@
-var sys = require('sys'),
+var util = require('util'),
rpc = require('../src/bertrpc');
// connect to the server
@@ -6,19 +6,19 @@ rpc.connect(7000, 'localhost', function (service) {
// call the echo module's hello function with no arguments
var res = service.call('echo', 'hello', []);
- sys.debug("client sending {call, say, hello, []}");
+ util.debug("client sending {call, say, hello, []}");
// the call return comes back asynchronously
res.finish(function (result) {
- sys.debug("client received: " + sys.inspect(result));
+ util.debug("client received: " + util.inspect(result));
});
// call the echo module's echo function with a simple string
// argument and provide the finish callback to the call method
// instead of registering it on the resulting promise:
- sys.debug("client sending {call, say, echo, ['Hello World']}");
+ util.debug("client sending {call, say, echo, ['Hello World']}");
service.call('echo', 'echo', ['Hello World'], function (result) {
- sys.debug("client received " + sys.inspect(result));
+ util.debug("client received " + util.inspect(result));
});
// grab the echo module object so that we can call on it without
@@ -27,11 +27,11 @@ rpc.connect(7000, 'localhost', function (service) {
// pass dict and integer args this time to make things a bit more
// interesting.
- sys.debug("client sending {call, say, echo, [[{foo, <<'bar'>>}, {bar, <<'baz'>>}], 21]}");
+ util.debug("client sending {call, say, echo, [[{foo, <<'bar'>>}, {bar, <<'baz'>>}], 21]}");
echo_module.call('echo', [{foo: 'bar', bar: 'baz'}, 21], function (result) {
- sys.debug("client received: " + sys.inspect(result));
+ util.debug("client received: " + util.inspect(result));
});
- sys.debug("client closing connection");
+ util.debug("client closing connection");
service.end();
});
2  examples/echo-server.js
View
@@ -1,4 +1,4 @@
-var sys = require('sys'),
+var util = require('util'),
rpc = require('../src/bertrpc');
rpc.expose('echo', {
8 examples/math-client.js
View
@@ -1,4 +1,4 @@
-var sys = require('sys'),
+var util = require('util'),
rpc = require('../src/bertrpc');
// connect to the server
@@ -9,9 +9,9 @@ rpc.connect(7001, 'localhost', function (service) {
// call the math module's sum function with a few integers
// and print the result
- sys.debug("math client summing [1, 2, 3]");
+ util.debug("math client summing [1, 2, 3]");
mathrpc.call('sum', [[1, 2, 3]], function (result) {
- sys.debug("math client got: " + sys.inspect(result));
+ util.debug("math client got: " + util.inspect(result));
});
// calculate a fibonacci number and pass the result to
@@ -32,6 +32,6 @@ rpc.connect(7001, 'localhost', function (service) {
// calculate the 25th fibonacci number
fib(25, function (number) {
- sys.debug("the 25th fibonacci number is " + number);
+ util.debug("the 25th fibonacci number is " + number);
});
});
2  examples/math-server.js
View
@@ -1,4 +1,4 @@
-var sys = require('sys'),
+var util = require('util'),
rpc = require('../src/bertrpc');
rpc.expose('math', {
4 src/bertrpc.js
View
@@ -16,7 +16,7 @@
// TODO: trace should be switchable
// TODO: logger and error handling
-var sys = require('sys'),
+var util = require('util'),
net = require('net'),
bert = require('./bert');
@@ -77,7 +77,7 @@ var BERTRPC = {
// Write a message to the console/log.
trace: function (side, direction, message) {
- sys.puts(" " + direction + " [" + side + "] " + message);
+ util.puts(" " + direction + " [" + side + "] " + message);
},
// The node net.Server object -- ready to go. Use BERTRPC.listen
30 test/bert-test.js
View
@@ -1,13 +1,13 @@
-var sys = require('sys'),
+var util = require('util'),
bert = require('../src/bert');
process.mixin(GLOBAL, require('./test'));
var encode = bert.encode,
decode = bert.decode,
R = bert.repr,
- dump = function (obj) { sys.puts(obj) },
+ dump = function (obj) { util.puts(obj) },
bin = bert.bin_repr,
- dump_bin = function (obj) { sys.puts(bert.bin_repr(obj)) };
+ dump_bin = function (obj) { util.puts(bert.bin_repr(obj)) };
var data = null,
obj = null;
@@ -17,7 +17,7 @@ var data = null,
obj = bert.atom("hello");
test('bert.repr(<atom>)', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal("hello", bert.repr(obj));
});
@@ -38,7 +38,7 @@ test('bert.decode(<atom>)', function() {
obj = "hello";
test('bert.repr(<atom>)', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal('<<"hello">>', bert.repr(obj));
});
@@ -58,7 +58,7 @@ test('bert.decode(<binary>)', function() {
obj = true
test('bert.repr(true)', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal('<true>', bert.repr(obj));
});
@@ -70,7 +70,7 @@ test('bert.encode(true)', function() {
test('bert.decode(true)', function() {
obj = decode(data);
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
assert_equal(true, obj);
});
@@ -193,7 +193,7 @@ test('bert.encode([1, 2, 3])', function() {
});
test('bert.repr([1, 2, 3])', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal("[1, 2, 3]", bert.repr(obj));
});
@@ -212,7 +212,7 @@ test('bert.decode([1, 2, 3])', function() {
obj = {a:1, b:2, c:3};
test('bert.repr({a:1, b:2, c:3})', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal("[{a, 1}, {b, 2}, {c, 3}]", bert.repr(obj));
});
@@ -226,9 +226,9 @@ test('bert.encode({a:1, b:2, c:3})', function() {
});
test('bert.decode({a:1, b:2, c:3})', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
obj = decode(data);
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal(1, obj['a']);
assert_equal(2, obj['b']);
@@ -245,7 +245,7 @@ test('bert.encode(<tuple>)', function() {
});
test('bert.repr(<tuple>)', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal('{<<"Hello">>, 1}', bert.repr(obj));
});
@@ -263,7 +263,7 @@ test('bert.decode(<tuple>)', function() {
obj = []
test('bert.repr([])', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal('[]', bert.repr(obj));
});
@@ -283,7 +283,7 @@ test('bert.decode([])', function() {
obj = { a: bert.tuple(1, 2, 3), b: [4, 5, 6] }
test('bert.repr(<complex>)', function() {
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal("[{a, {1, 2, 3}}, {b, [4, 5, 6]}]", bert.repr(obj));
});
@@ -300,7 +300,7 @@ test('bert.encode(<complex>)', function () {
test('bert.decode(<complex>)', function() {
obj = decode(data);
- dump(sys.inspect(obj));
+ dump(util.inspect(obj));
dump(R(obj));
assert_equal('object', typeof(obj));
assert_equal('tuple', obj.a.type);
2  test/bertrpc-test.js
View
@@ -1,6 +1,6 @@
process.mixin(GLOBAL, require('./test'));
-var sys = require('sys'),
+var util = require('util'),
bertrpc = require('../src/bertrpc'),
bert = require('../src/bert');
30 test/test.js
View
@@ -1,4 +1,4 @@
-var sys = require('sys');
+var util = require('util');
TEST = {
passed: 0,
@@ -6,13 +6,13 @@ TEST = {
assertions: 0,
test: function (desc, block) {
- var _puts = sys.puts,
+ var _puts = util.puts,
output = "",
result = '?',
_boom = null;
- sys.puts = function (s) { output += s + "\n"; }
+ util.puts = function (s) { output += s + "\n"; }
try {
- sys.print(" " + desc + " ...");
+ util.print(" " + desc + " ...");
block();
result = '.';
} catch(boom) {
@@ -21,16 +21,16 @@ TEST = {
} else {
result = 'E';
_boom = boom;
- sys.puts(boom.toString());
+ util.puts(boom.toString());
}
}
- sys.puts = _puts;
+ util.puts = _puts;
if ( result == '.' ) {
- sys.print(" OK\n");
+ util.print(" OK\n");
TEST.passed += 1;
} else {
- sys.print(" FAIL\n");
- sys.print(output.replace(/^/, " ") + "\n");
+ util.print(" FAIL\n");
+ util.print(output.replace(/^/, " ") + "\n");
TEST.failed += 1;
if ( _boom ) throw _boom;
}
@@ -38,14 +38,14 @@ TEST = {
assert: function (value, desc) {
TEST.assertions += 1;
- if ( desc ) sys.puts("ASSERT: " + desc);
+ if ( desc ) util.puts("ASSERT: " + desc);
if ( !value ) throw 'FAIL';
},
assert_equal: function (expect, is) {
assert(
expect == is,
- sys.inspect(expect) + " == " + sys.inspect(is)
+ util.inspect(expect) + " == " + util.inspect(is)
);
},
@@ -55,12 +55,12 @@ TEST = {
catch (boom) { error = boom }
if ( !error ) {
- sys.puts('NO BOOM');
+ util.puts('NO BOOM');
throw 'FAIL'
}
if ( error != message ) {
- sys.puts('BOOM: ' + sys.inspect(error) +
- ' [' + sys.inspect(message) + ' expected]');
+ util.puts('BOOM: ' + util.inspect(error) +
+ ' [' + util.inspect(message) + ' expected]');
throw 'FAIL'
}
}
@@ -71,7 +71,7 @@ process.mixin(exports, TEST);
process.addListener('exit', function (code) {
if ( !TEST.exit ) {
TEST.exit = true;
- sys.puts("" + TEST.passed + " passed, " + TEST.failed + " failed");
+ util.puts("" + TEST.passed + " passed, " + TEST.failed + " failed");
if ( TEST.failed > 0 ) { process.exit(1) };
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.