a fully working interpreter?
This commit is contained in:
parent
f65deb926a
commit
4ccd660763
@ -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
21
src/Tests.hs
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user