mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 14:32:24 +00:00
Port updated tests and binary snapping, with corrected Reals code, from tidy branch.
This commit is contained in:
parent
b1dc7d77e8
commit
ca2cc52a44
221 changed files with 949 additions and 550 deletions
|
|
@ -55,7 +55,7 @@ C7442404 movl $0, 4(%esp)
|
|||
00000000
|
||||
C7042400 movl $LC0, (%esp)
|
||||
E8000000 call _Heap_REGMOD
|
||||
A3800000 movl %eax, _m.2056
|
||||
A3800000 movl %eax, _m.1612
|
||||
C7050000 movl $544502577, _aa_a30
|
||||
00003173
|
||||
C7050400 movl $1663053873, _aa_a30+4
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
voc aa.mod -m
|
||||
$OBECOMP aa.mod -m
|
||||
./aa >result
|
||||
. ../testresult.sh
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ C7442404 movl $0, 4(%esp)
|
|||
00000000
|
||||
C7042400 movl $LC0, (%esp)
|
||||
E8000000 call _Heap_REGMOD
|
||||
A3000000 movl %eax, _m.2052
|
||||
A3000000 movl %eax, _m.1608
|
||||
C7442404 movl $7, 4(%esp)
|
||||
07000000
|
||||
C7042406 movl $LC1, (%esp)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
voc hello.mod -m
|
||||
$OBECOMP hello.mod -m
|
||||
./hello >result
|
||||
. ../testresult.sh
|
||||
|
|
|
|||
18
src/test/confidence/intsyntax/IntSyntax.mod
Normal file
18
src/test/confidence/intsyntax/IntSyntax.mod
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
MODULE IntSyntax;
|
||||
|
||||
(* Test for error messages generated by incompatible integer types *)
|
||||
|
||||
VAR s: SHORTINT; i: INTEGER; l: LONGINT;
|
||||
|
||||
BEGIN
|
||||
|
||||
l := l; (* Good, same types *)
|
||||
l := i; (* Good, LONGINT longer than INTEGER *)
|
||||
l := s; (* Good, LONGINT longer than SHORTINT *)
|
||||
i := s; (* Good, INTEGER longer then SHORTINT *)
|
||||
|
||||
i := l; (* Bad, INTEGER shorter than LONGINT *)
|
||||
s := l; (* Bad, SHORTINT shorter than LONGINT *)
|
||||
i := l; (* Bad, SHORTINT shorter than INTEGER *)
|
||||
|
||||
END IntSyntax.
|
||||
15
src/test/confidence/intsyntax/expected
Normal file
15
src/test/confidence/intsyntax/expected
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
IntSyntax.mod compiling IntSyntax.
|
||||
|
||||
14: i := l; (* Bad, INTEGER shorter than LONGINT *)
|
||||
[32m^[0m
|
||||
pos 341[31m err [0m113 incompatible assignment
|
||||
|
||||
15: s := l; (* Bad, SHORTINT shorter than LONGINT *)
|
||||
[32m^[0m
|
||||
pos 393[31m err [0m113 incompatible assignment
|
||||
|
||||
16: i := l; (* Bad, SHORTINT shorter than INTEGER *)
|
||||
[32m^[0m
|
||||
pos 446[31m err [0m113 incompatible assignment
|
||||
|
||||
Module compilation failed.
|
||||
5
src/test/confidence/intsyntax/test.sh
Normal file
5
src/test/confidence/intsyntax/test.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
# Generate mixed source and assembly code listing
|
||||
$OBECOMP IntSyntax.mod -m >result
|
||||
. ../testresult.sh
|
||||
|
|
@ -91,11 +91,51 @@ BEGIN
|
|||
(* Also need full tests for CHAR, and poossibly SYSTEM.BYTE. Here's a simple one *)
|
||||
|
||||
c := 1X; c := SYSTEM.LSH(c,2); c := SYSTEM.ROT(c,-2); ASSERT(c=1X, 93);
|
||||
b := 1; b := SYSTEM.LSH(b,2); b := SYSTEM.ROT(b,-2); ASSERT(SYSTEM.VAL(INTEGER,b)=1, 94);
|
||||
b := 1; b := SYSTEM.LSH(b,2); b := SYSTEM.ROT(b,-2); ASSERT(SYSTEM.VAL(CHAR,b)=1X, 94);
|
||||
|
||||
END Shift;
|
||||
|
||||
|
||||
PROCEDURE TestValue(v,e: LONGINT; name: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
IF v # e THEN
|
||||
Console.String(name);
|
||||
Console.String(" = ");
|
||||
Console.Int(v,1);
|
||||
Console.String(", expected ");
|
||||
Console.Int(e,1);
|
||||
Console.Ln;
|
||||
END
|
||||
END TestValue;
|
||||
|
||||
PROCEDURE IntSize;
|
||||
VAR l: LONGINT;
|
||||
BEGIN
|
||||
TestValue(MIN(SHORTINT), -80H, "MIN(SHORTINT)");
|
||||
TestValue(MAX(SHORTINT), 7FH, "MAX(SHORTINT)");
|
||||
IF SIZE(INTEGER) = 2 THEN (* 32 bit machine *)
|
||||
TestValue(MIN(INTEGER), -7FFFH - 1, "MIN(INTEGER)");
|
||||
TestValue(MAX(INTEGER), 7FFFH, "MAX(INTEGER)");
|
||||
TestValue(MIN(LONGINT), -7FFFFFFFH - 1, "MIN(LONGINT)");
|
||||
TestValue(MAX(LONGINT), 7FFFFFFFH, "MAX(LONGINT)");
|
||||
ELSIF SIZE(INTEGER) = 4 THEN (* 64 bit machine *)
|
||||
TestValue(MIN(INTEGER), -7FFFFFFFH - 1, "MIN(INTEGER)");
|
||||
TestValue(MAX(INTEGER), 7FFFFFFFH, "MAX(INTEGER)");
|
||||
(* Since we need to be compilable on 32 bit machines we cannot use
|
||||
a 64 bit constant, so use arithmetic. *)
|
||||
l := 1; l := SYSTEM.LSH(l, 63); l := l-1; (* Generate l = 7FFFFFFFFFFFFFFFH *)
|
||||
TestValue(MIN(LONGINT), -l - 1, "MIN(LONGINT)");
|
||||
TestValue(MAX(LONGINT), l, "MAX(LONGINT)");
|
||||
ELSE
|
||||
Console.String("SIZE(INTEGER) = ");
|
||||
Console.Int(SIZE(INTEGER),1);
|
||||
Console.String(", expected 2 or 4.");
|
||||
Console.Ln;
|
||||
END;
|
||||
END IntSize;
|
||||
|
||||
BEGIN
|
||||
Shift;
|
||||
IntSize;
|
||||
Console.String("Language tests successful."); Console.Ln;
|
||||
END TestLanguage.
|
||||
|
|
|
|||
|
|
@ -484,3 +484,58 @@ D3E2 sall %cl, %edx
|
|||
89D0 movl %edx, %eax
|
||||
09D8 orl %ebx, %eax
|
||||
8845E5 movb %al, -27(%ebp)
|
||||
0FB645E5 movzbl -27(%ebp), %eax
|
||||
3A45F7 cmpb -9(%ebp), %al
|
||||
740C je L52
|
||||
C7042436 movl $54, (%esp)
|
||||
E8000000 call _Platform_AssertFail
|
||||
D07DF7 sarb -9(%ebp)
|
||||
0FB745F4 movzwl -12(%ebp), %eax
|
||||
83E801 subl $1, %eax
|
||||
668945F4 movw %ax, -12(%ebp)
|
||||
66837DF4 cmpw $-7, -12(%ebp)
|
||||
0F8D19FF jge L53
|
||||
66C745F4 movw $0, -12(%ebp)
|
||||
C745EC01 movl $1, -20(%ebp)
|
||||
8B45EC movl -20(%ebp), %eax
|
||||
C1E01F sall $31, %eax
|
||||
8945EC movl %eax, -20(%ebp)
|
||||
8B45EC movl -20(%ebp), %eax
|
||||
8945E0 movl %eax, -32(%ebp)
|
||||
EB50 jmp L54
|
||||
8B45E0 movl -32(%ebp), %eax
|
||||
8945E8 movl %eax, -24(%ebp)
|
||||
66837DF4 cmpw $0, -12(%ebp)
|
||||
780F js L55
|
||||
0FBF45F4 movswl -12(%ebp), %eax
|
||||
8B55E8 movl -24(%ebp), %edx
|
||||
89C1 movl %eax, %ecx
|
||||
D3E2 sall %cl, %edx
|
||||
89D0 movl %edx, %eax
|
||||
EB0F jmp L56
|
||||
0FBF45F4 movswl -12(%ebp), %eax
|
||||
F7D8 negl %eax
|
||||
8B55E8 movl -24(%ebp), %edx
|
||||
89C1 movl %eax, %ecx
|
||||
D3FA sarl %cl, %edx
|
||||
89D0 movl %edx, %eax
|
||||
8945E8 movl %eax, -24(%ebp)
|
||||
8B45E8 movl -24(%ebp), %eax
|
||||
3B45EC cmpl -20(%ebp), %eax
|
||||
740C je L57
|
||||
C704243E movl $62, (%esp)
|
||||
E8000000 call _Platform_AssertFail
|
||||
D17DEC sarl -20(%ebp)
|
||||
0FB745F4 movzwl -12(%ebp), %eax
|
||||
83E801 subl $1, %eax
|
||||
668945F4 movw %ax, -12(%ebp)
|
||||
66837DF4 cmpw $-31, -12(%ebp)
|
||||
7DA9 jge L58
|
||||
66C745F4 movw $0, -12(%ebp)
|
||||
66C745E6 movw $1, -26(%ebp)
|
||||
0FB745E6 movzwl -26(%ebp), %eax
|
||||
0FB7C0 movzwl %ax, %eax
|
||||
C1E00F sall $15, %eax
|
||||
668945E6 movw %ax, -26(%ebp)
|
||||
0FB745E6 movzwl -26(%ebp), %eax
|
||||
668945F2 movw %ax, -14(%ebp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
# Generate mixed source and assembly code listing
|
||||
voc TestLanguage.mod -m
|
||||
$OBECOMP TestLanguage.mod -m
|
||||
./TestLanguage >result
|
||||
. ../testresult.sh
|
||||
|
|
|
|||
99
src/test/confidence/library/TestLibrary.mod
Normal file
99
src/test/confidence/library/TestLibrary.mod
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
MODULE TestLibrary;
|
||||
|
||||
IMPORT SYSTEM, Oberon, Texts, Reals, oocLowReal;
|
||||
|
||||
VAR W: Texts.Writer;
|
||||
|
||||
PROCEDURE tc(c: CHAR); BEGIN Texts.Write(W, c) END tc;
|
||||
PROCEDURE ts(s: ARRAY OF CHAR); BEGIN Texts.WriteString(W, s) END ts;
|
||||
PROCEDURE ti(i, n: LONGINT); BEGIN Texts.WriteInt(W, i, n) END ti;
|
||||
PROCEDURE tr(r: LONGREAL; n: INTEGER); BEGIN Texts.WriteLongReal(W, r, n) END tr;
|
||||
PROCEDURE tn; BEGIN Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf) END tn;
|
||||
|
||||
|
||||
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); tc(str[i]) END;
|
||||
tn;
|
||||
END TestConvert;
|
||||
|
||||
PROCEDURE TestHex(r: REAL);
|
||||
VAR str: ARRAY 20 OF CHAR;
|
||||
BEGIN
|
||||
Reals.ConvertH(r, str); str[8] := 0X; ts(str); tn;
|
||||
END TestHex;
|
||||
|
||||
PROCEDURE TestSetExpo(r: REAL; i: INTEGER);
|
||||
BEGIN
|
||||
ts("r = "); tr(r,10);
|
||||
ts(", i = "); ti(Reals.Expo(r),1);
|
||||
Reals.SetExpo(r, i);
|
||||
ts(" -> r = "); tr(r,10);
|
||||
ts(", i = "); ti(Reals.Expo(r),1); tn;
|
||||
END TestSetExpo;
|
||||
|
||||
PROCEDURE TestFractionPart(r: REAL);
|
||||
BEGIN
|
||||
ts("r = "); tr(r,14);
|
||||
ts(", exp = "); ti(Reals.Expo(r),1);
|
||||
r := oocLowReal.fraction(r);
|
||||
ts(" -> r = "); tr(r,14);
|
||||
ts(", exp = "); ti(Reals.Expo(r),1); tn;
|
||||
END TestFractionPart;
|
||||
|
||||
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);
|
||||
|
||||
ti(Reals.Expo(0.5),1); tn; (* 126 *)
|
||||
ti(Reals.Expo(1.0),1); tn; (* 127 *)
|
||||
ti(Reals.Expo(2.0),1); tn; (* 128 *)
|
||||
ti(Reals.Expo(3.0),1); tn; (* 128 *)
|
||||
ti(Reals.Expo(4.0),1); tn; (* 129 *)
|
||||
|
||||
TestSetExpo(1.0, 129);
|
||||
TestSetExpo(-1.0, 129);
|
||||
TestSetExpo(2.0, 129);
|
||||
TestSetExpo(-4.0, 129);
|
||||
TestSetExpo(1.5, 129);
|
||||
TestSetExpo(-1.5, 129);
|
||||
|
||||
TestFractionPart(1.234);
|
||||
TestFractionPart(-1.234);
|
||||
TestFractionPart(32.678);
|
||||
TestFractionPart(-32.678);
|
||||
|
||||
r := 0.0;
|
||||
ASSERT(~oocLowReal.IsInfinity(r), 3); ASSERT(~oocLowReal.IsNaN(r), 4);
|
||||
|
||||
r := 0.0; Reals.SetExpo(r, 255);
|
||||
ASSERT(oocLowReal.IsInfinity(r), 5); ASSERT(~oocLowReal.IsNaN(r), 6);
|
||||
|
||||
r := 0.123; Reals.SetExpo(r, 255);
|
||||
ASSERT(~oocLowReal.IsInfinity(r), 7); ASSERT(oocLowReal.IsNaN(r), 8);
|
||||
END RealTests;
|
||||
|
||||
|
||||
BEGIN
|
||||
Texts.OpenWriter(W);
|
||||
RealTests;
|
||||
ts("Library tests successful."); tn
|
||||
END TestLibrary.
|
||||
26
src/test/confidence/library/expected
Normal file
26
src/test/confidence/library/expected
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
000001
|
||||
000001
|
||||
000002
|
||||
000002
|
||||
000003
|
||||
0000803F
|
||||
0000C03F
|
||||
00000040
|
||||
295C3F40
|
||||
00004040
|
||||
126
|
||||
127
|
||||
128
|
||||
128
|
||||
129
|
||||
r = 1.0D+000, i = 127 -> r = 4.0D+000, i = 129
|
||||
r = -1.0D+000, i = 127 -> r = -4.0D+000, i = 129
|
||||
r = 2.0D+000, i = 128 -> r = 4.0D+000, i = 129
|
||||
r = -4.0D+000, i = 129 -> r = -4.0D+000, i = 129
|
||||
r = 1.5D+000, i = 127 -> r = 6.0D+000, i = 129
|
||||
r = -1.5D+000, i = 127 -> r = -6.0D+000, i = 129
|
||||
r = 1.23400D+000, exp = 127 -> r = 1.23400D+000, exp = 127
|
||||
r = -1.23400D+000, exp = 127 -> r = -1.23400D+000, exp = 127
|
||||
r = 3.26780D+001, exp = 132 -> r = 1.02119D+000, exp = 127
|
||||
r = -3.26780D+001, exp = 132 -> r = -1.02119D+000, exp = 127
|
||||
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
|
||||
$OBECOMP TestLibrary.mod -m
|
||||
./TestLibrary >result
|
||||
. ../testresult.sh
|
||||
|
|
@ -71,7 +71,7 @@ C7442404 movl $0, 4(%esp)
|
|||
00000000
|
||||
C7042400 movl $LC0, (%esp)
|
||||
E8000000 call _Heap_REGMOD
|
||||
A3000000 movl %eax, _m.2287
|
||||
A3000000 movl %eax, _m.1843
|
||||
0FB70500 movzwl _Platform_ArgCount, %eax
|
||||
6683F802 cmpw $2, %ax
|
||||
7F5C jg L6
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
voc LSS.Mod LSB.Mod LSC.Mod LSV.Mod lola.Mod -m
|
||||
$OBECOMP LSS.Mod LSB.Mod LSC.Mod LSV.Mod lola.Mod -m
|
||||
./Lola RISC5.Lola result
|
||||
. ../testresult.sh
|
||||
|
|
|
|||
0
src/test/confidence/planned-binary-change
Normal file
0
src/test/confidence/planned-binary-change
Normal file
|
|
@ -368,7 +368,7 @@ C7442404 movl $_EnumPtrs, 4(%esp)
|
|||
02040000
|
||||
C7042411 movl $LC2, (%esp)
|
||||
E8000000 call _Heap_REGMOD
|
||||
A3180000 movl %eax, _m.2428
|
||||
A3180000 movl %eax, _m.1984
|
||||
C7442404 movl $7, 4(%esp)
|
||||
07000000
|
||||
C704241C movl $LC3, (%esp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
voc signal.mod -m
|
||||
$OBECOMP signal.mod -m
|
||||
./SignalTest x &
|
||||
sleep 1
|
||||
kill -2 $!
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ fi
|
|||
|
||||
# Compare generated code
|
||||
if [ -f new.asm ]
|
||||
then egrep '^[0-9 ]{4} ([0-9a-f]{4}| ) [0-9A-F]{2}[0-9A-F ]{6}' new.asm|cut -c 11- >new.$FLAVOUR.s
|
||||
then egrep '^[0-9 ]{4} ([0-9a-f]{4}| ) [0-9A-F]{2}[0-9A-F ]{6}' new.asm|cut -c 11- >new.$FLAVOUR.$BRANCH.s
|
||||
|
||||
if [ -f old.$FLAVOUR.s -a old.$FLAVOUR -nt ../../../../bootstrap/unix-44/Configuration.c ]
|
||||
if [ -f old.$FLAVOUR.$BRANCH.s -a old.$FLAVOUR.$BRANCH -nt ../planned-binary-change ]
|
||||
then
|
||||
if diff -b old.$FLAVOUR.s new.$FLAVOUR.s
|
||||
if diff -b old.$FLAVOUR.$BRANCH.s new.$FLAVOUR.$BRANCH.s
|
||||
then echo "--- Generated code unchanged ---"
|
||||
else echo "--- Generated code changed ---"
|
||||
fi
|
||||
else
|
||||
cp new.$FLAVOUR.s old.$FLAVOUR.s
|
||||
cp new.$FLAVOUR.$BRANCH.s old.$FLAVOUR.$BRANCH.s
|
||||
echo "--- Generated code snapped ---"
|
||||
fi
|
||||
|
||||
|
|
|
|||
4
src/test/confidence/texts/expected
Normal file
4
src/test/confidence/texts/expected
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
aaa
|
||||
-3.1E+02
|
||||
-311.141504
|
||||
-3.1D+002
|
||||
5
src/test/confidence/texts/test.sh
Normal file
5
src/test/confidence/texts/test.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
. ../testenv.sh
|
||||
$OBECOMP testTexts.mod -m
|
||||
./testTexts >result
|
||||
. ../testresult.sh
|
||||
41
src/test/confidence/texts/testTexts.mod
Normal file
41
src/test/confidence/texts/testTexts.mod
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
(* compile with voc -M testTexts.Mod *)
|
||||
MODULE testTexts;
|
||||
|
||||
IMPORT Texts, Console;
|
||||
|
||||
CONST pi = -311.1415;
|
||||
|
||||
VAR
|
||||
W: Texts.Writer;
|
||||
T: Texts.Text;
|
||||
R: Texts.Reader;
|
||||
ch: CHAR;
|
||||
i: INTEGER;
|
||||
s: ARRAY 1024 OF CHAR;
|
||||
|
||||
BEGIN
|
||||
Texts.OpenWriter(W);
|
||||
|
||||
Texts.WriteString(W, "aaa"); Texts.WriteLn(W);
|
||||
Texts.WriteReal(W, pi, 7); Texts.WriteLn(W);
|
||||
Texts.WriteRealFix(W, pi, 0, 7); Texts.WriteLn(W);
|
||||
Texts.WriteLongReal(W, pi, 7); Texts.WriteLn(W);
|
||||
|
||||
NEW(T); Texts.Open(T, "test.txt");
|
||||
|
||||
Texts.Append(T, W.buf);
|
||||
(*Texts.Store(W, T);*)
|
||||
|
||||
Texts.OpenReader(R, T, 0);
|
||||
Texts.Read(R, ch);
|
||||
i := 0;
|
||||
WHILE ~R.eot DO
|
||||
IF ch = 0DX THEN
|
||||
s[i] := 0X; i := 0; Console.String(s); Console.Ln
|
||||
ELSE
|
||||
s[i] := ch; INC(i)
|
||||
END;
|
||||
Texts.Read(R, ch)
|
||||
END;
|
||||
s[i] := 0X; (*Console.String(s)*)
|
||||
END testTexts.
|
||||
Loading…
Add table
Add a link
Reference in a new issue