diff --git a/tests/other_errors/import_file_with_main.jou b/tests/other_errors/import_file_with_main.jou index 4f9171f5..ff4a1c08 100644 --- a/tests/other_errors/import_file_with_main.jou +++ b/tests/other_errors/import_file_with_main.jou @@ -1,7 +1,7 @@ -import "./imported.jou" -import "stdlib/io.jou" - -def main() -> int: - printf("%d", add(114, 514)) - - return 0 +import "./imported/imported.jou" +import "stdlib/io.jou" + +def main() -> int: # Output: compiler error in file "tests/other_errors/imported/imported.jou": imported file should not have `main` function + printf("%d", add(114, 514)) + + return 0 diff --git a/tests/other_errors/imported/imported.jou b/tests/other_errors/imported/imported.jou new file mode 100644 index 00000000..846baf44 --- /dev/null +++ b/tests/other_errors/imported/imported.jou @@ -0,0 +1,10 @@ +# This file is meant to be imported, not ran directly. + +import "stdlib/io.jou" + +def add(a: int, b: int) -> int: + return a + b + +def main() -> int: + printf("%d", add(1, 2)) + return 0