diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt index f97a788e..b148307e 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt @@ -97,11 +97,12 @@ internal open class MatchJournalImpl( override fun reset(pastPos: MatchJournal.Pos) { while (posPtr.hasPrevious()) { + current = posPtr.previous() if (current === pastPos.chunk) { current.entries = current.entries.subList(0, pastPos.entriesCount) + posPtr.next() // make 'posPtr' to always point right after 'current' return } - current = posPtr.previous() posPtr.remove() } if (currentPos() != pastPos) throw IllegalStateException() diff --git a/reactor/Test/test/TestStoreAwareJournal.kt b/reactor/Test/test/TestStoreAwareJournal.kt index 9f45d126..8eef2264 100644 --- a/reactor/Test/test/TestStoreAwareJournal.kt +++ b/reactor/Test/test/TestStoreAwareJournal.kt @@ -242,7 +242,6 @@ class TestStoreAwareJournal { @Test - @Ignore("reset is tested properly in TestController") fun testFullReset() { with(programWithRules( rule("rule1", @@ -284,7 +283,7 @@ class TestStoreAwareJournal { with(hist) { - view().chunks.size shouldBe 2 + view().chunks.size shouldBe 5 storeView().allOccurrences().count() shouldBe 1 // only "qux" // reset to the very beginning @@ -300,7 +299,6 @@ class TestStoreAwareJournal { @Test - @Ignore("reset is tested properly in TestController") fun testPushExecReset() { with(programWithRules( rule("rule2", @@ -326,7 +324,7 @@ class TestStoreAwareJournal { princConstraint("foo") ), body( - constraint("last") + princConstraint("last") )) )) { @@ -357,27 +355,26 @@ class TestStoreAwareJournal { // rule4 - hist.view().chunks.size shouldBe 2 + hist.view().chunks.size shouldBe 4 logFirstMatch() // match on the principal constraint must add the chunk - hist.view().chunks.size shouldBe 3 + hist.view().chunks.size shouldBe 5 val oldState = hist.view() - val oldNChunks = oldState.chunks.size val oldStore = hist.storeView().allOccurrences() val savedPos = hist.currentPos() hist.testPush() - logExpand(occurrence("last")) + logExpandJustified("last") - oldState.chunks.size shouldBe 3 - assertNotEquals(oldState.chunks, hist.view().chunks) + hist.view().chunks.size shouldBe 6 assertNotEquals(oldStore, hist.storeView().allOccurrences()) + hist.reset(savedPos) - oldState.chunks.size shouldBe 2 + hist.view().chunks.size shouldBe oldState.chunks.size hist.view().chunks shouldBe oldState.chunks hist.storeView().allOccurrences() shouldBe oldStore hist.currentPos() shouldBe savedPos