]> hydra-www.ietfng.org Git - dyna2/commitdiff
Fixed issue #52.
authorTim Vieira <tim.f.vieira@gmail.com>
Thu, 18 Jul 2013 17:21:54 +0000 (13:21 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Thu, 18 Jul 2013 17:21:54 +0000 (13:21 -0400)
run-doctests.py
src/Dyna/Backend/Python/interpreter.py

index 32ecb741525850ea606125c828cfcbbd8a589014..18b5a853eacb4967ea1ee5d72683d6bdbfdfc810 100755 (executable)
@@ -19,7 +19,7 @@ failures = []
 print 'End-to-end'
 print '=========='
 
-for z in path('examples/expected').glob("*.py.out"):
+for z in sorted(path('examples/expected').glob("*.py.out")):
 
     x = re.sub('(examples/)expected/(.*).py.out', r'\1\2.dyna', z)
     y = x + '.py.out'
@@ -47,7 +47,7 @@ print
 print 'Doctests'
 print '========'
 
-for x in path('test').glob("*/*.dynadoc"):
+for x in sorted(path('test').glob("*/*.dynadoc")):
     print x,
     sys.stdout.flush()
     with file(x) as f:
index e8bac8ae046d23c583c85b732e0fa4dfd7eea7c2..c97fa469c6354afdb8eed38e68018eff1db4406c 100644 (file)
@@ -139,6 +139,11 @@ class Interpreter(object):
         if was == now:
             # nothing to do.
             return
+        # special handling for with_key, forks a second update
+        self.replace(self.build('$key/1', item), None)     # always clear $key
+        if hasattr(now, 'fn') and now.fn == 'with_key/2':
+            now, key = now.args
+            self.replace(self.build('$key/1', item), key)
         # delete existing value before so we can replace it
         if was is not None:
             self.push(item, was, delete=True)
@@ -188,13 +193,6 @@ class Interpreter(object):
             self.set_error(item, (None, [(e, None)]))
 
         else:
-            # issue replacement update
-
-            # special handling for with_key, forks into two updates
-            if hasattr(now, 'fn') and now.fn == 'with_key/2':
-                now, key = now.args
-                self.replace(self.build('$key/1', item), key)
-
             self.replace(item, now)
 
         return now