Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(490)

Side by Side Diff: src/translate/tests/test_normalization.py

Issue 6223064: issue278
Patch Set: Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/translate/tests/__init__.py ('k') | src/translate/tools.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 try:
2 # Python 2
3 from StringIO import StringIO
4 except ImportError:
5 # Python 3
6 from io import StringIO
7
8 import pddl
9 from pddl_to_prolog import Rule, PrologProgram
10
11 def test_normalization():
12 prog = PrologProgram()
13 prog.add_fact(pddl.Atom("at", ["foo", "bar"]))
14 prog.add_fact(pddl.Atom("truck", ["bollerwagen"]))
15 prog.add_fact(pddl.Atom("truck", ["segway"]))
16 prog.add_rule(Rule([pddl.Atom("truck", ["?X"])], pddl.Atom("at", ["?X", "?Y" ])))
17 prog.add_rule(Rule([pddl.Atom("truck", ["X"]), pddl.Atom("location", ["?Y"]) ],
18 pddl.Atom("at", ["?X", "?Y"])))
19 prog.add_rule(Rule([pddl.Atom("truck", ["?X"]), pddl.Atom("location", ["?Y"] )],
20 pddl.Atom("at", ["?X", "?X"])))
21 prog.add_rule(Rule([pddl.Atom("p", ["?Y", "?Z", "?Y", "?Z"])],
22 pddl.Atom("q", ["?Y", "?Y"])))
23 prog.add_rule(Rule([], pddl.Atom("foo", [])))
24 prog.add_rule(Rule([], pddl.Atom("bar", ["X"])))
25 prog.normalize()
26 output = StringIO()
27 prog.dump(file=output)
28 assert output.getvalue() == """\
29 Atom at(foo, bar).
30 Atom truck(bollerwagen).
31 Atom truck(segway).
32 Atom @object(bollerwagen).
33 Atom @object(foo).
34 Atom @object(bar).
35 Atom @object(segway).
36 Atom foo().
37 Atom bar(X).
38 none Atom at(?X, ?Y) :- Atom truck(?X), Atom @object(?Y).
39 none Atom at(?X, ?Y) :- Atom truck(X), Atom location(?Y), Atom @object(?X).
40 none Atom at(?X, ?X@0) :- Atom truck(?X), Atom location(?Y), Atom =(?X, ?X@0).
41 none Atom q(?Y, ?Y@0) :- Atom p(?Y, ?Z, ?Y, ?Z), Atom =(?Y, ?Y@0), Atom =(?Y, ?Y @1), Atom =(?Z, ?Z@2).
42 """
OLDNEW
« no previous file with comments | « src/translate/tests/__init__.py ('k') | src/translate/tools.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b