Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace ds {
done_cycle = current_cycle;
}
++current_cycle;
length_t count = temp_facts.size();
length_t count = temp_rules.size() + temp_facts.size();
for (auto it = temp_facts.begin(); it != temp_facts.end();) {
auto node = temp_facts.extract(it++);
facts.emplace(std::move(node.value()), current_cycle);
Expand Down
12 changes: 6 additions & 6 deletions tests/test_chain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ TEST_F(TestChain, execute_multiple_premises_chain) {
}
return false;
});
EXPECT_EQ(count, 1);
EXPECT_EQ(count, 2);
EXPECT_TRUE(success);
}

TEST_F(TestChain, execute_multiple_premises_partial) {
chain->add("p q r");
chain->add("p");
auto count = chain->execute([](ds::rule_t* rule) { return false; });
EXPECT_EQ(count, 0);
EXPECT_EQ(count, 1);
}

TEST_F(TestChain, execute_three_premises) {
Expand All @@ -87,7 +87,7 @@ TEST_F(TestChain, execute_three_premises) {
}
return false;
});
EXPECT_EQ(count, 1);
EXPECT_EQ(count, 3);
EXPECT_TRUE(success);
}

Expand Down Expand Up @@ -124,7 +124,7 @@ TEST_F(TestChain, execute_exceed_by_too_many_premises) {
EXPECT_TRUE(chain->add("ccccc"));
EXPECT_TRUE(chain->add("ddddd"));
EXPECT_TRUE(chain->add("eeeee"));
EXPECT_EQ(chain->execute([](ds::rule_t* rule) { return false; }), 1);
EXPECT_EQ(chain->execute([](ds::rule_t* rule) { return false; }), 5);
chain->reset();
chain->set_limit_size(100);
chain->set_buffer_size(1000);
Expand All @@ -134,7 +134,7 @@ TEST_F(TestChain, execute_exceed_by_too_many_premises) {
EXPECT_TRUE(chain->add("ccccc"));
EXPECT_TRUE(chain->add("ddddd"));
EXPECT_TRUE(chain->add("eeeee"));
EXPECT_EQ(chain->execute([](ds::rule_t* rule) { return false; }), 1);
EXPECT_EQ(chain->execute([](ds::rule_t* rule) { return false; }), 5);
chain->reset();
chain->set_limit_size(100);
chain->set_buffer_size(100);
Expand All @@ -144,5 +144,5 @@ TEST_F(TestChain, execute_exceed_by_too_many_premises) {
EXPECT_TRUE(chain->add("ccccc"));
EXPECT_TRUE(chain->add("ddddd"));
EXPECT_TRUE(chain->add("eeeee"));
EXPECT_EQ(chain->execute([](ds::rule_t* rule) { return false; }), 0);
EXPECT_EQ(chain->execute([](ds::rule_t* rule) { return false; }), 1);
}
12 changes: 6 additions & 6 deletions tests/test_chain.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ test("execute_multiple_premises_chain", () => {
}
return false;
});
expect(count).toBe(1);
expect(count).toBe(2);
expect(success).toBe(true);
});

test("execute_multiple_premises_partial", () => {
chain.add("p q r");
chain.add("p");
const count = chain.execute((rule) => false);
expect(count).toBe(0);
expect(count).toBe(1);
});

test("execute_three_premises", () => {
Expand All @@ -74,7 +74,7 @@ test("execute_three_premises", () => {
}
return false;
});
expect(count).toBe(1);
expect(count).toBe(3);
expect(success).toBe(true);
});

Expand Down Expand Up @@ -110,7 +110,7 @@ test("execute_exceed_by_too_many_premises", () => {
expect(newChain.add("ccccc")).toBe(true);
expect(newChain.add("ddddd")).toBe(true);
expect(newChain.add("eeeee")).toBe(true);
expect(newChain.execute((rule) => false)).toBe(1);
expect(newChain.execute((rule) => false)).toBe(5);

newChain.reset();
newChain.set_limit_size(100);
Expand All @@ -121,7 +121,7 @@ test("execute_exceed_by_too_many_premises", () => {
expect(newChain.add("ccccc")).toBe(true);
expect(newChain.add("ddddd")).toBe(true);
expect(newChain.add("eeeee")).toBe(true);
expect(newChain.execute((rule) => false)).toBe(1);
expect(newChain.execute((rule) => false)).toBe(5);

newChain.reset();
newChain.set_limit_size(100);
Expand All @@ -132,5 +132,5 @@ test("execute_exceed_by_too_many_premises", () => {
expect(newChain.add("ccccc")).toBe(true);
expect(newChain.add("ddddd")).toBe(true);
expect(newChain.add("eeeee")).toBe(true);
expect(newChain.execute((rule) => false)).toBe(0);
expect(newChain.execute((rule) => false)).toBe(1);
});
12 changes: 6 additions & 6 deletions tests/test_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def callback(rule: apyds.Rule) -> bool:
return False

count = chain.execute(callback)
assert count == 1
assert count == 2
assert success


def test_execute_multiple_premises_partial(chain: apyds.Chain) -> None:
chain.add("p q r")
chain.add("p")
count = chain.execute(lambda rule: False)
assert count == 0
assert count == 1


def test_execute_three_premises(chain: apyds.Chain) -> None:
Expand All @@ -81,7 +81,7 @@ def callback(rule: apyds.Rule) -> bool:
return False

count = chain.execute(callback)
assert count == 1
assert count == 3
assert success


Expand Down Expand Up @@ -117,7 +117,7 @@ def test_execute_exceed_by_too_many_premises() -> None:
assert chain.add("ccccc")
assert chain.add("ddddd")
assert chain.add("eeeee")
assert chain.execute(lambda rule: False) == 1
assert chain.execute(lambda rule: False) == 5

chain.reset()
chain.set_limit_size(100)
Expand All @@ -128,7 +128,7 @@ def test_execute_exceed_by_too_many_premises() -> None:
assert chain.add("ccccc")
assert chain.add("ddddd")
assert chain.add("eeeee")
assert chain.execute(lambda rule: False) == 1
assert chain.execute(lambda rule: False) == 5

chain.reset()
chain.set_limit_size(100)
Expand All @@ -139,4 +139,4 @@ def test_execute_exceed_by_too_many_premises() -> None:
assert chain.add("ccccc")
assert chain.add("ddddd")
assert chain.add("eeeee")
assert chain.execute(lambda rule: False) == 0
assert chain.execute(lambda rule: False) == 1
Loading