piterate :: [ModedVar] -> Doc e
piterate vs = if length vs == 0 then "_"
- else parens $
- sepBy "," (map ground2underscore vs)
- <> "," -- add a comma to ensure tuple.
-
+ else "[" <> sepBy "," (map ground2underscore vs) <> "]"
-- filterGround :: [ModedVar] -> [DVar]
-- filterGround = map (^.mv_var) . filter (not.nGround.(^.mv_mi))
<+> equals
<+> "build"
<> (parens $ pfas f vs <> comma
- <> (sepBy "," $ map pretty vs))
+ <> (sepBy "," $ map pretty vs))
pdope_ _ (OPIter v vs _ Det (Just (PDBS c))) = return $ pretty (v^.mv_var)
<+> equals
vcat
[ pretty (o^.mv_var)
<+> equals
- <+> "gbc"
- <> tupled (pfas f m : map (pretty . _mv_var) m)
+ <+> "gbc(" <> pfas f m <> ",[" <> sepBy "," (map (pretty . _mv_var) m) <> "])"
+
--- needs an opbuild
, ("d" <> pretty dookie)
from interpreter import Interpreter
from repl import REPL
from cStringIO import StringIO
-from utils import red, green, yellow, strip_comments
+from utils import bold, red, green, yellow, strip_comments
+
+
+def diff(expect, got):
+ with file('/tmp/expect','wb') as A:
+ A.write(expect)
+ with file('/tmp/got','wb') as B:
+ B.write(got)
+ from subprocess import Popen, PIPE
+ p = Popen(['colordiff', A.name, B.name], stdout=PIPE, stderr=PIPE)
+ return p.communicate()[0]
def extract(code):
repl.cmdloop()
continue
+ exception = False
sys.stdout = x = StringIO()
try:
repl.onecmd(cmd)
except:
+ exception = True
print >> out, red % traceback.format_exc()
finally:
sys.stdout = sys.__stdout__
got = clean(x.getvalue())
expect = clean(expect)
- if expect == '*ignore*':
+ if expect == '*ignore*' and not exception:
continue
- if expect != got:
+ if expect != got or exception:
print >> out, green % expect
print >> out, red % got
+ print >> out, bold % yellow % '=== diff ======'
+ print >> out, diff(expect, got).strip()
+ print >> out, bold % yellow % '==============='
errors += 1
+
else:
print >> out
print >> out, got
# is not possible.
self.emit(*e)
- def gbc(self, fn, *args):
+ def gbc(self, fn, args):
item = self.build(fn, *args)
this expresion graph.
"""
- if x not in ('true', 'false'):
- if x in self.visited:
- return red % '*cycle@%s*' % x
+ #if x not in ('true', 'false'):
+ # if x in self.visited:
+ # #return red % '*cycle@%s*' % x
+ # return x
self.visited.add(x)
g = self.graph
@property
def prompt(self):
- return bold % green % '> '
+ return '> '
def do_rules(self, _):
"""
|
└─ := 3
- f(X=3) := (f((X=3 - 1)=2)=2 + f((X=3 - 2)=1)=1)=3,
+ f(X=3) := (f((X=3 - 1)=2)=2 + f((X=3 - 2)=1)=1)=3
for ((X=3 > 1)=true) = (true=true).
|
├─ f(1) = 1
|
└─ := 2
- f(X=2) := (f((X=2 - 1)=1)=1 + f((X=2 - 2)=0)=1)=2,
+ f(X=2) := (f((X=2 - 1)=1)=1 + f((X=2 - 2)=0)=1)=2
for ((X=2 > 1)=true) = (true=true).
|
├─ f(0) = 1