diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt index 8a5af0b57..2b7f76fe6 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt @@ -2,6 +2,10 @@ package it.unibo.tuprolog.collections internal interface PrototypeClauseCollectionTest { + fun getTakesUnificationIntoAccount() + + fun retractTakesUnificationIntoAccount() + fun nestedGetWorksAtSeveralDepthLevels() fun nestedRetractWorksAtSeveralDepthLevels() diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt index 77aa909ba..ccff42d41 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt @@ -121,4 +121,14 @@ internal class MutableReteClauseMultiSetTest : PrototypeClauseMultiSetTest{ override fun nestedRetractWorksAtSeveralDepthLevels() { prototype.nestedRetractWorksAtSeveralDepthLevels() } + + @Test + override fun getTakesUnificationIntoAccount() { + prototype.getTakesUnificationIntoAccount() + } + + @Test + override fun retractTakesUnificationIntoAccount() { + prototype.retractTakesUnificationIntoAccount() + } } \ No newline at end of file diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt index 36a0a7233..e9795b339 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt @@ -150,4 +150,14 @@ internal class MutableReteClauseQueueTest : PrototypeClauseQueueTest { override fun nestedRetractWorksAtSeveralDepthLevels() { prototype.nestedRetractWorksAtSeveralDepthLevels() } + + @Test + override fun getTakesUnificationIntoAccount() { + prototype.getTakesUnificationIntoAccount() + } + + @Test + override fun retractTakesUnificationIntoAccount() { + prototype.retractTakesUnificationIntoAccount() + } } \ No newline at end of file diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt index dfc553c4a..cae6df6f7 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt @@ -120,4 +120,14 @@ internal class ReteClauseMultiSetTest : PrototypeClauseMultiSetTest { override fun nestedRetractWorksAtSeveralDepthLevels() { prototype.nestedRetractWorksAtSeveralDepthLevels() } + + @Test + override fun getTakesUnificationIntoAccount() { + prototype.getTakesUnificationIntoAccount() + } + + @Test + override fun retractTakesUnificationIntoAccount() { + prototype.retractTakesUnificationIntoAccount() + } } \ No newline at end of file diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt index 6edfda284..1c71a35ac 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt @@ -150,4 +150,14 @@ internal class ReteClauseQueueTest : PrototypeClauseQueueTest{ override fun nestedRetractWorksAtSeveralDepthLevels() { prototype.nestedRetractWorksAtSeveralDepthLevels() } + + @Test + override fun getTakesUnificationIntoAccount() { + prototype.getTakesUnificationIntoAccount() + } + + @Test + override fun retractTakesUnificationIntoAccount() { + prototype.retractTakesUnificationIntoAccount() + } } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt index 86bc3f2d8..14c5e6364 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt @@ -14,6 +14,10 @@ internal abstract class PrototypeClauseCollectionTestImpl( private val collectionGenerator: (Iterable) -> ClauseCollection ) : PrototypeClauseCollectionTest { + private val member = Scope.empty { + factOf(structOf("member", varOf("H"), consOf(varOf("H"), anonymous()))) + } + private val deep = Fact.of( LogicList.of( @@ -66,6 +70,35 @@ internal abstract class PrototypeClauseCollectionTestImpl( protected abstract fun retractClauses(collection: ClauseCollection, query: Clause): Sequence + override fun getTakesUnificationIntoAccount() { + val collection = collectionGenerator(listOf(member)) + + assertClausesHaveSameLengthAndContent( + sequenceOf(member), + getClauses(collection, Fact.of(Struct.of("member", Atom.of("a"), LogicList.of(Atom.of("a"))))) + ) + assertClausesHaveSameLengthAndContent( + sequenceOf(), + getClauses(collection, Fact.of(Struct.of("member", Atom.of("a"), LogicList.of(Atom.of("b"))))) + ) + } + + override fun retractTakesUnificationIntoAccount() { + var collection = collectionGenerator(listOf(member)) + + assertClausesHaveSameLengthAndContent( + sequenceOf(member), + retractClauses(collection, Fact.of(Struct.of("member", Atom.of("a"), LogicList.of(Atom.of("a"))))) + ) + + collection = collectionGenerator(listOf(member)) + + assertClausesHaveSameLengthAndContent( + sequenceOf(), + retractClauses(collection, Fact.of(Struct.of("member", Atom.of("a"), LogicList.of(Atom.of("b"))))) + ) + } + override fun nestedGetWorksAtSeveralDepthLevels() { val collection = collectionGenerator(listOf(deep))