Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkobelka committed Nov 20, 2017
1 parent 84782bd commit 073ac66
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ifj2017/tests/02_functions/26.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
' Multiple return inside function

function foo() as integer
return 42
return 31
return 22
end function

scope
dim b as integer
b = foo()
print b;
end scope
14 changes: 14 additions & 0 deletions ifj2017/tests/02_functions/27.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
' Condition return

function get_integer(a as integer) as integer
if a < 2 then
return 42
else
end if
end function

scope
dim b as string
b = get_integer(25)
print b;
end scope
9 changes: 9 additions & 0 deletions ifj2017/tests/02_functions/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"name": "25",
"stdout": " 486",
"timeout": 2
},
{
"name": "26",
"stdout": " 42"
},
{
"name": "27",
"compiler_exit_code": 4,
"stdout": " 0"
}
]
}
35 changes: 35 additions & 0 deletions ifj2017/tests/66_errors/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,41 @@
"info": "Empty file",
"name": "17",
"compiler_exit_code": 2
},
{
"info": "Function after scope",
"compiler_exit_code": 2,
"code": "scope \n end scope \n function foo() as integer \n end function"
},
{
"info": "Declaration after scope",
"compiler_exit_code": 2,
"code": "scope \n end scope \n declare function foo() as integer"
},
{
"info": "No end scope",
"compiler_exit_code": 2,
"code": "scope \n dim a as integer \n print a;"
},
{
"info": "No end function",
"compiler_exit_code": 2,
"code": "function foo() as integer \n scope \n end scope"
},
{
"info": "Print without semicolon",
"compiler_exit_code": 2,
"code": "scope \n print 10 \n end scope"
},
{
"info": "Print without semicolon 2",
"compiler_exit_code": 2,
"code": "scope \n print 10; 10\n end scope"
},
{
"info": "Print without semicolon 2",
"compiler_exit_code": 2,
"code": "scope \n print 10 10;\n end scope"
}

]
Expand Down

0 comments on commit 073ac66

Please sign in to comment.