From 3a8615accd92fb7ec8d8aece5694991b62dba18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E4=BA=91?= <71159641+littlewhitecloud@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:47:10 +0800 Subject: [PATCH] update test --- tests/other_errors/import_file_with_main.jou | 14 +++++++------- tests/other_errors/imported/imported.jou | 10 ++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 tests/other_errors/imported/imported.jou 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