@@ -11,7 +11,8 @@ import Data.Generics.Labels
|
||||
|
||||
root :: IO TestTree
|
||||
root = pure . testGroup "stack machine" $
|
||||
[ add
|
||||
[ lit_int
|
||||
, arith
|
||||
]
|
||||
|
||||
|
||||
@@ -21,10 +22,17 @@ evalsTo rs bs = Sut.eval (MkProgram bs) @?= rs
|
||||
|
||||
|
||||
|
||||
add = testCase "lit int" do
|
||||
lit_int = testCase "lit int" do
|
||||
evalsTo [ValLit (LitInt 3)]
|
||||
[ MkBlock "main" []
|
||||
[ PopCont "ktail"
|
||||
, CallReg "ktail" [ValLit (LitInt 3)]
|
||||
]]
|
||||
|
||||
arith = testCase "arith" do
|
||||
evalsTo [ValLit (LitInt 12)]
|
||||
[ MkBlock "main" []
|
||||
[ PopCont "ktail"
|
||||
, Prim "x1" (PrimAdd (ValLit $ LitInt 3) (ValLit $ LitInt 4))
|
||||
, CallReg "ktail" [ValReg "x1"]
|
||||
]]
|
||||
|
||||
Reference in New Issue
Block a user