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: * B(a) :- C(c)
24: * B(a) :- D(d)
25: * A(a)
26: * A(b)
27: * C(c)
28: * D(d)
29: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
30: * @version 3.4 <7 March 05>
31: * @since 2.1
32: */
33: public class TestCut4 extends TestCut {
34: /**
35: * @see test.org.mandarax.reference.cut.TestCut#feedKnowledgeBase(KnowledgeBase)
36: */
37: public void feedKnowledgeBase(
38: org.mandarax.kernel.KnowledgeBase knowledge) {
39: kb.add(lfs.rule(this .prereq2("A", "x"), this .cut(), this
40: .prereq2("B", "x"), this .fact2("R", "x")));
41: kb.add(lfs.rule(this .prereq1("C", "c"), this .fact2("B", "x")));
42: kb.add(lfs.rule(this .prereq1("D", "d"), this .fact2("B", "x")));
43: kb.add(this .fact1("A", "a"));
44: kb.add(this .fact1("A", "b"));
45: kb.add(this .fact2("C", "c"));
46: kb.add(this .fact2("D", "d"));
47: }
48:
49: /**
50: * Get the expected results.
51: * @return an array of expected results.
52: */
53: protected String[] getExpectedResults() {
54: return new String[] { "a", "a" };
55: }
56:
57: /**
58: * Convert the object to a string.
59: * @return a string
60: */
61: public String toString() {
62: return "Test case for cut 4";
63: }
64:
65: }
|