Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit 0eb8c0b

Browse files
committed
新增测试文件,验证现有变量声明语法,包括显式类型声明、自动类型推断及复杂表达式的类型推断,增强了类型系统的测试覆盖。
1 parent 3b404c7 commit 0eb8c0b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test_existing_syntax.cn

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// 测试现有的变量声明语法
2+
3+
using ns std;
4+
5+
fn test_variable_declarations() : void {
6+
// 测试显式类型声明
7+
x: int = 42;
8+
y: float = 3.14;
9+
z: string = "Hello";
10+
11+
std::println("显式类型声明:");
12+
std::println("x (int) = " + x);
13+
std::println("y (float) = " + y);
14+
std::println("z (string) = " + z);
15+
16+
// 测试自动类型推断
17+
a: auto = 100;
18+
b: auto = 2.71;
19+
c: auto = "World";
20+
21+
std::println("自动类型推断:");
22+
std::println("a (auto) = " + a);
23+
std::println("b (auto) = " + b);
24+
std::println("c (auto) = " + c);
25+
26+
// 测试复杂表达式的类型推断
27+
d: auto = x + a;
28+
e: auto = y * 2.0;
29+
f: auto = z + " " + c;
30+
31+
std::println("复杂表达式类型推断:");
32+
std::println("d = " + d);
33+
std::println("e = " + e);
34+
std::println("f = " + f);
35+
};
36+
37+
fn main() : void {
38+
test_variable_declarations();
39+
};

0 commit comments

Comments
 (0)