stage1 部分功能测试00,01,02,06成功
This commit is contained in:
34
stage1/test13.spl
Normal file
34
stage1/test13.spl
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
type Pair = struct {
|
||||
a: i32,
|
||||
b: i32,
|
||||
};
|
||||
|
||||
fn main() i32 {
|
||||
/* struct field access */
|
||||
var p: Pair;
|
||||
p.a = 1;
|
||||
p.b = 2;
|
||||
if p.a != 1 { ret 1; }
|
||||
if p.b != 2 { ret 2; }
|
||||
|
||||
/* inline type definition */
|
||||
type Triple = struct {
|
||||
x: i32,
|
||||
y: i32,
|
||||
z: i32,
|
||||
};
|
||||
var t: Triple;
|
||||
t.x = 10;
|
||||
t.y = 20;
|
||||
t.z = 30;
|
||||
if t.x + t.y + t.z != 60 { ret 3; }
|
||||
|
||||
/* type reuse */
|
||||
var p2: Pair;
|
||||
p2.a = 5;
|
||||
p2.b = 6;
|
||||
if p2.a + p2.b != 11 { ret 4; }
|
||||
|
||||
ret 0;
|
||||
}
|
||||
Reference in New Issue
Block a user