MODULE Test; IMPORT Wr, Stdio, Fmt, Text, Cstdlib; PROCEDURE msg (t: Text.T) = BEGIN Wr.PutText (Stdio.stderr, t & "\n"); END msg; PROCEDURE msgB (b: BOOLEAN) = BEGIN Wr.PutText (Stdio.stderr, Fmt.Bool (b) & "\n"); END msgB; PROCEDURE msgI (i: INTEGER) = BEGIN Wr.PutText (Stdio.stderr, Fmt.Int (i) & "\n"); END msgI; PROCEDURE msgC (c: CHAR) = BEGIN Wr.PutText (Stdio.stderr, Fmt.Char (c) & "\n"); END msgC; PROCEDURE msgR (c: REAL) = BEGIN Wr.PutText (Stdio.stderr, Fmt.Real (c) & "\n"); END msgR; PROCEDURE warn (b: BOOLEAN) = BEGIN IF NOT b THEN Wr.PutText (Stdio.stderr, "------------------------ WARNING\n" ); INC (warnings); END; END warn; PROCEDURE check (b: BOOLEAN) = BEGIN IF NOT b THEN Wr.PutText (Stdio.stderr, "************************ ERROR\n" ); INC (errors); END; END check; PROCEDURE checkB (b: BOOLEAN; shouldBe: BOOLEAN) = BEGIN IF NOT b = shouldBe THEN Wr.PutText (Stdio.stderr, "************************ ERROR: " & Fmt.Bool (b) & " instead of " & Fmt.Bool (shouldBe) & "\n"); INC (errors); END; END checkB; PROCEDURE checkI (i: INTEGER; shouldBe: INTEGER) = BEGIN IF NOT i = shouldBe THEN Wr.PutText (Stdio.stderr, "************************ ERROR: " & Fmt.Int (i) & " instead of " & Fmt.Int (shouldBe) & "\n"); INC (errors); END; END checkI; PROCEDURE checkC (c, shouldBe: CHAR) = BEGIN IF NOT c = shouldBe THEN Wr.PutText (Stdio.stderr, "************************ ERROR: " & Fmt.Char (c) & " instead of " & Fmt.Char (shouldBe)); INC (errors); END; END checkC; PROCEDURE checkR (c, shouldBe: REAL) = BEGIN IF NOT c = shouldBe THEN Wr.PutText (Stdio.stderr, "************************ ERROR: " & Fmt.Real (c) & " instead of " & Fmt.Real (shouldBe)); INC (errors); END; END checkR; PROCEDURE done () = BEGIN Wr.PutText (Stdio.stderr, "\n\n" & Fmt.Int (errors) & " error(s) and " & Fmt.Int (warnings) & " warning(s) detected\n"); Stdio.Close (); IF errors # 0 THEN Cstdlib.exit (1); END; END done; BEGIN END Test.