]> hydra-www.ietfng.org Git - dyna2/commitdiff
update tests - new solution formatting.
authorTim Vieira <tim.f.vieira@gmail.com>
Sat, 6 Jul 2013 17:44:56 +0000 (13:44 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Sat, 6 Jul 2013 17:44:56 +0000 (13:44 -0400)
examples/expected/lists.py.out
examples/expected/matrixops.py.out
examples/expected/simple.py.out
examples/matrixops.dyna
src/Dyna/Backend/Python/chart.py
src/Dyna/Backend/Python/interpreter.py

index 24c96b56edbf135e3179fd0583a5d6c2947744a7..c678512655d5173d7aacde162f830c02eb572512 100644 (file)
@@ -16,7 +16,7 @@ d(4) = true.
 
 f/1
 ===
-f([1, 2]) = true.
+f([1, 2]).
 
 foo/1
 =====
index 83e757e3ebf1545be10ab15ca7fc1212f57a2535..da4fd8e8906ca77c1e32daf620ec85835396b6cf 100644 (file)
@@ -39,9 +39,9 @@ rows(c) = 2.
 
 shape/3
 =======
-shape(a,2,2) = true.
-shape(b,2,3) = true.
-shape(c,2,3) = true.
+shape(a,2,2).
+shape(b,2,3).
+shape(c,2,3).
 
 times/4
 =======
index 42175936c240404fed02dce3c519a00be9c8b396..2b3666ef4203c3bbe1449d4ac4a8e1ea34211d43 100644 (file)
@@ -1,7 +1,7 @@
 
 Solution
 ========
-a = true.
-b = true.
-c = true.
+a.
+b.
+c.
 
index 4dc21d59e1f5266b076b36d4f252a46c4279d54d..5c08af59ee020ecebae30653317a502fd566552e 100644 (file)
@@ -19,19 +19,19 @@ cols(X) max= _ is m(X, _, C), C.
 % matrix "a" = [ 1 0 ;
 %                0 1 ]
 m(a, 1, 1) += 1.
-m(a, 1, 2) += 0 .
-m(a, 2, 1) += 0 .
+m(a, 1, 2) += 0.
+m(a, 2, 1) += 0.
 m(a, 2, 2) += 1.
 
 % matrix "b" = [ 3 0 1 ;
 %                0 2 0 ]
 m(b, 1, 1) += 3.
-m(b, 1, 2) += 0 .
-m(b, 1, 3) += 1 .
-m(b, 2, 1) += 0 .
+m(b, 1, 2) += 0.
+m(b, 1, 3) += 1.
+m(b, 2, 1) += 0.
 m(b, 2, 2) += 2.
-m(b, 2, 3) += 0 .
+m(b, 2, 3) += 0.
 
 % matrix "c" is the product of matricies "a" and "b"
 :-dispos product(&,&).
-product(a,b) := &c .
+product(a,b) := &c.
index 0ef1c9aa125fe42a3ea65a006acd5cb862d60362..a2b9c2b59572e9d9711694da5edb06c65a086707 100644 (file)
@@ -21,6 +21,8 @@ class Chart(object):
         if not rows:
             return ''
 
+        heading = [self.name, '='*len(self.name)]
+
         # special handing or-equals aggregators -- only list true facts (and errors)
         if self.agg_name == ':-' or self.agg_name == '|=':
             lines = []
@@ -30,7 +32,7 @@ class Chart(object):
                 elif term.value:  # e.g. $error
                     lines.append('%s = %s.' % (_repr(term), _repr(term.value)))
             if self.arity != 0:
-                lines.append('')
+                lines = heading + lines # heading
             return '\n'.join(lines)
 
         if self.arity == 0:
@@ -38,14 +40,13 @@ class Chart(object):
             return '%s = %s.' % (term, _repr(term.value))
 
         p = [(_repr(term), _repr(term.value)) for term in sorted(rows)]
-        lines = [self.name, '='*len(self.name)]  # heading
+        lines = []
         terms, values = zip(*p)
         widths = map(len, terms)
         fmt = '%%-%ds = %%s.' % min(max(widths), 40)
         for term, value in zip(terms, values):
             lines.append(fmt % (term, value))
-        lines.append('')
-        return '\n'.join(lines)
+        return '\n'.join(heading + lines)
 
     def __getitem__(self, s):
         assert len(s) == self.arity + 1, \
index 87dcbb1651016abdafab6443a953933c18baecd3..fce690dd56e375ec99b747332253645a957064df 100644 (file)
@@ -227,12 +227,10 @@ class Interpreter(object):
         if nullary:
             for line in nullary:
                 print >> out, line
-            print >> out
-        else:
-            print >> out
-
+        print >> out
         for line in charts:
             print >> out, line
+            print >> out
 
         self.dump_errors(out)