|
6 | 6 | BLOCKSWORLD_VALID_PLAN, |
7 | 7 | LOGISTICS_FUEL_DOMAIN, |
8 | 8 | LOGISTICS_FUEL_PROBLEM, |
| 9 | + TYPED_HIERARCHY_DOMAIN, |
| 10 | + TYPED_HIERARCHY_PROBLEM, |
| 11 | + TYPED_HIERARCHY_SIBLING_PLAN, |
| 12 | + TYPED_HIERARCHY_SUBTYPE_PLAN, |
9 | 13 | write_pddl_files, |
10 | 14 | ) |
11 | 15 |
|
@@ -86,6 +90,39 @@ def test_empty_plan(tmp_path): |
86 | 90 | assert result.phases["structure"]["status"] == "PASS" |
87 | 91 |
|
88 | 92 |
|
| 93 | +def test_subtype_object_accepted_for_supertype_parameter(tmp_path): |
| 94 | + """Action parameter typed `vehicle` must accept a `truck` (subtype).""" |
| 95 | + paths = write_pddl_files( |
| 96 | + tmp_path, |
| 97 | + TYPED_HIERARCHY_DOMAIN, |
| 98 | + TYPED_HIERARCHY_PROBLEM, |
| 99 | + TYPED_HIERARCHY_SUBTYPE_PLAN, |
| 100 | + ) |
| 101 | + v = PDDLValidator() |
| 102 | + result = v.validate(paths["domain"], paths["problem"], paths["plan"]) |
| 103 | + assert result.phases["structure"]["status"] == "PASS", ( |
| 104 | + result.phases["structure"]["errors"] |
| 105 | + ) |
| 106 | + |
| 107 | + |
| 108 | +def test_sibling_type_rejected_for_parameter(tmp_path): |
| 109 | + """An object from a sibling branch (cargo) must NOT satisfy a vehicle parameter.""" |
| 110 | + paths = write_pddl_files( |
| 111 | + tmp_path, |
| 112 | + TYPED_HIERARCHY_DOMAIN, |
| 113 | + TYPED_HIERARCHY_PROBLEM, |
| 114 | + TYPED_HIERARCHY_SIBLING_PLAN, |
| 115 | + ) |
| 116 | + v = PDDLValidator() |
| 117 | + result = v.validate(paths["domain"], paths["problem"], paths["plan"]) |
| 118 | + assert not result.is_valid |
| 119 | + assert result.status == "STRUCTURE_ERROR" |
| 120 | + assert any( |
| 121 | + "expects type 'vehicle'" in e and "box1" in e |
| 122 | + for e in result.phases["structure"]["errors"] |
| 123 | + ) |
| 124 | + |
| 125 | + |
89 | 126 | def test_comment_and_cost_lines_skipped(tmp_path): |
90 | 127 | plan = """\ |
91 | 128 | ; This is a comment |
|
0 commit comments