raz / test / run / WhileBottom.raz

37 lines · 810 B · raw · history · last change cee2693c

1(* while, tested after its body: rounds none, one and many; a condition
2 with and, or and a call; break; while true; and a check that fails in
3 the condition, told at its place in the source. *)
4module WhileBottom;
5import Out;
6
7var calls: INT;
8
9proc small(n: INT): BOOL;
10begin
11 INC(calls);
12 return n < 3;
13end;
14
15proc main*;
16var i, n: INT; a: [4]INT;
17begin
18 i := 5;
19 while i < 3 do INC(i); end;
20 Out.int(i); Out.ln;
21 i := 0;
22 while i < 1 do INC(i); end;
23 Out.int(i); Out.ln;
24 i := 0;
25 while (i < 10) and small(i) or (i = 7) do INC(i); end;
26 Out.int(i); Out.char(' '); Out.int(calls); Out.ln;
27 n := 0;
28 while true do
29 INC(n);
30 if n = 4 then break; end;
31 end;
32 Out.int(n); Out.ln;
33 i := 0;
34 while a[i] = 0 do INC(i); end;
35end;
36
37end WhileBottom.