From 7857473434289be3cfab2fe4cb631eaf3644c434 Mon Sep 17 00:00:00 2001 From: szdytom Date: Sun, 27 Aug 2023 14:09:29 +0800 Subject: [PATCH] Add more test cases Signed-off-by: szdytom --- scripts/check.py | 2 +- tests/fail/lang-change-local-var.ac | 8 ++++++++ tests/fail/logic-use-self.ac | 8 ++++++++ tests/ok/function-types1.ac | 7 +++++++ tests/ok/function-types2.ac | 7 +++++++ tests/ok/lambda-capture.ac | 9 +++++++++ tests/ok/local-vars.ac | 8 ++++++++ tests/ok/multi-thoerems.ac | 15 +++++++++++++++ tests/ok/nested-types.ac | 9 +++++++++ tests/ok/unicode-letters.ac | 7 +++++++ 10 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/fail/lang-change-local-var.ac create mode 100644 tests/fail/logic-use-self.ac create mode 100644 tests/ok/function-types1.ac create mode 100644 tests/ok/function-types2.ac create mode 100644 tests/ok/lambda-capture.ac create mode 100644 tests/ok/local-vars.ac create mode 100644 tests/ok/multi-thoerems.ac create mode 100644 tests/ok/nested-types.ac create mode 100644 tests/ok/unicode-letters.ac diff --git a/scripts/check.py b/scripts/check.py index 0827630..bbf5355 100644 --- a/scripts/check.py +++ b/scripts/check.py @@ -32,7 +32,7 @@ def test_compiler(test_dir, should_fail): passed_files += 1 else: if 'error' in result.stdout: - print(f' {Color.RED}测试失败:{Color.RESET} {file_path} 应该编译通过,但是发现错误: {result.stderr}') + print(f' {Color.RED}测试失败:{Color.RESET} {file_path} 应该编译通过,但是发现错误。') has_failed_tests = True else: print(f' {Color.GREEN}测试通过:{Color.RESET} {file_path}') diff --git a/tests/fail/lang-change-local-var.ac b/tests/fail/lang-change-local-var.ac new file mode 100644 index 0000000..19975c4 --- /dev/null +++ b/tests/fail/lang-change-local-var.ac @@ -0,0 +1,8 @@ +struct { + +T1 = Fn(h: A, y: B) -> A { + z = y; + z = h; + return z; +}; +} main; diff --git a/tests/fail/logic-use-self.ac b/tests/fail/logic-use-self.ac new file mode 100644 index 0000000..74d2049 --- /dev/null +++ b/tests/fail/logic-use-self.ac @@ -0,0 +1,8 @@ +struct { + +T1 = Fn(h: A) -> B { + return T1(h); +}; + +} main; + diff --git a/tests/ok/function-types1.ac b/tests/ok/function-types1.ac new file mode 100644 index 0000000..f3a5fc0 --- /dev/null +++ b/tests/ok/function-types1.ac @@ -0,0 +1,7 @@ +struct { + +T1 = Fn(h1: Fn(<>, , B), h2: A) -> B { + return h1(h2); +}; + +} main; diff --git a/tests/ok/function-types2.ac b/tests/ok/function-types2.ac new file mode 100644 index 0000000..9a5b141 --- /dev/null +++ b/tests/ok/function-types2.ac @@ -0,0 +1,7 @@ +struct { + +T1 = Fn(h1: Fn(, , B)) -> B { + return h1(h1); +}; + +} main; diff --git a/tests/ok/lambda-capture.ac b/tests/ok/lambda-capture.ac new file mode 100644 index 0000000..0b8e905 --- /dev/null +++ b/tests/ok/lambda-capture.ac @@ -0,0 +1,9 @@ +struct { + +T = Fn(z: Fn(<>, , b), y: Fn(<>, , c)) -> Fn(<>, , c) { + return Fn<>(h: a) -> c { + return y(z(h)); + }; +}; + +} main; diff --git a/tests/ok/local-vars.ac b/tests/ok/local-vars.ac new file mode 100644 index 0000000..5179bd5 --- /dev/null +++ b/tests/ok/local-vars.ac @@ -0,0 +1,8 @@ +struct { + +T1 = Fn(h1: A) -> A { + h2 = h1; + return h2; +}; + +} main; diff --git a/tests/ok/multi-thoerems.ac b/tests/ok/multi-thoerems.ac new file mode 100644 index 0000000..19fdee0 --- /dev/null +++ b/tests/ok/multi-thoerems.ac @@ -0,0 +1,15 @@ +struct { + +T1 = Fn(a: A) -> A { + return a; +}; + +T2 = Fn(a: b) -> b { + return a; +}; + +T3 = Fn(a: c) -> c { + return T2(T2(T1(a))); +}; + +} main; diff --git a/tests/ok/nested-types.ac b/tests/ok/nested-types.ac new file mode 100644 index 0000000..35c7c96 --- /dev/null +++ b/tests/ok/nested-types.ac @@ -0,0 +1,9 @@ +struct { + +T1 = Fn(h1: Fn(, , , C)>, B)) -> B { + return h1(Fn<>(h: B) -> B{ + return h; + }); +}; + +} main; diff --git a/tests/ok/unicode-letters.ac b/tests/ok/unicode-letters.ac new file mode 100644 index 0000000..4f09e6e --- /dev/null +++ b/tests/ok/unicode-letters.ac @@ -0,0 +1,7 @@ +struct { + +中文定理名称 = Fn<来>(啊: 来) -> 来 { + return 啊; +}; + +} main;