01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package test.org.mandarax.reference;
19:
20: /**
21: * Test case for cut.
22: * R(x) :- A(x),B(x)
23: * A(x) :- !,B(x)
24: * A(x) :- C(x)
25: * B(b)
26: * C(c)
27: * The expected result is {b}.
28: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
29: * @version 3.4 <7 March 05>
30: * @since 2.1
31: */
32: public class TestCut7 extends TestCut {
33: /**
34: * @see test.org.mandarax.reference.cut.TestCut#feedKnowledgeBase(KnowledgeBase)
35: */
36: public void feedKnowledgeBase(
37: org.mandarax.kernel.KnowledgeBase knowledge) {
38: kb.add(lfs.rule(this .prereq2("A", "x"), this .prereq2("B", "x"),
39: this .fact2("R", "x")));
40: kb.add(lfs.rule(this .cut(), this .prereq2("B", "x"), this .fact2(
41: "A", "x")));
42: kb.add(lfs.rule(this .prereq2("C", "x"), this .fact2("A", "x")));
43: kb.add(this .fact1("B", "b"));
44: kb.add(this .fact1("C", "c"));
45: }
46:
47: /**
48: * Get the expected results.
49: * @return an array of expected results.
50: */
51: protected String[] getExpectedResults() {
52: return new String[] { "b" };
53: }
54:
55: /**
56: * Convert the object to a string.
57: * @return a string
58: */
59: public String toString() {
60: return "Test case for cut 7";
61: }
62:
63: }
|