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