Skip to content

Commit

Permalink
added test that old singletons behavior is preserved when command is …
Browse files Browse the repository at this point in the history
…used to disable new singletons-by-default behavior

Note that it's a matter of "if these two branches of logic didn't necessarily have to test the same WME from the perspective of the backtracing, it's just by happenstance that they did" where the new behavior is "and so because they did ultimately test the same superstate wme, we won't generalize to say that potentially this logic would have happened had they tested different wmes". The old behavior was basically "and so we'll generalize that if different wmes lead to those same logic traces in the future, we'll already have the chunk"
  • Loading branch information
scijones committed Mar 22, 2024
1 parent 7e2b911 commit d269cc9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sp {answer*make*t2-1
(state <s1> ^superstate nil ^foo2 { <f1> <> homer } ^foo { <f2> <> bart }
^foo { <f3> <> simpson })
-->
(<s1> ^test-done true)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Tests:
# - Two conditions in two tests backtraced through that test the same constant in the same wme in the top state
# - Should not appear as same condition or variable in chunk
# - Two conditions in two tests backtraced through, one that tests a constant in the top state and one
# that tests a copy of it made on the top state

srand 23
chunk always
chunk automatically-create-singletons off

sp {init-superstate
(state <s> ^superstate nil)
-->
(<s> ^foo bar)
(write (crlf) |Starting chunking unit test.|)
}

sp {elab-superstate
(state <s> ^{ << foo foot >> <a> } <v>)
-->
(<s> ^foo2 <v>)
(write (crlf) |Starting chunking unit test.|)
}

sp {apply*test-done
(state <s> ^superstate nil ^test-done)
-->
(write (crlf) |Chunk produced. Test completed.|)
(succeeded)
(interrupt)
}

sp {apply*test-failed
(state <s> ^superstate.superstate.superstate.superstate nil)
-->
(write (crlf) |Chunk not produced. Test failed.|)
(interrupt)
}

sp {propose*test
(state <s> ^superstate.superstate nil)
-->
(<s> ^operator <o> +)}

sp {apply-bt1
(state <s> ^operator
^superstate <ss>)
(<ss> ^foo {<> bart <x>}
^foo2 {<> homer <z>})
-->
(<s> ^continue1 true)
}

sp {apply-bt2
(state <s> ^operator
^superstate <ss>)
(<ss> ^foo {<> simpson <y>})
-->
(<s> ^continue2 true)
}

sp {apply-bt3
(state <s> ^operator
^superstate <ss>)
-->
(<s> ^continue3 true)
}

sp {make
(state <s> ^operator
^continue1
^continue2
^superstate <ss>)
-->
(<ss> ^test-done true +)
}
1 change: 1 addition & 0 deletions UnitTests/SoarUnitTests/ChunkingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void ChunkingTests::STI_Variablization_Same_Type() { check_ch
void ChunkingTests::STI_Variablization() { check_chunk("STI_Variablization", 8, 1); }
void ChunkingTests::STI_with_referents() { check_chunk("STI_with_referents", 8, 1); }
void ChunkingTests::Superstate_Identity_Opaque() { check_chunk("Superstate_Identity_Opaque", 8, 1); }
void ChunkingTests::Superstate_Identity_Opaque_Old_Singleton_Behavior() { check_chunk("Superstate_Identity_Opaque_Old_Singleton_Behavior", 8, 1); }
void ChunkingTests::Ungrounded_in_BT_Constraint() { check_chunk("Ungrounded_in_BT_Constraint", 8, 2); }
void ChunkingTests::Ungrounded_Mixed() { check_chunk("Ungrounded_Mixed", 8, 1); }
void ChunkingTests::Ungrounded_Relational_Constraint() { check_chunk("Ungrounded_Relational_Constraint", 8, 1); }
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/SoarUnitTests/ChunkingTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ChunkingTests : public FunctionalTestHarness
TEST(Maintain_Instantiation_Specific_Identity, -1);
TEST(Opaque_State_Barrier, -1);
TEST(Superstate_Identity_Opaque, -1);
TEST(Superstate_Identity_Opaque_Old_Singleton_Behavior, -1);
TEST(STI_Variablization, -1);
TEST(STI_with_referents, -1);
TEST(Conflated_Constants, -1);
Expand Down Expand Up @@ -192,6 +193,7 @@ class ChunkingTests : public FunctionalTestHarness
void STI_Variablization();
void STI_with_referents();
void Superstate_Identity_Opaque();
void Superstate_Identity_Opaque_Old_Singleton_Behavior();
void Ungrounded_in_BT_Constraint();
void Ungrounded_Mixed();
void Ungrounded_Relational_Constraint();
Expand Down

0 comments on commit d269cc9

Please sign in to comment.