Просмотр исходного кода

showcase13: print a visible result (was exit-code only, looked like no output); SysIO output (111/111)

Eric Streit 2 недель назад
Родитель
Сommit
28828ae95a
2 измененных файлов с 11 добавлено и 2 удалено
  1. 1 1
      compiler/run_tests.sh
  2. 10 1
      compiler/tests/showcase13.mod

+ 1 - 1
compiler/run_tests.sh

@@ -254,7 +254,7 @@ rm -f gen_ssa/_showcase11.txt
 # step 8.2/8.3: const folding, forward types, trailing ';', empty
 # statements, 1-char strings, qualified type names.
 expect_run_files Showcase12 42 showcase12lib.def showcase12lib.mod showcase12.mod
-expect_run showcase13.mod 42
+expect_run_files_out Showcase13 42 "Even(8)=T Odd(7)=T total=42" ../stdlib/sysio.def ../stdlib/sysio.mod showcase13.mod
 expect_run_files_out MixProg 0 "7" ../stdlib/textio.def ../stdlib/textio.mod ../stdlib/sysio.def ../stdlib/sysio.mod ../stdlib/files.def ../stdlib/files.mod d_mix_prog.mod
 rm -f gen_ssa/_mix.txt
 

+ 10 - 1
compiler/tests/showcase13.mod

@@ -1,7 +1,8 @@
 MODULE Showcase13;
 // Step showcase: FORWARD declarations driving mutual recursion, plus
 // BITSET set operations (union, membership) and the typed set
-// constructor BITSET{...}. Expected ExitCode: 42.
+// constructor BITSET{...}. Prints a result and exits 42.
+IMPORT SysIO;
 
 VAR ExitCode : INTEGER;
 VAR s, t : BITSET;
@@ -21,6 +22,13 @@ BEGIN
   IF k = 0 THEN RETURN FALSE ELSE RETURN Even(k - 1) END
 END Odd;
 
+PROCEDURE Show (label : ARRAY OF CHAR; v : INTEGER);
+BEGIN
+  SysIO.Write(label);
+  SysIO.WriteInt(v);
+  SysIO.WriteLn
+END Show;
+
 BEGIN
   n := 0;
   IF Even(8) THEN n := n + 10 END;    // TRUE  -> 10
@@ -33,5 +41,6 @@ BEGIN
   s := s + t;                         // union {1, 3, 5, 7}
   IF 7 IN s THEN n := n + 11 END;     // member -> 42
 
+  Show("Even(8)=T Odd(7)=T total=", n);
   ExitCode := n
 END Showcase13.