From f1c6a24181918b1d6024f0aff4274ae88c578598 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Fri, 24 Jan 2025 01:39:15 -0600 Subject: [PATCH] I wonder how many tests there will be once these are all implemented --- test/Main.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/Main.hs b/test/Main.hs index ec17413..b115951 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -3,6 +3,7 @@ import Instructions.CodeInstructions import Instructions.ExecInstructions import Instructions.FloatInstructions import Instructions.IntInstructions +import Instructions.StringInstructions import Push import State @@ -30,6 +31,11 @@ codeTestFunc name goal genome startState = let state = loadProgram genome startState in assert (goal == _code (interpretExec state)) putStrLn (name <> " passed test.") +stringTestFunc :: String -> [String] -> [Gene] -> State -> IO () +stringTestFunc name goal genome startState = + let state = loadProgram genome startState + in assert (goal == _string (interpretExec state)) putStrLn (name <> " passed test.") + main :: IO () main = do -- Int tests @@ -138,3 +144,8 @@ main = do codeTestFunc "instructionCodeReverse2Args" [Block [GeneInt 2, GeneInt 1]] [StateFunc instructionCodeFromExec, Block [GeneInt 1, GeneInt 2], StateFunc instructionCodeReverse] emptyState codeTestFunc "instructionCodeReverse3Args" [Block [GeneInt 3, GeneInt 2, GeneInt 1]] [StateFunc instructionCodeFromExec, Block [GeneInt 1, GeneInt 2, GeneInt 3], StateFunc instructionCodeReverse] emptyState codeTestFunc "instructionCodeReverseNonBlock" [GeneInt 1] [StateFunc instructionCodeFromExec, GeneInt 1, StateFunc instructionCodeReverse] emptyState + + -- String tests + stringTestFunc "instructionStringConcat" ["123abc"] [GeneString "abc", GeneString "123", StateFunc instructionStringConcat] emptyState + stringTestFunc "instructionStringSwap" ["abc", "123"] [GeneString "abc", GeneString "123", StateFunc instructionStringSwap] emptyState + stringTestFunc "instructionStringInsertString" ["123INSabc"] [GeneString "abc", GeneString "123", StateFunc instructionStringConcat, GeneString "INS", StateFunc instructionStringSwap, GeneInt 3, StateFunc instructionStringInsertString] emptyState