diff --git a/lib/Bril.hs b/lib/Bril.hs index ad89ae8..99ffcbc 100644 --- a/lib/Bril.hs +++ b/lib/Bril.hs @@ -120,24 +120,24 @@ instrFromString s instance Show InstrOperation where show op = case op of - Nop -> "add" - Add -> "sub" - Sub -> "mul" - Mul -> "eq" - Eq -> "lt" - Lt -> "gt" - Gt -> "le" - Le -> "ge" - Ge -> "not" - Not -> "and" - And -> "or" - Or -> "jmp" - Jmp -> "br" - Br -> "ret" - Ret -> "call" - Call -> "print" - Print -> "id" - Id -> "nop" + Add -> "add" + Sub -> "sub" + Mul -> "mul" + Eq -> "eq" + Lt -> "lt" + Gt -> "gt" + Le -> "le" + Ge -> "ge" + Not -> "not" + And -> "and" + Or -> "or" + Jmp -> "jmp" + Br -> "br" + Ret -> "ret" + Call -> "call" + Print -> "print" + Id -> "id" + Nop -> "nop" optionalArrayField :: FromJSON a => Data.Aeson.Object -> Data.Aeson.Key -> Parser [a] diff --git a/tests/Main.hs b/tests/Main.hs index 671c9f9..a96407a 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -81,6 +81,10 @@ testInstrs = TestCase $ do (eitherDecode "{\"op\": \"id\", \"dest\": \"a\", \"type\": \"bool\", \"args\": [\"b\"]}") (Right $ B.ValueInstr B.Id B.Bool "a" ["b"] [] []) + assertEqual "parse label" + (eitherDecode "{\"label\": \"test\"}") + (Right $ B.Label "test") + testProgramFromFiles :: Test testProgramFromFiles = TestCase $ do res <- try $ (B.parseBrilFromPath "bril-sources/add.json") :: IO (Either IOError (Either String B.Program))