summaryrefslogtreecommitdiff
path: root/t/array.pas
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-06-05 01:25:59 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-06-05 01:25:59 +0800
commit176c8e70f56bbbbe5ab2063f22000b9af0180e85 (patch)
tree0f291a33e69bd9c840131e170e63c0d245268d7b /t/array.pas
parentbaa601da82cce51d2b4bd39a32fdc5b8de5c6452 (diff)
add case statement support
Diffstat (limited to 't/array.pas')
-rw-r--r--t/array.pas45
1 files changed, 45 insertions, 0 deletions
diff --git a/t/array.pas b/t/array.pas
new file mode 100644
index 0000000..6bf913e
--- /dev/null
+++ b/t/array.pas
@@ -0,0 +1,45 @@
+program arr;
+
+type
+ a1=integer;
+ a2=array[0..5] of a1;
+ a3=array[0..6] of a2;
+ a4=array[0..7] of a3;
+ a5=array[0..8] of a4;
+
+extern memset(dst:^void; n:integer; c:integer):^void;
+extern puts(s:string):integer;
+
+function assert_equal(a:integer; b:integer):void;
+begin
+ if a<>b then puts('error!')
+end;
+
+function main():integer;
+var
+ a:array[0..9] of a5;
+ pa1:^a5;
+ pa2:^a4;
+ pa3:^a3;
+ pa4:^a2;
+ pa5:^a1;
+begin
+ memset(@a, 0, 4*6*7*8*9*10);
+ a[1][2][3][4][5] := 0x1234567;
+ pa1 := @a[1];
+ pa2 := @a[1][2];
+ pa3 := @a[1][2][3];
+ pa4 := @a[1][2][3][4];
+ pa5 := @a[1][2][3][4][5];
+ assert_equal(pa1^[2][3][4][5], 0x1234567);
+ assert_equal(pa2^[3][4][5], 0x1234567);
+ assert_equal(pa3^[4][5], 0x1234567);
+ assert_equal(pa4^[5], 0x1234567);
+ assert_equal(pa5^, 0x1234567);
+
+ assert_equal((@a[1][2][3])^[4][5], 0x1234567);
+ assert_equal((@a[1][2][2]+1)^[4][5], 0x1234567);
+
+ puts('good');
+ main := 0
+end;