diff --git a/src/examples/forbble.pbl b/src/examples/forbble.pbl index 85792b3..1e389b9 100755 --- a/src/examples/forbble.pbl +++ b/src/examples/forbble.pbl @@ -157,18 +157,19 @@ ; Math (feval (: "sq" dup * $)) ; Gets next Fibonacci number from two on stack -(feval (: "fib" swap over + dup . $)) +(feval (: "_f" swap over + $)) +(feval (: "fib" _f dup . $)) -; A simple REPL. Exits on 'q' -(def repl (fn (_) ( - (prn "forbble::> ") - (def _inp (inp 0 0)) - (if (= "q" _inp) () ( - (def _str (+ "(feval (" _inp "))" )) - (eval _str) - (pch 10) - (repl 0) - ))))) - -; Run the REPL -(repl 0) +;; A simple REPL. Exits on 'q' +;(def repl (fn (_) ( +; (prn "forbble::> ") +; (def _inp (inp 0 0)) +; (if (= "q" _inp) () ( +; (def _str (+ "(feval (" _inp "))" )) +; (eval _str) +; (pch 10) +; (repl 0) +; ))))) +; +;; Run the REPL +;(repl 0) diff --git a/src/tests.sh b/src/tests.sh index 7f39c23..eab3e6e 100755 --- a/src/tests.sh +++ b/src/tests.sh @@ -28,7 +28,7 @@ title() { } pass() { - echo -n "✓" + echo -n "✓" ((TOTAL_PASSES++)) } @@ -41,6 +41,7 @@ fail() { check() { if $VALGRIND; then + echo -ne "\n $1 " local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2") else local output=$(./pl "(loadfile \"examples/lib.pbl\") $2") @@ -189,6 +190,11 @@ check "BasicOpEval" "(eval \"(+ 5 10)\")" "15" check "MapFilter" "(eval \"(fil (< 50) (map sq (1 2 3 4 5 6 7 8 9 10 11 12)))\")" "( 64 81 100 121 144 )" endBlock +title "Forbble" +check "BasicForbbleOp" "(loadfile 'examples/forbble.pbl') (feval (10 10 * .)) ''" "100" +check "FibForbble" "(loadfile 'examples/forbble.pbl') (feval (1 1 _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f _f .)) ''" "28657" +endBlock + # title "Environment" # check "EnvStressTestEarly" "(def a 1)(def b 20)(def c 'yee')(def d 'yeehunnid')(def e 3) (a)" "1" # check "EnvStressTestLate" "(def a 1)(def b 2)(def c 3)(def d 4)(def e 5)(def f 6)(def n 40) (n)" "40"