public void Count() { var test = new IntegrationTest(@" (defun make-counter () (let ((count 0)) (lambda () (set! count (+ 1 count))))) (define count-a (make-counter)) (define count-b (make-counter)) "); test.Test("(count-a) (count-b) (count-a) (count-a) (count-b)", "1", "1", "2", "3", "2"); }
public void Adder() { var test = new IntegrationTest(@" (defun make-adder (x) (lambda (y) (+ x y))) (define add2 (make-adder 2)) (define add3 (make-adder 3)) "); test.Test("(add2 3) (add3 3)", "5", "6"); }
public void Fibonacci(string input, string output) { var test = new IntegrationTest(@" (defun fib (n) (defun iter (i p f) (if (eq i n) f (iter (+ i 1) f (+ p f)))) (iter 0 1 0)) "); test.Test(input, output); }
public void Wiggle(string input) { var test = new IntegrationTest(); string smidgen = Math.Pow(2, -32).ToString(CultureInfo.InvariantCulture); test.Test(string.Format("(+ {0} {0} -{0})", input), input); test.Test(string.Format("(= {0} (+ {0} {0} -{0}))", input), "T"); test.Test(string.Format("(+ {0} {1} -{1})", input, smidgen), input); test.Test(string.Format("(= {0} (+ {0} {1} -{1}))", input, smidgen), "T"); test.Test(string.Format("(< {0} (+ {0} {1}))", input, smidgen), "T"); test.Test(string.Format("(< (- {0} {1}) {0})", input, smidgen), "T"); test.Test(string.Format("(> {0} (- {0} {1}))", input, smidgen), "T"); test.Test(string.Format("(> (+ {0} {1}) {0})", input, smidgen), "T"); test.Test(string.Format("(= {0} (+ {0} {0}))", input), "NIL"); test.Test(string.Format("(= {0} (+ {0} {1}))", input, smidgen), "NIL"); test.Test(string.Format("(< {0} (- {0} {1}))", input, smidgen), "NIL"); test.Test(string.Format("(> {0} (+ {0} {1}))", input, smidgen), "NIL"); }