[svn] r7053: nemerle/trunk/tools/nemerlish: Makefile tests/nemish1.test tests/test-nemish.pl

malekith svnadmin at nemerle.org
Tue Dec 5 10:31:46 CET 2006


Log:
Add a script for testing nemish itself.

Author: malekith
Date: Tue Dec  5 10:31:44 2006
New Revision: 7053

Added:
   nemerle/trunk/tools/nemerlish/tests/nemish1.test
   nemerle/trunk/tools/nemerlish/tests/test-nemish.pl   (contents, props changed)
Modified:
   nemerle/trunk/tools/nemerlish/Makefile

Modified: nemerle/trunk/tools/nemerlish/Makefile
==============================================================================
--- nemerle/trunk/tools/nemerlish/Makefile	(original)
+++ nemerle/trunk/tools/nemerlish/Makefile	Tue Dec  5 10:31:44 2006
@@ -46,6 +46,9 @@
 	fi
 
 
+test-nemish: symlinks
+	perl tests/test-nemish.pl "$(EXECUTE)" tests/*.test
+
 uninstall:
 	$(RM) Nemerle.Evaluation
 	$(GACUTIL_UNINSTALL_COMMAND) Nemerle.Evaluation

Added: nemerle/trunk/tools/nemerlish/tests/nemish1.test
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/nemerlish/tests/nemish1.test	Tue Dec  5 10:31:44 2006
@@ -0,0 +1,23 @@
+def x = 42;
+def y = x + 7 - 3 - 4;;
+System.Console.WriteLine ($"Ala ma $x + $y kotow.");;
+73;;
+using System.Console;;
+mutable i = 3;
+while (i>0) { WriteLine (i); i--; }
+;;
+
+/*
+BEGIN-OUTPUT
+def x = 42 : System.Int32
+def y = 42 : System.Int32
+Ala ma 42 + 42 kotow.
+def it = 73 : System.Int32
+3
+2
+1
+mutable i = 0 : System.Int32
+def x = 42 : System.Int32
+def y = 42 : System.Int32
+END-OUTPUT
+*/

Added: nemerle/trunk/tools/nemerlish/tests/test-nemish.pl
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/nemerlish/tests/test-nemish.pl	Tue Dec  5 10:31:44 2006
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+$err = 0;
+$engine = shift;
+
+sub one_test($) {
+  $filename = shift;
+  open(T, "< $filename");
+  while (<T>) {
+    /BEGIN-OUTPUT/ and last;
+  }
+  
+  print STDERR "$filename ... ";
+  
+  open(M, "$engine nemish.exe < $filename |");
+  $lerr = 0;
+  while (<M>) {
+    s/^- ([=-]\s*)*//;
+    /^\S*$/ and next;
+    /^(Please|Welcome|Type) / and next;
+    $act = $_;
+    $exp = <T>;
+    chomp $act;
+    chomp $exp;
+    if ($act ne $exp) {
+      print "\nExpected:\n$exp\ngot:\n$act\n";
+      $lerr++;
+    }
+  }
+  $l = <T>;
+  if ($l =~ /END-OUTPUT/) { } else {
+    $lerr++;
+    print "\nExpected:\n$l\n";
+  }
+
+  if ($lerr == 0) { print STDERR "OK\n"; }
+  else { $err++; print STDERR "FAIL\n"; }
+}
+
+foreach (@ARGV) {
+  one_test($_);
+}
+
+if ($err != 0) {
+  print STDERR "There were $err ERRORS!\n";
+  exit 1;
+} else {
+  print STDERR "All OK\n";
+  exit 0;
+}



More information about the svn mailing list