From d269cc970e7fdcb7bb9eb17e44f0155185feac2c Mon Sep 17 00:00:00 2001 From: scijones Date: Fri, 22 Mar 2024 16:01:47 -0400 Subject: [PATCH] added test that old singletons behavior is preserved when command is 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" --- ...paque_Old_Singleton_Behavior_expected.soar | 7 ++ ...dentity_Opaque_Old_Singleton_Behavior.soar | 76 +++++++++++++++++++ UnitTests/SoarUnitTests/ChunkingTests.cpp | 1 + UnitTests/SoarUnitTests/ChunkingTests.hpp | 2 + 4 files changed, 86 insertions(+) create mode 100644 UnitTests/SoarTestAgents/Chunking/expected/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior_expected.soar create mode 100644 UnitTests/SoarTestAgents/Chunking/tests/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior.soar diff --git a/UnitTests/SoarTestAgents/Chunking/expected/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior_expected.soar b/UnitTests/SoarTestAgents/Chunking/expected/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior_expected.soar new file mode 100644 index 0000000000..d4f2510de4 --- /dev/null +++ b/UnitTests/SoarTestAgents/Chunking/expected/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior_expected.soar @@ -0,0 +1,7 @@ +sp {answer*make*t2-1 + (state ^superstate nil ^foo2 { <> homer } ^foo { <> bart } + ^foo { <> simpson }) + --> + ( ^test-done true) +} + diff --git a/UnitTests/SoarTestAgents/Chunking/tests/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior.soar b/UnitTests/SoarTestAgents/Chunking/tests/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior.soar new file mode 100644 index 0000000000..3fbf496c06 --- /dev/null +++ b/UnitTests/SoarTestAgents/Chunking/tests/ChunkingTests_Superstate_Identity_Opaque_Old_Singleton_Behavior.soar @@ -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 ^superstate nil) +--> + ( ^foo bar) + (write (crlf) |Starting chunking unit test.|) +} + +sp {elab-superstate + (state ^{ << foo foot >> } ) +--> + ( ^foo2 ) + (write (crlf) |Starting chunking unit test.|) +} + +sp {apply*test-done + (state ^superstate nil ^test-done) +--> + (write (crlf) |Chunk produced. Test completed.|) + (succeeded) + (interrupt) +} + +sp {apply*test-failed + (state ^superstate.superstate.superstate.superstate nil) +--> + (write (crlf) |Chunk not produced. Test failed.|) + (interrupt) +} + +sp {propose*test + (state ^superstate.superstate nil) +--> + ( ^operator +)} + +sp {apply-bt1 + (state ^operator + ^superstate ) + ( ^foo {<> bart } + ^foo2 {<> homer }) + --> + ( ^continue1 true) +} + +sp {apply-bt2 + (state ^operator + ^superstate ) + ( ^foo {<> simpson }) +--> + ( ^continue2 true) +} + +sp {apply-bt3 + (state ^operator + ^superstate ) +--> + ( ^continue3 true) +} + +sp {make + (state ^operator + ^continue1 + ^continue2 + ^superstate ) +--> + ( ^test-done true +) +} \ No newline at end of file diff --git a/UnitTests/SoarUnitTests/ChunkingTests.cpp b/UnitTests/SoarUnitTests/ChunkingTests.cpp index 20be60c23d..6b824a7854 100644 --- a/UnitTests/SoarUnitTests/ChunkingTests.cpp +++ b/UnitTests/SoarUnitTests/ChunkingTests.cpp @@ -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); } diff --git a/UnitTests/SoarUnitTests/ChunkingTests.hpp b/UnitTests/SoarUnitTests/ChunkingTests.hpp index 26ccf3adc3..0eeb45be99 100644 --- a/UnitTests/SoarUnitTests/ChunkingTests.hpp +++ b/UnitTests/SoarUnitTests/ChunkingTests.hpp @@ -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); @@ -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();