Add more test cases

Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
方而静 2023-08-27 14:09:29 +08:00
parent 14bc07ec9c
commit 7857473434
Signed by: szTom
GPG Key ID: 072D999D60C6473C
10 changed files with 79 additions and 1 deletions

View File

@ -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}')

View File

@ -0,0 +1,8 @@
struct {
T1 = Fn<A, B>(h: A, y: B) -> A {
z = y;
z = h;
return z;
};
} main;

View File

@ -0,0 +1,8 @@
struct {
T1 = Fn<A, B>(h: A) -> B {
return T1<A, B>(h);
};
} main;

View File

@ -0,0 +1,7 @@
struct {
T1 = Fn<A, B>(h1: Fn(<>, <A>, B), h2: A) -> B {
return h1(h2);
};
} main;

View File

@ -0,0 +1,7 @@
struct {
T1 = Fn<B>(h1: Fn(<C>, <C>, B)) -> B {
return h1<typeof(h1)>(h1);
};
} main;

View File

@ -0,0 +1,9 @@
struct {
T = Fn<a, b, c>(z: Fn(<>, <a>, b), y: Fn(<>, <b>, c)) -> Fn(<>, <a>, c) {
return Fn<>(h: a) -> c {
return y(z(h));
};
};
} main;

8
tests/ok/local-vars.ac Normal file
View File

@ -0,0 +1,8 @@
struct {
T1 = Fn<A>(h1: A) -> A {
h2 = h1;
return h2;
};
} main;

View File

@ -0,0 +1,15 @@
struct {
T1 = Fn<A>(a: A) -> A {
return a;
};
T2 = Fn<b>(a: b) -> b {
return a;
};
T3 = Fn<c>(a: c) -> c {
return T2<c>(T2<c>(T1<c>(a)));
};
} main;

9
tests/ok/nested-types.ac Normal file
View File

@ -0,0 +1,9 @@
struct {
T1 = Fn<B>(h1: Fn(<C>, <Fn(<>, <C>, C)>, B)) -> B {
return h1<B>(Fn<>(h: B) -> B{
return h;
});
};
} main;

View File

@ -0,0 +1,7 @@
struct {
中文定理名称 = Fn<来>(啊: 来) -> 来 {
return 啊;
};
} main;