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