2025-01-11 13:32:37 +01:00
|
|
|
type
|
|
|
|
T = array 5 of Int,
|
|
|
|
R = record
|
|
|
|
x: Int;
|
|
|
|
y: Int
|
|
|
|
end;
|
|
|
|
|
|
|
|
proc test_string();
|
|
|
|
var s: String;
|
|
|
|
begin
|
|
|
|
s := "Test string.";
|
|
|
|
|
|
|
|
writei("");
|
|
|
|
writei(s)
|
|
|
|
end;
|
|
|
|
|
|
|
|
proc test_array();
|
2025-01-12 10:35:24 +01:00
|
|
|
var a: T, x: Int;
|
2025-01-11 13:32:37 +01:00
|
|
|
begin
|
|
|
|
a[0] := 2;
|
|
|
|
a[1] := 5;
|
|
|
|
|
|
|
|
writei("");
|
|
|
|
writei("Test array:");
|
|
|
|
|
2025-01-12 10:35:24 +01:00
|
|
|
x := 0;
|
|
|
|
while x < 2 do
|
2025-01-11 13:32:37 +01:00
|
|
|
begin
|
2025-01-12 10:35:24 +01:00
|
|
|
writei(a[x]);
|
|
|
|
x := x + 1
|
2025-01-11 13:32:37 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
proc test_pointer();
|
2025-01-12 10:35:24 +01:00
|
|
|
var x: Int, p: ^Int;
|
2025-01-11 13:32:37 +01:00
|
|
|
begin
|
2025-01-12 10:35:24 +01:00
|
|
|
x := 5;
|
|
|
|
p := @x;
|
2025-01-11 13:32:37 +01:00
|
|
|
|
|
|
|
writei("");
|
|
|
|
writei("Test pointer:");
|
|
|
|
writei(p);
|
|
|
|
writei(p^)
|
|
|
|
end;
|
|
|
|
|
|
|
|
proc test_record();
|
|
|
|
var r: R;
|
|
|
|
begin
|
|
|
|
writei("");
|
|
|
|
writei("Test record:");
|
|
|
|
|
|
|
|
r.x := 4;
|
|
|
|
r.y := 8;
|
|
|
|
|
|
|
|
writei(r.y)
|
|
|
|
end;
|
|
|
|
|
2025-01-11 23:20:23 +01:00
|
|
|
proc test_primitive();
|
|
|
|
var c: Char, z: Float;
|
2025-01-11 13:32:37 +01:00
|
|
|
begin
|
2025-01-11 23:20:23 +01:00
|
|
|
c := 'x';
|
2025-01-11 13:32:37 +01:00
|
|
|
z := 8.2;
|
2025-01-11 23:20:23 +01:00
|
|
|
|
|
|
|
writei("");
|
|
|
|
writei("Test primitives:");
|
|
|
|
writei(c);
|
|
|
|
writei(z)
|
|
|
|
end;
|
|
|
|
|
|
|
|
proc test_const();
|
|
|
|
const t = 5;
|
2025-01-12 10:35:24 +01:00
|
|
|
var x: Int;
|
2025-01-11 23:20:23 +01:00
|
|
|
begin
|
2025-01-12 10:35:24 +01:00
|
|
|
x := t;
|
2025-01-11 23:20:23 +01:00
|
|
|
|
|
|
|
writei("");
|
|
|
|
writei("Test const:");
|
2025-01-12 10:35:24 +01:00
|
|
|
writei(x)
|
2025-01-11 23:20:23 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
proc test_if();
|
|
|
|
var y: Bool;
|
|
|
|
begin
|
2025-01-11 13:32:37 +01:00
|
|
|
y := false;
|
|
|
|
|
2025-01-11 23:20:23 +01:00
|
|
|
writei("");
|
2025-01-11 13:32:37 +01:00
|
|
|
if y then
|
2025-01-11 23:20:23 +01:00
|
|
|
writei("Test if: True")
|
2025-01-11 13:32:37 +01:00
|
|
|
else
|
2025-01-11 23:20:23 +01:00
|
|
|
writei("Test if: False")
|
|
|
|
end;
|
2025-01-11 13:32:37 +01:00
|
|
|
|
2025-01-11 23:20:23 +01:00
|
|
|
begin
|
|
|
|
test_primitive();
|
2025-01-11 13:32:37 +01:00
|
|
|
test_string();
|
|
|
|
test_array();
|
|
|
|
test_pointer();
|
2025-01-11 23:20:23 +01:00
|
|
|
test_record();
|
|
|
|
test_const();
|
|
|
|
test_if()
|
2025-01-11 13:32:37 +01:00
|
|
|
end.
|