Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xor pre flag test case bug #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/TinyRAM/Spec/EndToEndSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ spec = describe "TinyRAM end to end" $ do
andTestCase
andTestNegativeCase
--andFlagTestCase bugged reported
andPreFlagTestCase
cjmpTestCase
jmpTestExampleNonTermCase
negativeTestCase
negative8bitTestCase
orTestCase
orFlagTestCase
--xorTestCase --bugged reported
xorPreFlagTestCase
addTestNegativeTestCase
subTestCase
--notTestCase --negative answer bugged
Expand Down Expand Up @@ -194,6 +196,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
Expand Down Expand Up @@ -741,6 +757,19 @@ orFlagTestCase =
-- answer <- execute program (InputTape []) (InputTape [])
-- answer `shouldBe` Right 15

xorPreFlagTestCase :: Spec
xorPreFlagTestCase =
it "answers 15" $ do
let program =
construct
[ Mov (reg' 2) (imm 15),
Cmov (reg' 0) (imm 1),
Xor (reg' 0) (reg' 2) (reg 2),
Answer (reg 0)
]
answer <- execute program (InputTape []) (InputTape [])
answer `shouldBe` Right 15

addTestNegativeTestCase :: Spec
addTestNegativeTestCase =
it "answers 3" $ do
Expand Down