diff --git a/chapter3/interpreter.coffee b/chapter3/interpreter.coffee index 266059f..89c5742 100644 --- a/chapter3/interpreter.coffee +++ b/chapter3/interpreter.coffee @@ -149,7 +149,6 @@ evaluate = (e, env, continuation) -> when "lambda" make_function (astSymbolsToLispSymbols cadr exp), (cddr exp), env, continuation else - console.log(cdr exp) evlis (cdr exp), env, (args) -> evaluate (car exp), env, (fn) -> invoke fn, args, continuation diff --git a/test-reports.xml b/test-reports.xml new file mode 100644 index 0000000..ff13886 --- /dev/null +++ b/test-reports.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + at nvalu (chapter1/interpreter.coffee:11:19) + at handler (chapter1/interpreter.coffee:118:11) + at astSymbolsToLispSymbols (chapter1/interpreter.coffee:119:3) + at evaluate (chapter1/interpreter.coffee:145:43) + at evaluate (chapter1/interpreter.coffee:144:57) + at eprogn (chapter1/interpreter.coffee:77:7) + at evaluate (chapter1/interpreter.coffee:143:27) + at module.exports (chapter1/interpreter.coffee:152:25) + at Context.<anonymous> (test/test_chapter1.coffee:38:12) + + + + + + + + at nvalu (chapter1/interpreter.coffee:11:19) + at handler (chapter1/interpreter.coffee:118:11) + at astSymbolsToLispSymbols (chapter1/interpreter.coffee:119:3) + at evaluate (chapter1/interpreter.coffee:145:43) + at evaluate (chapter1/interpreter.coffee:148:15) + at eprogn (chapter1/interpreter.coffee:80:7) + at evaluate (chapter1/interpreter.coffee:143:27) + at module.exports (chapter1/interpreter.coffee:152:25) + at Context.<anonymous> (test/test_chapter1.coffee:47:12) + + + + + + + + at Context.<anonymous> (test/test_chapter3.coffee:11:56) + + + + + + + at evaluate (chapter3/interpreter.coffee:160:15) + at eprogn (chapter3/interpreter.coffee:77:7) + at evaluate (chapter3/interpreter.coffee:146:27) + at module.exports (chapter3/interpreter.coffee:162:39) + at Context.<anonymous> (test/test_chapter3.coffee:24:12) + + + + + + at lookup (chapter3/interpreter.coffee:95:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at lookup (chapter3/interpreter.coffee:97:7) + at evaluate (chapter3/interpreter.coffee:134:12) + at eprogn (chapter3/interpreter.coffee:80:7) + at chapter3/interpreter.coffee:78:9 + at update (chapter3/interpreter.coffee:105:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at update (chapter3/interpreter.coffee:107:7) + at chapter3/interpreter.coffee:148:11 + at evaluate (chapter3/interpreter.coffee:132:12) + at evaluate (chapter3/interpreter.coffee:147:26) + at eprogn (chapter3/interpreter.coffee:77:7) + at evaluate (chapter3/interpreter.coffee:146:27) + at module.exports (chapter3/interpreter.coffee:162:39) + at Context.<anonymous> (test/test_chapter3.coffee:27:12) + + + + + + at nvalu (chapter3/interpreter.coffee:11:19) + at handler (chapter3/interpreter.coffee:120:11) + at astSymbolsToLispSymbols (chapter3/interpreter.coffee:121:3) + at evaluate (chapter3/interpreter.coffee:150:26) + at evaluate (chapter3/interpreter.coffee:147:26) + at eprogn (chapter3/interpreter.coffee:77:7) + at evaluate (chapter3/interpreter.coffee:146:27) + at module.exports (chapter3/interpreter.coffee:162:39) + at Context.<anonymous> (test/test_chapter3.coffee:30:12) + + + + + + +Index: string +=================================================================== +--- string ++++ string + + at Context.<anonymous> (test/test_chapter3.coffee:36:108) + + + + + + at nvalu (chapter3/interpreter.coffee:11:19) + at handler (chapter3/interpreter.coffee:120:11) + at astSymbolsToLispSymbols (chapter3/interpreter.coffee:121:3) + at evaluate (chapter3/interpreter.coffee:150:26) + at chapter3/interpreter.coffee:157:9 + at evlis (chapter3/interpreter.coffee:90:5) + at evaluate (chapter3/interpreter.coffee:156:7) + at eprogn (chapter3/interpreter.coffee:80:7) + at evaluate (chapter3/interpreter.coffee:146:27) + at module.exports (chapter3/interpreter.coffee:162:39) + at Context.<anonymous> (test/test_chapter3.coffee:39:12) + + + + + diff --git a/test/test_chapter1.coffee b/test/test_chapter1.coffee index 02dbb86..cfc9ed7 100644 --- a/test/test_chapter1.coffee +++ b/test/test_chapter1.coffee @@ -2,17 +2,25 @@ chai = require 'chai' chai.should() expect = chai.expect +{cons} = require "cons-lists/lists" lisp = require '../chapter1/interpreter' {read, readForms} = require '../chapter1/reader' +the_false_value = (cons "false", "boolean") + describe "Core interpreter", -> - it "Should handle if statements", -> + it "Should handle true statements", -> expect(lisp read "(begin (if (lt 0 1) #t #f))").to.equal(true) - expect(lisp read "(begin (if (lt 1 0) #t #f))").to.equal(false) - expect(lisp read '(begin (if (lt 1 0) "y" "n"))').to.equal("n") + it "Should handle false statements", -> + expect(lisp read "(begin (if (lt 1 0) #t #f))").to.deep.equal(the_false_value) + it "Should handle return strings", -> expect(lisp read '(begin (if (lt 0 1) "y" "n"))').to.equal("y") - expect(lisp read '(begin (if (eq "y" "y") "y" "n"))').to.equal("y") - expect(lisp read '(begin (if (eq "y" "x") "y" "n"))').to.equal("n") + it "Should handle return strings when false", -> + expect(lisp read '(begin (if (lt 1 0) "y" "n"))').to.equal("n") + it "Should handle equivalent objects that are not intrinsically truthy", -> + expect(lisp read '(begin (if (eq? "y" "y") "y" "n"))').to.equal("y") + it "Should handle inequivalent objects that are not intrinsically truthy", -> + expect(lisp read '(begin (if (eq? "y" "x") "y" "n"))').to.equal("n") it "Should handle basic arithmetic", -> expect(lisp read '(begin (+ 5 5))').to.equal(10) @@ -21,7 +29,7 @@ describe "Core interpreter", -> expect(lisp read '(begin (- 9 5))').to.equal(4) it "Should handle some algebra", -> - expect(lisp read '(begin (* (+ 5 5) (* 2 3))').to.equal(60) + expect(lisp read '(begin (* (+ 5 5) (* 2 3)))').to.equal(60) it "Should handle a basic setting", -> expect(lisp read '(begin (set! fact 4) fact)').to.equal(4)