adding test

This commit is contained in:
Danny Yoo 2011-03-10 15:11:08 -05:00
parent 55d84eec95
commit dfbb278e4b
2 changed files with 30 additions and 1 deletions

View File

@ -43,6 +43,24 @@ var Primitives = (function() {
var secondArg = MACHINE.env[MACHINE.env.length-2];
return firstArg < secondArg;
},
'>': function(arity, returnLabel) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
return firstArg > secondArg;
},
'<=': function(arity, returnLabel) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
return firstArg <= secondArg;
},
'>=': function(arity, returnLabel) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
var secondArg = MACHINE.env[MACHINE.env.length-2];
return firstArg >= secondArg;
},
'+': function(arity, returnLabel) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
@ -100,10 +118,12 @@ var Primitives = (function() {
var firstArg = MACHINE.env[MACHINE.env.length-1];
return firstArg === NULL;
},
'add1': function(arity, returnLabel) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
return firstArg + 1;
},
'sub1': function(arity, returnLabel) {
var firstArg = MACHINE.env[MACHINE.env.length-1];
return firstArg - 1;

View File

@ -63,4 +63,13 @@
(displayln (fib 5))
(displayln (fib 6)))
"2\n3\n5\n8\n")
(test '(begin (define (tak x y z)
(if (>= y x)
z
(tak (tak (- x 1) y z)
(tak (- y 1) z x)
(tak (- z 1) x y))))
(displayln (tak 18 12 6)))
"7\n")