From 040f502492a9622224670f7e337c2b8b9d9c7f9a Mon Sep 17 00:00:00 2001 From: Derek Verbrugge Date: Thu, 27 Oct 2022 15:43:20 -0400 Subject: [PATCH 1/3] adds andPreFlagTestCase --- test/TinyRAM/Spec/EndToEndSpec.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/TinyRAM/Spec/EndToEndSpec.hs b/test/TinyRAM/Spec/EndToEndSpec.hs index 91dae8b..4920236 100644 --- a/test/TinyRAM/Spec/EndToEndSpec.hs +++ b/test/TinyRAM/Spec/EndToEndSpec.hs @@ -37,6 +37,7 @@ spec = describe "TinyRAM end to end" $ do andTestCase andTestNegativeCase --andFlagTestCase bugged reported + andPreFlagTestCase cjmpTestCase jmpTestExampleNonTermCase negativeTestCase @@ -194,6 +195,20 @@ andTestCase = -- answer <- execute program (InputTape []) (InputTape []) -- answer `shouldBe` Right 0 +andPreFlagTestCase :: Spec +andPreFlagTestCase = + it "answers 0" $ do + let program = + construct + [ Mov (reg' 0) (imm 0), + Cmov (reg' 0) (imm 1), + Mov (reg' 2) (imm 58), + And (reg' 3) (reg' 2) (imm 15), + Answer (reg 0) + ] + answer <- execute program (InputTape []) (InputTape []) + answer `shouldBe` Right 0 + --; TinyRAM V=1.000 W=16 K=16 --mov r2, 58 --and r1, r2, -15 From 7f37d6c9511640fa06c1be033eeb545515c32c58 Mon Sep 17 00:00:00 2001 From: Derek Verbrugge Date: Thu, 27 Oct 2022 15:55:05 -0400 Subject: [PATCH 2/3] demonstrates notFlagTestCase bug --- test/TinyRAM/Spec/EndToEndSpec.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/TinyRAM/Spec/EndToEndSpec.hs b/test/TinyRAM/Spec/EndToEndSpec.hs index 4920236..a0feb98 100644 --- a/test/TinyRAM/Spec/EndToEndSpec.hs +++ b/test/TinyRAM/Spec/EndToEndSpec.hs @@ -48,6 +48,8 @@ spec = describe "TinyRAM end to end" $ do addTestNegativeTestCase subTestCase --notTestCase --negative answer bugged + --notPreFlagTestCase + notFlagTestCase mullTestCase umulhTestCase smulhTestCase @@ -810,6 +812,20 @@ subTestCase = --mull r1, r2, 2 --answer r1 +notFlagTestCase :: Spec +notFlagTestCase = + it "answers -11" $ do + let program = + construct + [ Mov (reg' 1) (imm 11), + Not (reg' 0) (reg 1), + Cmov (reg' 0) (imm 1), + Answer (reg 0) + ] + answer <- execute program (InputTape []) (InputTape []) + answer `shouldBe` Right (Word (word16ToInteger (negate 11))) + + mullTestCase :: Spec mullTestCase = it "answers 10" $ do From 97144a2cd506239c84d7c03d2e5bcf504aa73e83 Mon Sep 17 00:00:00 2001 From: Derek Verbrugge Date: Thu, 27 Oct 2022 16:09:07 -0400 Subject: [PATCH 3/3] notFlagTestCase bug --- test/TinyRAM/Spec/EndToEndSpec.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/TinyRAM/Spec/EndToEndSpec.hs b/test/TinyRAM/Spec/EndToEndSpec.hs index a0feb98..7f1d006 100644 --- a/test/TinyRAM/Spec/EndToEndSpec.hs +++ b/test/TinyRAM/Spec/EndToEndSpec.hs @@ -796,7 +796,7 @@ subTestCase = -- notTestCase :: Spec -- notTestCase = --- it "answers -11" $ do +-- it "answers 65524" $ do -- let program = -- construct -- [ Mov (reg' 1) (imm 11), @@ -804,7 +804,7 @@ subTestCase = -- Answer (reg 0) -- ] -- answer <- execute program (InputTape []) (InputTape []) --- answer `shouldBe` Right (Word (word16ToInteger (negate 11))) +-- answer `shouldBe` Right 65524 --mullTestCase --; TinyRAM V=1.000 W=16 K=16 @@ -814,7 +814,7 @@ subTestCase = notFlagTestCase :: Spec notFlagTestCase = - it "answers -11" $ do + it "answers 65524" $ do let program = construct [ Mov (reg' 1) (imm 11), @@ -823,7 +823,7 @@ notFlagTestCase = Answer (reg 0) ] answer <- execute program (InputTape []) (InputTape []) - answer `shouldBe` Right (Word (word16ToInteger (negate 11))) + answer `shouldBe` Right 65524 mullTestCase :: Spec