Clean us tests.sh

Use EDITOR in pebblisp.pbl config alias.
Toying with a promptUpdater function.
This commit is contained in:
Sage Vaillancourt 2022-04-07 16:42:39 -04:00 committed by Sage Vaillancourt
parent 6f82567e41
commit 03d3247be3
2 changed files with 82 additions and 70 deletions

View File

@ -31,7 +31,7 @@
(def aliases ( (def aliases (
(Alias "ls" "ls --color") (Alias "ls" "ls --color")
(Alias "alias" "(alias)") (Alias "alias" "(alias)")
(Alias "pbl" "vim ~/.pebblisp.pbl") (Alias "pbl" (cat (env "EDITOR") " ~/.pebblisp.pbl"))
(Alias "r" "(reloadConfig)") (Alias "r" "(reloadConfig)")
)) ))
@ -39,6 +39,16 @@
(reduce (map (fn (a) (cat nl a.name " -> " a.value)) aliases) cat "") (reduce (map (fn (a) (cat nl a.name " -> " a.value)) aliases) cat "")
))) )))
(def commRunning F)
(def promptUpdater (fn () (
(if commRunning () (
(prn (cat "" (prompt "")))
))
(sys "sleep 1")
(promptUpdater)
)))
(def preprocess (fn (text) ( (def preprocess (fn (text) (
(def matches (fil (fn (a) (= text a.name)) aliases)) (def matches (fil (fn (a) (= text a.name)) aliases))
(def match (first matches)) (def match (first matches))

View File

@ -91,24 +91,24 @@ check() {
echo "::SHELL TESTS::" echo "::SHELL TESTS::"
title "Plain returns" title "Basic Parsing"
check "PlainRet" "10" "10" check "Number" "10" "10"
check "StrRetrn" '"hey"' "hey" check "String" '"hey"' "hey"
check "HexReturn" "0x0f0f0" "61680" check "Hex Number" "0x0f0f0" "61680"
check "BinaryReturn" "0b011010011010011" "13523" check "Binary Number" "0b011010011010011" "13523"
title "Arithmetic" title "Arithmetic"
check "Addition" "(+ 1093 102852)" "103945" check "Addition" "(+ 1093 102852)" "103945"
check "Multiply" "(* 1000 10000)" "10000000" check "Multiply" "(* 1000 10000)" "10000000"
check "Division" "(/ 6418425 65)" "98745" check "Division" "(/ 6418425 65)" "98745"
check "ChainAdd" "(+ 3917 17304 1293844 400 100000)" "1415465" check "Chain Addition" "(+ 3917 17304 1293844 400 100000)" "1415465"
check "ChainMul" "(* 8263 23 123)" "23376027" check "Chain Multiplication" "(* 8263 23 123)" "23376027"
check "ChainDiv" "(/ 1493856 741 96 7)" "3" check "Chain Division" "(/ 1493856 741 96 7)" "3"
title "Comparison" title "Comparison"
check "GratrThn" "(> 23847123 19375933)" "T" check "Greater-Than" "(> 23847123 19375933)" "T"
check "GratrThnMulti" "(> 9999 55 1 0)" "T" check "Multiple Greater-Than" "(> 9999 55 1 0)" "T"
check "LessThan" "(< 23847123 19375933)" "F" check "Less-Than" "(< 23847123 19375933)" "F"
check "Equality" "(= 987654321 987654321 )" "T" check "Equality" "(= 987654321 987654321 )" "T"
check "String Equality" '(= "Bean" "Bean" )' "T" check "String Equality" '(= "Bean" "Bean" )' "T"
check "String Inequality" '(= "Beans" "Bean" )' "F" check "String Inequality" '(= "Beans" "Bean" )' "F"
@ -120,34 +120,33 @@ check "TripleQuotingWithQuotes" '"""My name is "yoink"."""' 'My name is "yoink".
title "TypeCheck" title "TypeCheck"
check "Is Num" "(isnum 23847123)" "T" check "Is Num" "(isnum 23847123)" "T"
check "IsntNum" '(isnum "WORDS")' "F"
check "Is String" '(isstr "words")' "T" check "Is String" '(isstr "words")' "T"
check "IsStringEmpty" '(isstr "")' "T" check "Empty String Is String" '(isstr "")' "T"
check "NumNotString" "(isstr 5)" "F" check "String Is Not Num" '(isnum "WORDS")' "F"
check "ListNotString" '(isstr ("hello"))' "F" check "List Is Not String" '(isstr ("hello"))' "F"
check "Num Is Not String" "(isstr 5)" "F"
title "Ifs/Bools" title "Ifs/Bools"
check "IfReturn" "(if (T) 123456789 987654321)" "123456789" check "IfReturn" "(if T 123456789 987654321)" "123456789"
check "IfRetTwo" "(if F 123456789 987654321)" "987654321" check "IfRetTwo" "(if F 123456789 987654321)" "987654321"
check "EmptyCnd" "(if () T F)" "F" check "EmptyCnd" "(if () T F)" "F"
check "EtyLstLt" "(if (()) T F)" "T" check "EtyLstLt" "(if (()) T F)" "T"
title "Lists" title "Lists"
check "RegLists" "(1 2 3 4 5)" "( 1 2 3 4 5 )" check "Normal List" "(1 2 3 4 5)" "( 1 2 3 4 5 )"
check "MultiTypeList" '(10 20 "rascals")' "( 10 20 rascals )" check "Heterogenous List" '(10 20 "rascals")' "( 10 20 rascals )"
check "EmptyLst" "()" "( )" check "Empty List" "()" "( )"
check "EmptLst2" "( )" "( )"
check "List Index" "(at (+ 1 1) (1 2 1000 4 5))" "1000" check "List Index" "(at (+ 1 1) (1 2 1000 4 5))" "1000"
check "EvalElems" "((* 10 10) 7)" "( 100 7 )" check "Eval List Elements" "((* 10 10) 7)" "( 100 7 )"
check "Append To List" "(ap (1 20 300 4000 50000) 600000)" "( 1 20 300 4000 50000 600000 )" check "Append To List" "(ap (1 20 300 4000 50000) 600000)" "( 1 20 300 4000 50000 600000 )"
check "AppndToEnvList" "(def l (50000 4000 300 20)) (def l (ap l 1)) l" "( 50000 4000 300 20 1 )" check "Append To List In Env" "(def l (50000 4000 300 20)) (def l (ap l 1)) l" "( 50000 4000 300 20 1 )"
check "PrependToList" "(pre (1 20 300 4000 50000) 600000)" "( 600000 1 20 300 4000 50000 )" check "Prepend On List" "(pre (1 20 300 4000 50000) 600000)" "( 600000 1 20 300 4000 50000 )"
check "PrepndToEnvList" "(def l (50000 4000 300 20)) (def l (pre l 1)) l" "( 1 50000 4000 300 20 )" check "Prepend On Env List" "(def l (50000 4000 300 20)) (def l (pre l 1)) l" "( 1 50000 4000 300 20 )"
check "Rest(Tail)OfList" "(def l (50000 4000 300 20)) (rest l)" "( 4000 300 20 )" check "Rest Of List" "(def l (50000 4000 300 20)) (rest l)" "( 4000 300 20 )"
check "List Length" "(def l (1 20 3 \"abc\" \"banana\" (+ 10 5))) (len l)" "6" check "List Length" "(def l (1 20 3 \"abc\" \"banana\" (+ 10 5))) (len l)" "6"
check "Identifying list" "(islist (1 2 3))" "T" check "Identifying List" "(islist (1 2 3))" "T"
check "Identifying empty list" "(islist ())" "T" check "Identifying Empty List" "(islist ())" "T"
check "Identifying not a list" "(islist 1)" "F" check "Identifying Not A List" "(islist 1)" "F"
deep_nesting="10" deep_nesting="10"
for _ in {0..25}; do deep_nesting="( $deep_nesting )"; done for _ in {0..25}; do deep_nesting="( $deep_nesting )"; done
@ -156,6 +155,7 @@ check "DeepNesting" "$deep_nesting" "$deep_nesting" # Above 25 it starts to stac
title "Spacing" title "Spacing"
check "Wide Spacing" "( + 1093 102852 )" "103945" check "Wide Spacing" "( + 1093 102852 )" "103945"
check "Very Wide Spacing" " ( + 1093 102852 ) " "103945" check "Very Wide Spacing" " ( + 1093 102852 ) " "103945"
check "Wide Empty List" "( )" "( )"
title "DemoFunctions" title "DemoFunctions"
check "Squaring" "(sq 9876)" "97535376" check "Squaring" "(sq 9876)" "97535376"
@ -167,9 +167,9 @@ check "MinRight" "(min 8429 192449)" "8429"
check "MinLeft" "(min 17294722 17294721)" "17294721" check "MinLeft" "(min 17294722 17294721)" "17294721"
title "Lambdas" title "Lambdas"
check "MultStmt" "(def yee (fn (a) (* 10 a))) ; (yee 5)" "50" check "Multi-Statement" "(def yee (fn (a) (* 10 a))) ; (yee 5)" "50"
check "MultStmtNoSemi" "(def yee (fn (a) (* 10 a)))(yee 5)" "50" check "Multi-Statement, No Semicolon" "(def yee (fn (a) (* 10 a)))(yee 5)" "50"
check "DefinMap" "(def yee (fn (a) (* 10 a))) ; (map yee (5 10 2 (+ 12 0)))" "( 50 100 20 120 )" check "Pre-Defined Map" "(def yee (fn (a) (* 10 a))) ; (map yee (5 10 2 (+ 12 0)))" "( 50 100 20 120 )"
check "AnonymousLambda" "\ check "AnonymousLambda" "\
(map (fn (a) (* a a)) (5 6 7))" "( 25 36 49 )" (map (fn (a) (* a a)) (5 6 7))" "( 25 36 49 )"
check "FbnciSeq" "\ check "FbnciSeq" "\
@ -190,7 +190,7 @@ check "LambdaClone" "(def y (fn (a) (* 10 a))) (def b y) (def y 12345) ((b 5) y)
check "Duplicate" "(def dupe (fn (a) (() (a a a))));(dupe (* 10 10))" "( 100 100 100 )" check "Duplicate" "(def dupe (fn (a) (() (a a a))));(dupe (* 10 10))" "( 100 100 100 )"
title "Cat" title "Cat"
check "ExplicitCat" '(cat "Big" " Kitty")' "Big Kitty" check "Basic Cat" '(cat "Big" " Kitty")' "Big Kitty"
check "Cat Nums" '(cat "There are " (+ 2 3) " kitties")' "There are 5 kitties" check "Cat Nums" '(cat "There are " (+ 2 3) " kitties")' "There are 5 kitties"
title "Filtering" title "Filtering"
@ -199,7 +199,7 @@ check "FilterEval" "(fil (fn (a) (= 1000 a)) ((+ 450 550) (* 20 50) (/ 30 3) (-
check "MapFilter" "(fil (fn (a) (< 50 a)) (map sq (1 2 3 4 5 6 7 8 9 10 11 12)))" "( 64 81 100 121 144 )" check "MapFilter" "(fil (fn (a) (< 50 a)) (map sq (1 2 3 4 5 6 7 8 9 10 11 12)))" "( 64 81 100 121 144 )"
title "Structs" title "Structs"
check "StructDef" "(struct Post (title body))" "T" check "Struct Definition" "(struct Post (title body))" "T"
check "Building a struct"\ check "Building a struct"\
'(struct Post (title body)) (Post "A title" "The Body")'\ '(struct Post (title body)) (Post "A title" "The Body")'\
'{ title: "A title", body: "The Body" }' '{ title: "A title", body: "The Body" }'
@ -208,16 +208,16 @@ check "Accessing struct fields"\
"( TITLE BODY )" "( TITLE BODY )"
title "HigherOrder" title "HigherOrder"
check "Simple reducing" '(reduce (1 2 3) + 0)' '6' check "Simple Reduction" '(reduce (1 2 3) + 0)' '6'
check "NonListReducing" '(reduce 1 + 0)' '1' check "Non-List Reduction" '(reduce 1 + 0)' '1'
check "StringReducing" '(reduce (" my" " friend") cat "Hello,")' 'Hello, my friend' check "String Reduction" '(reduce (" my" " friend") cat "Hello,")' 'Hello, my friend'
check "FuncReturningAFunc" "(def plusser (fn (outer) (fn (inner) (+ outer inner))))\ check "Lambda Returning a Lambda" "(def plusser (fn (outer) (fn (inner) (+ outer inner))))\
(def plusFive (plusser 5))\ (def plusFive (plusser 5))\
(plusFive 10)" "15" (plusFive 10)" "15"
title "ShouldError" title "ShouldError"
check "LenOfNotList" "(len 5)" regex "BAD_PARAMS.*" check "Len of Not-List" "(len 5)" regex "BAD_PARAMS.*"
check "NoMapList" "(map sq)" "NULL_MAP_ARGS" check "Map With No List" "(map sq)" "NULL_MAP_ARGS"
check "Bad Number" "(5df)" regex "BAD_NUMBER.*" check "Bad Number" "(5df)" regex "BAD_NUMBER.*"
check "Bad Hex" "(0x0zf)" regex "BAD_NUMBER.*" check "Bad Hex" "(0x0zf)" regex "BAD_NUMBER.*"
check "Bad Binary" "(0b01120)" regex "BAD_NUMBER.*" check "Bad Binary" "(0b01120)" regex "BAD_NUMBER.*"
@ -231,14 +231,16 @@ check "BadParens6" '(ey")"' regex "MISMATCHED_PARENS.*"
title "ListArithmetic" disabled title "ListArithmetic" disabled
check "Uneven Lists" "(+ (1 2) (1 2 3))" "LISTS_NOT_SAME_SIZE" check "Uneven Lists" "(+ (1 2) (1 2 3))" "LISTS_NOT_SAME_SIZE"
check "ListAddi" "(+ 5 (1 2 3 (+ 10 10)))" "( 6 7 8 25 )" check "List Addition" "(+ 5 (1 2 3 (+ 10 10)))" "( 6 7 8 25 )"
check "ListModu" "(% 5 (1 2 3 (* 11 11)))" "( 1 2 3 1 )" check "List Modulo" "(% 5 (1 2 3 (* 11 11)))" "( 1 2 3 1 )"
check "ListsMul" "(* (10 20 30) (1 20 300))" "( 10 400 9000 )" check "List Multiplication" "(* (10 20 30) (1 20 300))" "( 10 400 9000 )"
title "Eval" title "Eval"
check "Basic Number Eval" '(eval "5")' "5" check "Basic Number Eval" '(eval "5")' "5"
check "Basic Op Eval" '(eval "(+ 5 10)")' "15" check "Basic Op Eval" '(eval "(+ 5 10)")' "15"
check "MapFilter" '(eval "(fil (fn (a) (< 50 a)) (map sq (1 2 3 4 5 6 7 8 9 10 11 12)))")' "( 64 81 100 121 144 )" check "Map Filter" \
'(eval "(fil (fn (a) (< 50 a)) (map sq (1 2 3 4 5 6 7 8 9 10 11 12)))")' \
"( 64 81 100 121 144 )"
title "Forbble" disabled title "Forbble" disabled
check "BasicForbbleOp" '(loadfile "examples/forbble.pbl") (feval (10 10 * .)) ""' "100" check "BasicForbbleOp" '(loadfile "examples/forbble.pbl") (feval (10 10 * .)) ""' "100"