From 51ec8973d2fa19d897c17d2f1be461e294db4d93 Mon Sep 17 00:00:00 2001 From: Grigorii Kirgizov Date: Mon, 3 Feb 2020 20:25:40 +0300 Subject: [PATCH] Add test to reproduce MPSCR-35 --- reactor/Test/test/TestIncrementalProgram.kt | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/reactor/Test/test/TestIncrementalProgram.kt b/reactor/Test/test/TestIncrementalProgram.kt index ebdf4117..d59e53a9 100644 --- a/reactor/Test/test/TestIncrementalProgram.kt +++ b/reactor/Test/test/TestIncrementalProgram.kt @@ -513,6 +513,60 @@ class TestIncrementalProgram { } } + // Weaker matches + @Test + fun invalidateStaleDiscardingMatches() { + val progSpec = MockIncrProgSpec( + setOf("main", "has_type", "no_type", "typeOf"), + setOf(sym0("check"), sym0("recover"), sym0("expectType"), sym0("typeOf")) + ) + programWithRules( + rule("main", + headReplaced( + constraint("main") + ), + body( + princConstraint("check"), + princConstraint("expectType") + )), + rule("has_type", + headReplaced( + princConstraint("expectType") + ), + headKept( + princConstraint("typeOf") + ), + body( + constraint("has_type") + )), + rule("no_type", + headReplaced( + princConstraint("expectType") + ), + body( + constraint("no_type") // not expected after increm launch + )) + ).launch("initial run", progSpec) { result -> + + result.storeView().constraintSymbols() shouldBe setOf(sym0("no_type"), sym0("check")) + + }.also { (builder, evalRes) -> + + builder.insertRulesAt(1, + rule("typeOf", + headKept( + princConstraint("check") + ), + body( + princConstraint("typeOf") + )) + ).relaunch("test1", progSpec, evalRes.token()) { result -> + + result.storeView().constraintSymbols() shouldBe setOf(sym0("has_type"), sym0("check"), sym0("typeOf")) + } + } + } + // Description: due to incremental launch, match on 'foobar' will be known // before it should actually happen. If it happens earlier than needed, // 'bar' will be discarded too early and program results will be incorrect.