| 1 |
(* Copyright (C) 2005, 2006 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 |
MODULE TestLong; |
| 18 |
|
| 19 |
FROM StrIO IMPORT WriteString, WriteLn; |
| 20 |
FROM FpuIO IMPORT StrToLongInt, WriteLongInt, LongIntToStr; |
| 21 |
FROM StrLib IMPORT StrEqual ; |
| 22 |
FROM M2RTS IMPORT ExitOnHalt ; |
| 23 |
|
| 24 |
TYPE |
| 25 |
String = ARRAY [0..255] OF CHAR; |
| 26 |
|
| 27 |
VAR |
| 28 |
CorrectResult, |
| 29 |
LongIntegerVariable : LONGINT; |
| 30 |
SameResult, |
| 31 |
St : String; |
| 32 |
|
| 33 |
BEGIN |
| 34 |
LongIntegerVariable := 12345678901234; |
| 35 |
WriteLongInt(LongIntegerVariable, 0); |
| 36 |
WriteLn; |
| 37 |
St := '12345678901234'; |
| 38 |
WriteString(St); |
| 39 |
WriteLn; |
| 40 |
LongIntToStr(LongIntegerVariable, 0, SameResult) ; |
| 41 |
StrToLongInt(St, CorrectResult) ; |
| 42 |
WriteLongInt(CorrectResult, 0); |
| 43 |
WriteLn ; |
| 44 |
IF NOT StrEqual(St, SameResult) |
| 45 |
THEN |
| 46 |
WriteString('test failed: correct value is: ') ; WriteString(St) ; |
| 47 |
WriteString(' assignment produced ') ; WriteString(SameResult) ; |
| 48 |
WriteLn ; |
| 49 |
ExitOnHalt(1) ; |
| 50 |
HALT |
| 51 |
END |
| 52 |
END TestLong. |