mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 20:22:24 +00:00
Add textTexts as a confidence test and tidy up a couple of other tests.
This commit is contained in:
parent
37ba47a202
commit
73ce62db28
6 changed files with 80 additions and 47 deletions
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.
|
||||||
|
|
@ -2,54 +2,43 @@ MODULE clb;
|
||||||
|
|
||||||
IMPORT Console;
|
IMPORT Console;
|
||||||
|
|
||||||
TYPE OnSomething = PROCEDURE (x, y : INTEGER);
|
TYPE OnSomething = PROCEDURE (x, y: INTEGER);
|
||||||
|
|
||||||
PROCEDURE ProcessEvents(x, y : INTEGER; onsomething : OnSomething);
|
|
||||||
|
|
||||||
|
PROCEDURE ProcessEvents(x, y: INTEGER; onsomething: OnSomething);
|
||||||
BEGIN
|
BEGIN
|
||||||
|
IF onsomething # NIL THEN
|
||||||
IF onsomething # NIL THEN onsomething(x, y)
|
onsomething(x, y)
|
||||||
ELSE
|
ELSE
|
||||||
Console.String("didn't happen"); Console.Ln
|
Console.String("didn't happen"); Console.Ln
|
||||||
END;
|
END
|
||||||
|
|
||||||
END ProcessEvents;
|
END ProcessEvents;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE OnEvent(x, y : INTEGER);
|
PROCEDURE OnEvent(x, y : INTEGER);
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
Console.String("event happened"); Console.Ln
|
||||||
Console.String("event happened"); Console.Ln
|
|
||||||
|
|
||||||
END OnEvent;
|
END OnEvent;
|
||||||
|
|
||||||
PROCEDURE OnEvent2(x, y : INTEGER);
|
PROCEDURE OnEvent2(x, y : INTEGER);
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
Console.String("event 2 happened"); Console.Ln
|
||||||
Console.String("happened"); Console.Ln
|
|
||||||
|
|
||||||
END OnEvent2;
|
END OnEvent2;
|
||||||
|
|
||||||
PROCEDURE Something;
|
PROCEDURE Something;
|
||||||
VAR onsmth : OnSomething;
|
VAR onsmth: OnSomething;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
onsmth := NIL;
|
onsmth := NIL;
|
||||||
ProcessEvents(0, 0, onsmth);
|
ProcessEvents(0, 0, onsmth);
|
||||||
|
|
||||||
onsmth := OnEvent;
|
onsmth := OnEvent;
|
||||||
ProcessEvents(0, 0, onsmth);
|
ProcessEvents(0, 0, onsmth);
|
||||||
|
|
||||||
END Something;
|
END Something;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
Something;
|
Something;
|
||||||
(*
|
(*
|
||||||
ProcessEvents(0, 0, NIL);
|
ProcessEvents(0, 0, NIL);
|
||||||
ProcessEvents(0, 0, OnEvent);
|
ProcessEvents(0, 0, OnEvent);
|
||||||
ProcessEvents(0, 0, OnEvent2);
|
ProcessEvents(0, 0, OnEvent2);
|
||||||
*)
|
*)
|
||||||
END clb.
|
END clb.
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,18 @@ VAR
|
||||||
F : Files.File;
|
F : Files.File;
|
||||||
ch : CHAR;
|
ch : CHAR;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
F := Files.Old (file);
|
||||||
|
IF F # NIL THEN
|
||||||
|
NEW(T);
|
||||||
|
Texts.Open(T, file);
|
||||||
|
Texts.OpenReader(R, T, 0);
|
||||||
|
Texts.Read (R, ch);
|
||||||
|
|
||||||
F := Files.Old (file);
|
WHILE ~R.eot DO
|
||||||
IF F # NIL THEN
|
IF ch = 0DX THEN Console.Ln ELSE Console.Char(ch) END;
|
||||||
NEW(T);
|
|
||||||
Texts.Open(T, file);
|
|
||||||
Texts.OpenReader(R, T, 0);
|
|
||||||
Texts.Read (R, ch);
|
|
||||||
|
|
||||||
WHILE ~R.eot DO
|
|
||||||
Console.Char(ch);
|
|
||||||
IF ch = 0DX THEN Console.Char(0AX) END;
|
|
||||||
Texts.Read (R, ch);
|
Texts.Read (R, ch);
|
||||||
END;
|
END;
|
||||||
|
ELSE
|
||||||
ELSE
|
Console.String ("cannot open"); Console.Ln;
|
||||||
|
END;
|
||||||
Console.String ("cannot open"); Console.Ln;
|
|
||||||
|
|
||||||
END;
|
|
||||||
|
|
||||||
|
|
||||||
END testFiles.
|
END testFiles.
|
||||||
|
|
|
||||||
|
|
@ -385,6 +385,7 @@ confidence:
|
||||||
cd src/test/confidence/hello; $(RUNTEST)
|
cd src/test/confidence/hello; $(RUNTEST)
|
||||||
cd src/test/confidence/intsyntax; $(RUNTEST)
|
cd src/test/confidence/intsyntax; $(RUNTEST)
|
||||||
cd src/test/confidence/language; $(RUNTEST)
|
cd src/test/confidence/language; $(RUNTEST)
|
||||||
|
cd src/test/confidence/texts; $(RUNTEST)
|
||||||
cd src/test/confidence/library; $(RUNTEST)
|
cd src/test/confidence/library; $(RUNTEST)
|
||||||
cd src/test/confidence/lola; $(RUNTEST)
|
cd src/test/confidence/lola; $(RUNTEST)
|
||||||
cd src/test/confidence/arrayassignment; $(RUNTEST)
|
cd src/test/confidence/arrayassignment; $(RUNTEST)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue