module TestParser(tests) where import Test.HUnit import Parser.Lexer import Parser.JavaParser import Ast testSingleEmptyClass = TestCase $ assertEqual "expect single empty class hello" [Class "Hello" [] []] $ parse [CLASS, IDENTIFIER "Hello", LBRACKET, RBRACKET] testTwoEmptyClasses = TestCase $ assertEqual "expect two empty classes" [Class "Class1" [] [], Class "Class2" [] []] $ parse [CLASS,IDENTIFIER "Class1",LBRACKET,RBRACKET,CLASS,IDENTIFIER "Class2",LBRACKET,RBRACKET] testBooleanField = TestCase $ assertEqual "expect class with boolean field" [Class "WithBool" [] [VariableDeclaration "boolean" "value" Nothing]] $ parse [CLASS,IDENTIFIER "WithBool",LBRACKET,BOOLEAN,IDENTIFIER "value",SEMICOLON,RBRACKET] testIntField = TestCase $ assertEqual "expect class with int field" [Class "WithInt" [] [VariableDeclaration "int" "value" Nothing]] $ parse [CLASS,IDENTIFIER "WithInt",LBRACKET,INT,IDENTIFIER "value",SEMICOLON,RBRACKET] testCustomTypeField = TestCase $ assertEqual "expect class with foo field" [Class "WithFoo" [] [VariableDeclaration "Foo" "value" Nothing]] $ parse [CLASS,IDENTIFIER "WithFoo",LBRACKET,IDENTIFIER "Foo",IDENTIFIER "value",SEMICOLON,RBRACKET] tests = TestList [ testSingleEmptyClass, testTwoEmptyClasses, testBooleanField, testIntField, testCustomTypeField ]