Debian Codegraph @

gcc/testsuite/gm2/pim/options/optimize/run/pass/concat.mod

raw
1 (* Copyright (C) 2005 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 MODULE concat ;
19
20 FROM StrLib IMPORT StrConCat, StrLen, StrEqual ;
21 FROM NumberIO IMPORT CardToStr ;
22 FROM libc IMPORT exit, printf ;
23 FROM SYSTEM IMPORT ADR ;
24
25
26 VAR
27 res: INTEGER ;
28
29 PROCEDURE Assert (v: BOOLEAN; f: ARRAY OF CHAR; l: CARDINAL; e: ARRAY OF CHAR) ;
30 VAR
31 r: INTEGER ;
32 BEGIN
33 IF v
34 THEN
35 r := printf("successfully evaluated assertion (%s)\n", ADR(e))
36 ELSE
37 r := printf("%s:%d assertion failed when evaluating %s\n", ADR(f), l, ADR(e)) ;
38 res := 1
39 END
40 END Assert ;
41
42
43 PROCEDURE foo ;
44 VAR
45 line: ARRAY [0..79] OF CHAR ;
46 BEGIN
47 CardToStr(10000, 6, line) ;
48 Assert(StrEqual(line, ' 10000'), __FILE__, __LINE__, 'StrEqual of CardToStr') ;
49 StrConCat(' ', line, line) ;
50 Assert(StrLen(line)=7, __FILE__, __LINE__, 'StrLen of StrConCat') ;
51 Assert(StrEqual(line, ' 10000'), __FILE__, __LINE__, 'StrEqual')
52 END foo ;
53
54
55 BEGIN
56 foo
57 END concat.