|
|
|
|
@@ -238,6 +238,40 @@ testStatementPreIncrement = TestCase $
|
|
|
|
|
assertEqual "expect increment" [StatementExpressionStatement $ PostIncrement $ Reference "a"] $
|
|
|
|
|
parseStatement [IDENTIFIER "a",INCREMENT,SEMICOLON]
|
|
|
|
|
|
|
|
|
|
testForLoop = TestCase $
|
|
|
|
|
assertEqual "expect for loop" [Block [
|
|
|
|
|
LocalVariableDeclaration (VariableDeclaration "int" "i" (Just (IntegerLiteral 0))),
|
|
|
|
|
While (BinaryOperation CompareLessThan (Reference "i") (IntegerLiteral 3)) (Block [Block [], StatementExpressionStatement (PostIncrement (Reference "i"))])
|
|
|
|
|
]] $
|
|
|
|
|
parseStatement [FOR,LBRACE,INT,IDENTIFIER "i",ASSIGN,INTEGERLITERAL 0,SEMICOLON,IDENTIFIER "i",LESS,INTEGERLITERAL 3,SEMICOLON,IDENTIFIER "i",INCREMENT,RBRACE,LBRACKET,RBRACKET]
|
|
|
|
|
testForLoopExpressionlistInInit = TestCase $
|
|
|
|
|
assertEqual "expect expressionlist in init part of for loop" [Block [
|
|
|
|
|
StatementExpressionStatement (PostIncrement (Reference "i")),
|
|
|
|
|
While (BinaryOperation CompareLessThan (Reference "i") (IntegerLiteral 3)) (Block [Block [], StatementExpressionStatement (PostIncrement (Reference "i"))])
|
|
|
|
|
]] $
|
|
|
|
|
parseStatement [FOR,LBRACE,IDENTIFIER "i",INCREMENT,SEMICOLON,IDENTIFIER "i",LESS,INTEGERLITERAL 3,SEMICOLON,IDENTIFIER "i",INCREMENT,RBRACE,LBRACKET,RBRACKET]
|
|
|
|
|
testForLoopMultipleUpdateExpressions = TestCase $
|
|
|
|
|
assertEqual "expect for loop with multiple update statements" [Block [
|
|
|
|
|
LocalVariableDeclaration (VariableDeclaration "int" "i" (Just (IntegerLiteral 0))),
|
|
|
|
|
While (BinaryOperation CompareLessThan (Reference "i") (IntegerLiteral 3)) (Block [Block [], StatementExpressionStatement (PostIncrement (Reference "i")), StatementExpressionStatement (PostIncrement (Reference "k"))])
|
|
|
|
|
]] $
|
|
|
|
|
parseStatement [FOR,LBRACE,INT,IDENTIFIER "i",ASSIGN,INTEGERLITERAL 0,SEMICOLON,IDENTIFIER "i",LESS,INTEGERLITERAL 3,SEMICOLON,IDENTIFIER "i",INCREMENT,COMMA,IDENTIFIER "k",INCREMENT,RBRACE,LBRACKET,RBRACKET]
|
|
|
|
|
testForLoopEmptyFirstPart = TestCase $
|
|
|
|
|
assertEqual "expect for loop with empty init part" [Block [
|
|
|
|
|
While (BinaryOperation CompareLessThan (Reference "i") (IntegerLiteral 3)) (Block [Block [], StatementExpressionStatement (PostIncrement (Reference "i"))])
|
|
|
|
|
]] $
|
|
|
|
|
parseStatement [FOR,LBRACE,SEMICOLON,IDENTIFIER "i",LESS,INTEGERLITERAL 3,SEMICOLON,IDENTIFIER "i",INCREMENT,RBRACE,LBRACKET,RBRACKET]
|
|
|
|
|
testForLoopEmtpySecondPart = TestCase $
|
|
|
|
|
assertEqual "expect for loop with empty expresion part" [Block [
|
|
|
|
|
While (BooleanLiteral True) (Block [Block [], StatementExpressionStatement (PostIncrement (Reference "i"))])
|
|
|
|
|
]] $
|
|
|
|
|
parseStatement [FOR,LBRACE,SEMICOLON,SEMICOLON,IDENTIFIER "i",INCREMENT,RBRACE,LBRACKET,RBRACKET]
|
|
|
|
|
testForLoopEmtpy = TestCase $
|
|
|
|
|
assertEqual "expect empty for loop" [Block [While (BooleanLiteral True) (Block [Block []])]] $
|
|
|
|
|
parseStatement [FOR,LBRACE,SEMICOLON,SEMICOLON,RBRACE,LBRACKET,RBRACKET]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests = TestList [
|
|
|
|
|
testSingleEmptyClass,
|
|
|
|
|
@@ -308,5 +342,11 @@ tests = TestList [
|
|
|
|
|
testStatementMethodCallNoParams,
|
|
|
|
|
testStatementConstructorCall,
|
|
|
|
|
testStatementConstructorCallWithArgs,
|
|
|
|
|
testStatementPreIncrement
|
|
|
|
|
testStatementPreIncrement,
|
|
|
|
|
testForLoop,
|
|
|
|
|
testForLoopExpressionlistInInit,
|
|
|
|
|
testForLoopMultipleUpdateExpressions,
|
|
|
|
|
testForLoopEmptyFirstPart,
|
|
|
|
|
testForLoopEmtpySecondPart,
|
|
|
|
|
testForLoopEmtpy
|
|
|
|
|
]
|