mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 14:32:24 +00:00
Make Reals.Mod independent of INTEGER size and add reals tests.
This commit is contained in:
parent
80f5e51789
commit
c0d5b8dbfd
6 changed files with 130 additions and 44 deletions
50
src/test/confidence/library/TestLibrary.mod
Normal file
50
src/test/confidence/library/TestLibrary.mod
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
MODULE TestLibrary;
|
||||
|
||||
IMPORT SYSTEM, Console, Reals;
|
||||
|
||||
PROCEDURE TestConvert(lr: LONGREAL);
|
||||
VAR str: ARRAY 20 OF CHAR; i: INTEGER;
|
||||
BEGIN
|
||||
Reals.ConvertL(lr, 6, str);
|
||||
i := 6; WHILE i > 0 DO DEC(i); Console.Char(str[i]) END;
|
||||
Console.Ln;
|
||||
END TestConvert;
|
||||
|
||||
PROCEDURE TestHex(r: REAL);
|
||||
VAR str: ARRAY 20 OF CHAR;
|
||||
BEGIN
|
||||
Reals.ConvertH(r, str); str[8] := 0X; Console.String(str); Console.Ln;
|
||||
END TestHex;
|
||||
|
||||
PROCEDURE RealTests;
|
||||
VAR
|
||||
str: ARRAY 20 OF CHAR;
|
||||
(*
|
||||
r: REAL;
|
||||
lr: LONGREAL;
|
||||
*)
|
||||
BEGIN
|
||||
TestConvert(1.0);
|
||||
TestConvert(1.5);
|
||||
TestConvert(2.0);
|
||||
TestConvert(2.99);
|
||||
TestConvert(3.0);
|
||||
|
||||
TestHex(1.0);
|
||||
TestHex(1.5);
|
||||
TestHex(2.0);
|
||||
TestHex(2.99);
|
||||
TestHex(3.0);
|
||||
|
||||
Console.Int(Reals.Expo(0.5),1); Console.Ln; (* 126 *)
|
||||
Console.Int(Reals.Expo(1.0),1); Console.Ln; (* 128 *)
|
||||
Console.Int(Reals.Expo(2.0),1); Console.Ln; (* 129 *)
|
||||
Console.Int(Reals.Expo(3.0),1); Console.Ln; (* 129 *)
|
||||
Console.Int(Reals.Expo(4.0),1); Console.Ln; (* 130 *)
|
||||
END RealTests;
|
||||
|
||||
|
||||
BEGIN
|
||||
RealTests;
|
||||
Console.String("Library tests successful."); Console.Ln;
|
||||
END TestLibrary.
|
||||
16
src/test/confidence/library/expected
Normal file
16
src/test/confidence/library/expected
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
000001
|
||||
000001
|
||||
000002
|
||||
000002
|
||||
000003
|
||||
33333333
|
||||
33333333
|
||||
33333333
|
||||
33333333
|
||||
33333333
|
||||
126
|
||||
128
|
||||
129
|
||||
129
|
||||
130
|
||||
Library tests successful.
|
||||
6
src/test/confidence/library/test.sh
Normal file
6
src/test/confidence/library/test.sh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
# Generate mixed source and assembly code listing
|
||||
voc TestLibrary.mod -m
|
||||
./TestLibrary >result
|
||||
. ../testresult.sh
|
||||
Loading…
Add table
Add a link
Reference in a new issue