a fully working interpreter?

This commit is contained in:
Taylor 2025-01-15 13:02:27 -06:00
parent f65deb926a
commit 4ccd660763
2 changed files with 21 additions and 1 deletions

View File

@ -52,7 +52,6 @@ intAdd (State es (i : is) fs bs ss ps) = State es ((i + head is) : drop 1 is) fs
-- let result = sum (take 2 (int state))
-- dropped = drop 2 (int state)
-- in updateIntStack (result : dropped) state
-- For safety, pattern match on [] and i:is or check for <2 long list after take 2?
-- Optionally, split this off into independent functions

21
src/Tests.hs Normal file
View File

@ -0,0 +1,21 @@
module Tests where
import Push
exampleState =
State
{ exec = [IntGene 5, FloatGene 3.4, BoolGene True, StringGene "hi"],
int = [1, 2, 3],
float = [1.2, 1.7],
bool = [True, False],
string = ["Hello", "Push"],
parameter = [IntGene 1, StringGene "Hi", BoolGene True, FloatGene 1.3]
}
-- intAdd
testResult1 = [3, 3] == int (intAdd exampleState)
loaded = loadProgarm [IntGene 6, IntGene 6, StateFunc intAdd] emptyState
-- interpretExec
testResult2 = [12] == int (interpretExec loaded)