Skip to content

Commit

Permalink
Rename new unit test, and enable it.
Browse files Browse the repository at this point in the history
It wasn't really virtual in the usual sense; just evaluatable.
  • Loading branch information
linas committed Apr 21, 2022
1 parent d4887d2 commit a7fb5f0
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 60 deletions.
1 change: 1 addition & 0 deletions tests/query/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ IF (HAVE_GUILE)
ADD_GUILE_TEST(OrLinkTest or-link-test.scm)
ADD_GUILE_TEST(OrMoreTest or-more-test.scm)
ADD_GUILE_TEST(OrBindTest or-bind-test.scm)
ADD_GUILE_TEST(OrEvalTest or-eval-test.scm)
ADD_GUILE_TEST(QuoteStartTest quote-start-test.scm)
ADD_GUILE_TEST(RecursiveTest recursive-test.scm)

Expand Down
19 changes: 0 additions & 19 deletions tests/query/VirtualUTest.cxxtest
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public:
void tearDown(void);

void test_satisfaction(void);
void xtest_disjunction(void);
};

void VirtualUTest::tearDown(void)
Expand Down Expand Up @@ -110,21 +109,3 @@ void VirtualUTest::test_satisfaction(void)

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

/*
* Test disjunction of virtual clauses (including one that is always true)
*/
void VirtualUTest::xtest_disjunction(void)
{
logger().debug("BEGIN TEST: %s", __FUNCTION__);

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

Handle result = eval->eval_h("(cog-execute! query)");
Handle human = as->add_link(SET_LINK, as->add_node(CONCEPT_NODE, "human"));
printf("Expecting human, got %s", result->to_string().c_str());

TS_ASSERT_EQUALS(result, human);

logger().debug("END TEST: %s", __FUNCTION__);
}
71 changes: 71 additions & 0 deletions tests/query/or-eval-test.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
;
; or-eval-test.scm -- Verify OrLink with GroundedPredicates in it
; Tests for problem reported in opencog/atomspace#2931

(use-modules (opencog) (opencog exec))
(use-modules (opencog test-runner))

;; Functions
(define-public (bool->tv b) (stv (if b 1 0) 1))
(define-public (tv->bool tv) (equal? (stv 1 1) tv))
(define-public (true? A) (bool->tv (tv->bool (cog-tv A))))
(define (always-true) (stv 1 1))

;; KB
(Inheritance (stv 1 1) (Concept "human") (Concept "person"))

;; Query
(define query-plain
(Get
(TypedVariable (Variable "$A") (Type "ConceptNode"))
(And
(Or
(Evaluation
(GroundedPredicate "scm: true?")
(Evaluation
(Predicate "P")
(List
(Concept "dog")
(Variable "$A"))))
(Evaluation
(GroundedPredicate "scm: always-true")
(List)))
(Inheritance
(Variable "$A")
(Concept "person"))))
)

(define query-present
(Get
(TypedVariable (Variable "$A") (Type "ConceptNode"))
(And
(Or
(Evaluation
(GroundedPredicate "scm: true?")
(Evaluation
(Predicate "P")
(List
(Concept "dog")
(Variable "$A"))))
(Evaluation
(GroundedPredicate "scm: always-true")
(List)))
(Present
(Inheritance
(Variable "$A")
(Concept "person")))))
)

(opencog-test-runner)
(define tname "or-eval-test")
(test-begin tname)

(test-assert "human-plain"
(equal? (cog-execute! query-plain) (Set (Concept "human"))))

(test-assert "human-present"
(equal? (cog-execute! query-present) (Set (Concept "human"))))

(test-end tname)

(opencog-test-end)
41 changes: 0 additions & 41 deletions tests/query/virtual-disjunction.scm

This file was deleted.

0 comments on commit a7fb5f0

Please sign in to comment.