diff --git a/ifj2017/tests/02_functions/26.code b/ifj2017/tests/02_functions/26.code new file mode 100644 index 0000000..cd6b98a --- /dev/null +++ b/ifj2017/tests/02_functions/26.code @@ -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 diff --git a/ifj2017/tests/02_functions/27.code b/ifj2017/tests/02_functions/27.code new file mode 100644 index 0000000..8b94247 --- /dev/null +++ b/ifj2017/tests/02_functions/27.code @@ -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 diff --git a/ifj2017/tests/02_functions/tests.json b/ifj2017/tests/02_functions/tests.json index a4b7c1f..bb132a5 100644 --- a/ifj2017/tests/02_functions/tests.json +++ b/ifj2017/tests/02_functions/tests.json @@ -77,6 +77,15 @@ "name": "25", "stdout": " 486", "timeout": 2 + }, + { + "name": "26", + "stdout": " 42" + }, + { + "name": "27", + "compiler_exit_code": 4, + "stdout": " 0" } ] } \ No newline at end of file diff --git a/ifj2017/tests/66_errors/tests.json b/ifj2017/tests/66_errors/tests.json index cf6c0fb..0052b9b 100644 --- a/ifj2017/tests/66_errors/tests.json +++ b/ifj2017/tests/66_errors/tests.json @@ -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" } ]