stage1 部分功能测试00,01,02,06成功
This commit is contained in:
27
stage1/test12.spl
Normal file
27
stage1/test12.spl
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
fn main() i32 {
|
||||
/* address-of and postfix deref */
|
||||
var x := 42;
|
||||
var p := &x;
|
||||
var v := p.*;
|
||||
if v != 42 { ret 1; }
|
||||
|
||||
/* null pointer */
|
||||
var np: *i32 = null;
|
||||
if np != null { ret 2; }
|
||||
if np == null {} else { ret 3; }
|
||||
|
||||
/* pointer to struct — auto-deref on .field */
|
||||
type Point = struct {
|
||||
a: i32,
|
||||
b: i32,
|
||||
};
|
||||
var pt: Point;
|
||||
pt.a = 10;
|
||||
pt.b = 20;
|
||||
var pp := &pt;
|
||||
if pp.a != 10 { ret 4; }
|
||||
if pp.b != 20 { ret 5; }
|
||||
|
||||
ret 0;
|
||||
}
|
||||
Reference in New Issue
Block a user