Debian Codegraph @

gcc/testsuite/gm2/pim/run/pass/hightests.mod

raw
1 MODULE hightests ;
2
3
4 FROM libc IMPORT printf, exit ;
5 FROM StrLib IMPORT StrCopy ;
6
7 PROCEDURE testhigh (a: ARRAY OF CHAR; expected: CARDINAL; first: CHAR; checkNul: BOOLEAN) ;
8 VAR
9 copy: ARRAY [0..10] OF CHAR ;
10 BEGIN
11 StrCopy (a, copy) ;
12 IF HIGH (a) # expected
13 THEN
14 printf ("unexpected high value, HIGH(%s) should be %d but was passed %d\n",
15 copy, expected, HIGH (a)) ;
16 code := 1
17 END ;
18 IF a[0] # first
19 THEN
20 printf ("unexpected first value in open array, %s, a[0] should be %c but was passed %c\n",
21 a, first, a[0]) ;
22 code := 2
23 END ;
24 IF checkNul AND (a[HIGH(a)] # 0C)
25 THEN
26 printf ("expected the array to contain a 0C terminator\n") ;
27 code := 3
28 END
29 END testhigh ;
30
31
32 VAR
33 str0: ARRAY [0..0] OF CHAR ;
34 str1: ARRAY [0..1] OF CHAR ;
35 str2: ARRAY [0..2] OF CHAR ;
36 str3: ARRAY [0..3] OF CHAR ;
37 ch : CHAR ;
38 code: INTEGER ;
39 BEGIN
40 testhigh ('1', 1, '1', TRUE) ;
41 str0 := '_' ;
42 str1 := '_1' ;
43 str2 := '_2' ;
44 str3 := '_3' ;
45 code := 0 ;
46 testhigh ('', 0, 0C, TRUE) ;
47 testhigh ('1', 1, '1', TRUE) ;
48 testhigh ('12', 2, '1', TRUE) ;
49 testhigh ('123', 3, '1', TRUE) ;
50 testhigh ('1234', 4, '1', TRUE) ;
51 testhigh (str0, 0, '_', FALSE) ;
52 testhigh (str1, 1, '_', FALSE) ;
53 testhigh (str2, 2, '_', TRUE) ;
54 testhigh (str3, 3, '_', TRUE) ;
55 IF code = 0
56 THEN
57 printf ("all tests pass\n")
58 ELSE
59 exit (1)
60 END
61 END hightests.