[svn] r7056: nemerle/trunk/tools/nemerlish: eval.n
tests/nemish1.test tests/test-nemish.pl
malekith
svnadmin at nemerle.org
Tue Dec 5 21:12:24 CET 2006
Log:
Make the check for new variables more reliable. Improve the test and the tester.
Author: malekith
Date: Tue Dec 5 21:12:23 2006
New Revision: 7056
Modified:
nemerle/trunk/tools/nemerlish/eval.n
nemerle/trunk/tools/nemerlish/tests/nemish1.test
nemerle/trunk/tools/nemerlish/tests/test-nemish.pl
Modified: nemerle/trunk/tools/nemerlish/eval.n
==============================================================================
--- nemerle/trunk/tools/nemerlish/eval.n (original)
+++ nemerle/trunk/tools/nemerlish/eval.n Tue Dec 5 21:12:23 2006
@@ -164,33 +164,24 @@
// Check which variables are new to this call and set the first field
// in the return tuple - true for variable "it", new ones and those
// whose values and/or type has changed; false - for the rest.
- def loop (l1, l2, l3, l4, acc) {
- match ((l1, l2, l3, l4)) {
- | ([], [], [], []) => acc
- | ((mut, name, ty) :: t1, [], h3 :: t3, []) =>
- loop (t1, [], t3, [], (true, mut, name, h3, ty) :: acc)
- | ((mut, name, ty) :: t1, (prevmut, prevname, prevty) :: t2,
- h3 :: t3, h4 :: t4) =>
- if (name == prevname)
- if ((name == "it" && Evaluator.compiled == true) ||
- (h3 != null && !(h3.Equals (h4))) ||
- (h3 == null && h4 != null) ||
- mut != prevmut)
- loop (t1, t2, t3, t4, (true, mut, name, h3, ty) :: acc)
- else
- loop (t1, t2, t3, t4, (false, mut, name, h3, ty) :: acc)
- else
- loop (t1, (prevmut, prevname, prevty) :: t2, t3, h4 :: t4,
- (true, mut, name, h3, ty) :: acc)
- // This should match only when no code has been successfully
- // evaluated yet and we have _no_ variables at all.
- | _ => acc
- }
- }
+ def prev = Hashtable ();
+ List.Iter2 (prevlocals, prevvals.Rev (), fun ((mut, name, _), val) {
+ prev [name] = (mut, val)
+ });
Evaluator.vals = List.Rev (newvals);
- loop (Evaluator.locals, prevlocals, newvals, List.Rev (prevvals), [])
+ List.Map2 (locals, newvals, fun ((mut, name, ty), val) {
+ def is_new =
+ if (prev.Contains (name)) {
+ def (prevmut, prevval) = prev [name];
+ (name == "it" && compiled == true) ||
+ (val != null && ! (val.Equals (prevval))) ||
+ (val == null && prevval != null) ||
+ prevmut != mut
+ } else true;
+ (is_new, mut, name, val, ty)
+ }).Rev ()
}
// Does the same that Eval does, but instead of evaluation the result
Modified: nemerle/trunk/tools/nemerlish/tests/nemish1.test
==============================================================================
--- nemerle/trunk/tools/nemerlish/tests/nemish1.test (original)
+++ nemerle/trunk/tools/nemerlish/tests/nemish1.test Tue Dec 5 21:12:23 2006
@@ -1,5 +1,5 @@
def x = 42;
-def y = x + 7 - 3 - 4;;
+def y = x * 2;;
System.Console.WriteLine ($"Ala ma $x + $y kotow.");;
73;;
using System.Console;;
@@ -10,14 +10,12 @@
/*
BEGIN-OUTPUT
def x = 42 : System.Int32
-def y = 42 : System.Int32
-Ala ma 42 + 42 kotow.
+def y = 84 : System.Int32
+Ala ma 42 + 84 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
*/
Modified: nemerle/trunk/tools/nemerlish/tests/test-nemish.pl
==============================================================================
--- nemerle/trunk/tools/nemerlish/tests/test-nemish.pl (original)
+++ nemerle/trunk/tools/nemerlish/tests/test-nemish.pl Tue Dec 5 21:12:23 2006
@@ -16,7 +16,7 @@
$lerr = 0;
while (<M>) {
s/^- ([=-]\s*)*//;
- /^\S*$/ and next;
+ /^\s*$/ and next;
/^(Please|Welcome|Type) / and next;
$act = $_;
$exp = <T>;
More information about the svn
mailing list