Skip to content

Commit

Permalink
Add unit test for issue opencog#2886
Browse files Browse the repository at this point in the history
  • Loading branch information
ngeiswei committed Nov 5, 2021
1 parent f1c2e3e commit 21cfeaa
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/query/PresentUTest.cxxtest
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public:

void test_literal(void);
void test_virtual(void);
// TODO: re-enable test_monotonicity as soon as
// https://github.com/opencog/atomspace/issues/2886 is fixed.
void xtest_monotonicity(void);
};

void PresentUTest::tearDown(void)
Expand Down Expand Up @@ -116,5 +119,29 @@ void PresentUTest::test_virtual(void)
logger().debug("END TEST: %s", __FUNCTION__);
}

/**
* Test the monotonicity of PresentLink. This is for issue
* https://github.com/opencog/atomspace/issues/2886
*
*/
void PresentUTest::xtest_monotonicity(void)
{
logger().debug("BEGIN TEST: %s", __FUNCTION__);

eval->eval("(load-from-path \"tests/query/present-monotonicity.scm\")");

Handle query = eval->eval_h("query");
Handle results = HandleCast(query->execute());
Handle P = an(PREDICATE_NODE, "P");
Handle Q = an(PREDICATE_NODE, "Q");
Handle expected = al(SET_LINK, al(LIST_LINK, P, Q));

printf("Expecting: %s\n", expected->to_string().c_str());
printf("Got: %s\n", results->to_string().c_str());
TS_ASSERT_EQUALS(results, expected);

logger().debug("END TEST: %s", __FUNCTION__);
}

#undef al
#undef an
46 changes: 46 additions & 0 deletions tests/query/present-monotonicity.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;; Query
(define query
(let* (
;; Constants
(R (Predicate "R"))
(A (Execution (Schema "A")))
;; Variables
(P (Variable "$P"))
(Q (Variable "$Q"))
;; Clauses
(P→Q (Quote
(Implication
(Unquote P)
(Unquote Q))))
(Q∧A (And Q A))
(Q∧A→R (Implication
Q∧A
R)))
;; Query
(Get
(VariableSet P Q)
(Present P→Q Q∧A→R))))

;; KB

;; Culprit
(Implication
(And
(Predicate "Qbis") ; Culprit
(Execution (Schema "A"))
)
(Predicate "R"))

;; Premises
(Implication
(Predicate "P")
(Predicate "Q"))
(Implication
(And
(Predicate "Q")
(Execution (Schema "A"))
)
(Predicate "R"))

;; PM
(define results (cog-execute! query))

0 comments on commit 21cfeaa

Please sign in to comment.