Permalink
Browse files

show with tests

  • Loading branch information...
1 parent e27328b commit 414ff2f98c8b286ff7a0dabd805843b163f251e6 @ajlopez committed Mar 25, 2012
Showing with 19 additions and 1 deletion.
  1. +9 −0 lib/ajlogo.js
  2. +10 −1 test/test.js
View
@@ -986,6 +986,15 @@
outputs[n](result);
});
+ topcontext.setProcedure('show', function(value) {
+ if (value instanceof Array)
+ value = "[ " + value.toPrintString() + " ]";
+
+ var result = value + "\r\n";
+ for (var n in outputs)
+ outputs[n](result);
+ });
+
topcontext.setProcedure('type', function(value) {
if (value instanceof Array)
value = value.toPrintString();
View
@@ -153,6 +153,7 @@ assert.ok(ctx.getProcedure('output'));
assert.ok(ctx.getProcedure('stop'));
assert.ok(ctx.getProcedure('print'));
assert.ok(ctx.getProcedure('type'));
+assert.ok(ctx.getProcedure('show'));
assert.ok(ctx.getProcedure('if'));
assert.ok(ctx.getProcedure('ifalse'));
assert.ok(ctx.getProcedure('ifelse'));
@@ -257,7 +258,7 @@ assert.equal('y', result.argnames[1]);
assert.equal(3, ajlogo.evaluateText('sumxy 1 2'));
-// Print and Type
+// print, type, show
var output = '';
@@ -277,6 +278,14 @@ output = '';
ajlogo.evaluateText('print [1 2 3]');
assert.equal('1 2 3\r\n', output);
+output = '';
+ajlogo.evaluateText('show [1 2 3]');
+assert.equal('[ 1 2 3 ]\r\n', output);
+
+output = '';
+ajlogo.evaluateText('show []');
+assert.equal('[ ]\r\n', output);
+
// If and variants
ctx.setVariable('ifone', 0);

0 comments on commit 414ff2f

Please sign in to comment.