1module Main where
2
3import Test.Tasty.Hspec
4import ATTParser
5import Control.Monad (forM_)
6
7main :: IO ()
8main = hspec $ do
9  describe "asm parser" $ do
10    -- 64bit
11    forM_ [("x86_64 linux", "test/asm/x86_64-linux.s")
12          ,("x86_64 macos", "test/asm/x86_64-mac.s")
13          ,("x86_64 mingw", "test/asm/x86_64-mingw32.s")
14          ,("aarch64 ios",  "test/asm/aarch64-ios.s")
15          ,("aarch64 linux","test/asm/aarch64.s")
16          ,("sparc64 linux","test/asm/sparc64-linux.s")
17          ,("mips64 linux", "test/asm/mips64-linux.s")
18          ,("powerpc64 linux","test/asm/powerpc64-linux.s")
19          ,("powerpc64le linux","test/asm/powerpc64le-linux.s")
20          ,("hppa linux",   "test/asm/hppa-linux.s")
21          ,("m68k linux",   "test/asm/m68k-linux.s")
22          ,("alpha linux",  "test/asm/alpha-linux.s")
23          ,("ia64 linux",   "test/asm/ia64-linux.s")
24          ,("nios2 linux",  "test/asm/nios2-linux.s")
25          ,("s390 linux",   "test/asm/s390-linux.s")
26          ,("s390x linux",  "test/asm/s390x-linux.s")
27          ,("sh4 linux",    "test/asm/sh4-linux.s")
28          ]
29      $ \(d, f) ->do
30      context d $ do
31        x <- runIO $ parse f
32
33        it "x should be 1" $ do
34          lookupInteger "x" x `shouldBe` (Just 1)
35        it "z should be 0xffffffffffffffff" $ do
36          lookupInteger "y" x `shouldBe` (Just 0xffffffffffffffff)
37        it "z should be -1" $ do
38          lookupInteger "z" x `shouldBe` (Just (-1))
39
40        it "t should be \"Hello World\\\"\\n\\0\"" $ do
41          lookupString "t" x `shouldBe` (Just "Hello World\" 12345\0")
42    -- 32 bit
43    forM_ [("arm ios",      "test/asm/arm-ios.s")
44          ,("arm linux",    "test/asm/arm.s")
45          ,("x86 linux",    "test/asm/x86-linux.s")
46          ,("sparc linux",  "test/asm/sparc-linux.s")
47          ,("mips linux",   "test/asm/mips-linux.s")
48          ,("powerpc linux","test/asm/powerpc-linux.s")
49          ]
50      $ \(d, f) ->do
51      context d $ do
52        x <- runIO $ parse f
53
54        it "x should be 1" $ do
55          lookupInteger "x" x `shouldBe` (Just 1)
56        it "z should be 0xffffffff" $ do
57          lookupInteger "y" x `shouldBe` (Just 0xffffffff)
58        it "z should be -1" $ do
59          lookupInteger "z" x `shouldBe` (Just (-1))
60
61        it "t should be \"Hello World\\\"\\n\\0\"" $ do
62          lookupString "t" x `shouldBe` (Just "Hello World\" 12345\0")
63
64
65