Skip to content

Commit 21cfeaa

Browse files
committed
Add unit test for issue opencog#2886
1 parent f1c2e3e commit 21cfeaa

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

tests/query/PresentUTest.cxxtest

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public:
6161

6262
void test_literal(void);
6363
void test_virtual(void);
64+
// TODO: re-enable test_monotonicity as soon as
65+
// https://github.com/opencog/atomspace/issues/2886 is fixed.
66+
void xtest_monotonicity(void);
6467
};
6568

6669
void PresentUTest::tearDown(void)
@@ -116,5 +119,29 @@ void PresentUTest::test_virtual(void)
116119
logger().debug("END TEST: %s", __FUNCTION__);
117120
}
118121

122+
/**
123+
* Test the monotonicity of PresentLink. This is for issue
124+
* https://github.com/opencog/atomspace/issues/2886
125+
*
126+
*/
127+
void PresentUTest::xtest_monotonicity(void)
128+
{
129+
logger().debug("BEGIN TEST: %s", __FUNCTION__);
130+
131+
eval->eval("(load-from-path \"tests/query/present-monotonicity.scm\")");
132+
133+
Handle query = eval->eval_h("query");
134+
Handle results = HandleCast(query->execute());
135+
Handle P = an(PREDICATE_NODE, "P");
136+
Handle Q = an(PREDICATE_NODE, "Q");
137+
Handle expected = al(SET_LINK, al(LIST_LINK, P, Q));
138+
139+
printf("Expecting: %s\n", expected->to_string().c_str());
140+
printf("Got: %s\n", results->to_string().c_str());
141+
TS_ASSERT_EQUALS(results, expected);
142+
143+
logger().debug("END TEST: %s", __FUNCTION__);
144+
}
145+
119146
#undef al
120147
#undef an

tests/query/present-monotonicity.scm

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
;; Query
2+
(define query
3+
(let* (
4+
;; Constants
5+
(R (Predicate "R"))
6+
(A (Execution (Schema "A")))
7+
;; Variables
8+
(P (Variable "$P"))
9+
(Q (Variable "$Q"))
10+
;; Clauses
11+
(P→Q (Quote
12+
(Implication
13+
(Unquote P)
14+
(Unquote Q))))
15+
(Q∧A (And Q A))
16+
(Q∧A→R (Implication
17+
Q∧A
18+
R)))
19+
;; Query
20+
(Get
21+
(VariableSet P Q)
22+
(Present P→Q Q∧A→R))))
23+
24+
;; KB
25+
26+
;; Culprit
27+
(Implication
28+
(And
29+
(Predicate "Qbis") ; Culprit
30+
(Execution (Schema "A"))
31+
)
32+
(Predicate "R"))
33+
34+
;; Premises
35+
(Implication
36+
(Predicate "P")
37+
(Predicate "Q"))
38+
(Implication
39+
(And
40+
(Predicate "Q")
41+
(Execution (Schema "A"))
42+
)
43+
(Predicate "R"))
44+
45+
;; PM
46+
(define results (cog-execute! query))

0 commit comments

Comments
 (0)