diff --git a/Test/TestParser.hs b/Test/TestParser.hs new file mode 100644 index 0000000..23346f3 --- /dev/null +++ b/Test/TestParser.hs @@ -0,0 +1,14 @@ +module TestParser(tests) where + +import Test.HUnit +import Parser.Lexer +import Parser.JavaParser + + +testIntLiteral = TestCase $ assertEqual "IntLiteral 34" [IntLiteral 34] $ parse (INTLITERAL 34) + +testAnd = TestCase $ assertEqual "scan '&&'" [AND] $ alexScanTokens "&&" + +tests = TestList [ + testIntLiteral + ] \ No newline at end of file diff --git a/Test/TestSuite.hs b/Test/TestSuite.hs index 9748fba..1fd2cbb 100644 --- a/Test/TestSuite.hs +++ b/Test/TestSuite.hs @@ -1,11 +1,13 @@ module Main where import Test.HUnit -import Parser.Lexer import TestLexer +-- import TestParser -otherTest = TestCase $ assertEqual "math" (4+3) 7 -tests = TestList [TestLabel "TestLexer" TestLexer.tests, TestLabel "mathTest" otherTest] +tests = TestList [ + TestLabel "TestLexer" TestLexer.tests + -- TestLabel "TestParser" TestParser.tests + ] main = do runTestTTAndExit Main.tests \ No newline at end of file diff --git a/project.cabal b/project.cabal index 69ef52a..357434e 100644 --- a/project.cabal +++ b/project.cabal @@ -12,7 +12,7 @@ executable compiler default-language: Haskell2010 hs-source-dirs: src build-tool-depends: alex:alex, happy:happy - other-modules: Parser.Lexer, Ast + other-modules: Parser.Lexer, Parser.JavaParser, Ast test-suite tests type: exitcode-stdio-1.0 @@ -22,4 +22,8 @@ test-suite tests array, HUnit build-tool-depends: alex:alex, happy:happy - other-modules: Parser.Lexer, TestLexer + other-modules: Parser.Lexer, + Parser.JavaParser, + Ast, + TestLexer + TestParser