Disable Forbble REPL. Add Forbble-based tests

This commit is contained in:
Sage Vaillancourt 2021-07-05 05:09:32 -04:00
parent d4d1f27a63
commit 4974e87273
2 changed files with 22 additions and 15 deletions

View File

@ -157,18 +157,19 @@
; Math ; Math
(feval (: "sq" dup * $)) (feval (: "sq" dup * $))
; Gets next Fibonacci number from two on stack ; 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' ;; A simple REPL. Exits on 'q'
(def repl (fn (_) ( ;(def repl (fn (_) (
(prn "forbble::> ") ; (prn "forbble::> ")
(def _inp (inp 0 0)) ; (def _inp (inp 0 0))
(if (= "q" _inp) () ( ; (if (= "q" _inp) () (
(def _str (+ "(feval (" _inp "))" )) ; (def _str (+ "(feval (" _inp "))" ))
(eval _str) ; (eval _str)
(pch 10) ; (pch 10)
(repl 0) ; (repl 0)
))))) ; )))))
;
; Run the REPL ;; Run the REPL
(repl 0) ;(repl 0)

View File

@ -28,7 +28,7 @@ title() {
} }
pass() { pass() {
echo -n "✓" echo -n "✓"
((TOTAL_PASSES++)) ((TOTAL_PASSES++))
} }
@ -41,6 +41,7 @@ fail() {
check() { check() {
if $VALGRIND; then if $VALGRIND; then
echo -ne "\n $1 "
local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2") local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2")
else else
local output=$(./pl "(loadfile \"examples/lib.pbl\") $2") 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 )" 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 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" # title "Environment"
# check "EnvStressTestEarly" "(def a 1)(def b 20)(def c 'yee')(def d 'yeehunnid')(def e 3) (a)" "1" # 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" # 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"