Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart7.png 74% of files have more coverage
66   184   58   3
36   130   0.88   22
22     2.64  
1    
 
  AbstractFormulaChecker       Line # 31 66 58 69.4% 0.6935484
 
No Tests
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.logic.wf;
17   
18   
19    import org.qedeq.base.trace.Trace;
20    import org.qedeq.kernel.bo.logic.common.ExistenceChecker;
21    import org.qedeq.kernel.bo.logic.common.FunctionKey;
22    import org.qedeq.kernel.bo.logic.common.PredicateKey;
23    import org.qedeq.kernel.bo.test.QedeqBoTestCase;
24    import org.qedeq.kernel.se.common.RuleKey;
25   
26    /**
27    * For testing the {@link org.qedeq.kernel.bo.logic.FormulaChecker}.
28    *
29    * @author Michael Meyling
30    */
 
31    public abstract class AbstractFormulaChecker extends QedeqBoTestCase {
32   
33    /** This class. */
34    private static final Class CLASS = AbstractFormulaChecker.class;
35   
36   
37    private ExistenceChecker checker = new ExistenceChecker() {
38   
 
39  163 toggle public boolean predicateExists(final String name, final int arguments) {
40  163 Trace.param(CLASS, this, "predicateExists(String, int)", "name", name);
41  163 Trace.param(CLASS, this, "predicateExists(String, int)", "arguments", arguments);
42  163 if ("in".equals(name) && arguments == 2) {
43  24 return true;
44  139 } else if ("isSet".equals(name) && arguments == 1) {
45  3 return true;
46  136 } else if ("equal".equals(name) && arguments == 2) {
47  132 return true;
48  4 } else if ("true".equals(name) && arguments == 0) {
49  2 return true;
50    }
51  2 return false;
52    }
53   
 
54  0 toggle public boolean predicateExists(final PredicateKey predicate) {
55  0 return predicateExists(predicate.getName(), Integer.parseInt(predicate.getArguments()));
56    }
57   
 
58  10 toggle public boolean functionExists(final String name, final int arguments) {
59  10 Trace.param(CLASS, this, "functionExists(String, int)", "name", name);
60  10 Trace.param(CLASS, this, "functionExists(String, int)", "arguments", arguments);
61  10 if ("power".equals(name) && arguments == 1) {
62  3 return true;
63  7 } else if ("union".equals(name) && arguments == 2) {
64  4 return true;
65  3 } else if ("intersection".equals(name) && arguments == 2) {
66  0 return true;
67  3 } else if ("empty".equals(name) && arguments == 0) {
68  1 return true;
69    }
70  2 return false;
71    }
72   
 
73  0 toggle public boolean functionExists(FunctionKey function) {
74  0 return functionExists(function.getName(), Integer.parseInt(function.getArguments()));
75    }
76   
 
77  38 toggle public boolean classOperatorExists() {
78  38 return true;
79    }
80   
 
81  138 toggle public boolean identityOperatorExists() {
82  138 return true;
83    }
84   
 
85  125 toggle public String getIdentityOperator() {
86  125 return "equal";
87    }
88   
 
89  0 toggle public boolean isInitialPredicate(PredicateKey predicate) {
90  0 if ("in".equals(predicate.getName()) && predicate.getArguments() == "2") {
91  0 return true;
92    }
93  0 return false;
94    }
95   
 
96  0 toggle public boolean isInitialFunction(FunctionKey function) {
97  0 return false;
98    }
99   
 
100  0 toggle public boolean ruleExists(RuleKey ruleKey) {
101  0 return false;
102    }
103   
104    };
105   
106    private ExistenceChecker checkerWithoutClass = new ExistenceChecker() {
107   
 
108  53 toggle public boolean predicateExists(String name, int arguments) {
109  53 Trace.param(CLASS, this, "predicateExists(String, int)", "name", name);
110  53 Trace.param(CLASS, this, "predicateExists(String, int)", "arguments", arguments);
111  53 if ("in".equals(name) && arguments == 2) {
112  15 return true;
113  38 } else if ("isSet".equals(name) && arguments == 1) {
114  3 return true;
115  35 } else if ("equal".equals(name) && arguments == 2) {
116  33 return true;
117  2 } else if ("true".equals(name) && arguments == 0) {
118  2 return true;
119    }
120  0 return false;
121    }
122   
 
123  0 toggle public boolean predicateExists(PredicateKey predicate) {
124  0 return predicateExists(predicate.getName(), Integer.parseInt(predicate.getArguments()));
125    }
126   
 
127  2 toggle public boolean functionExists(String name, int arguments) {
128  2 Trace.param(CLASS, this, "functionExists(String, int)", "name", name);
129  2 Trace.param(CLASS, this, "functionExists(String, int)", "arguments", arguments);
130  2 if ("power".equals(name) && arguments == 1) {
131  1 return true;
132  1 } else if ("union".equals(name) && arguments == 2) {
133  0 return true;
134  1 } else if ("intersection".equals(name) && arguments == 2) {
135  0 return true;
136  1 } else if ("empty".equals(name) && arguments == 0) {
137  1 return true;
138    }
139  0 return false;
140    }
141   
 
142  0 toggle public boolean functionExists(FunctionKey function) {
143  0 return functionExists(function.getName(), Integer.parseInt(function.getArguments()));
144    }
145   
 
146  2 toggle public boolean classOperatorExists() {
147  2 return false;
148    }
149   
 
150  31 toggle public boolean identityOperatorExists() {
151  31 return true;
152    }
153   
 
154  29 toggle public String getIdentityOperator() {
155  29 return "equal";
156    }
157   
 
158  0 toggle public boolean isInitialPredicate(PredicateKey predicate) {
159  0 if ("in".equals(predicate.getName()) && predicate.getArguments() == "2") {
160  0 return true;
161    }
162  0 return false;
163    }
164   
 
165  0 toggle public boolean isInitialFunction(FunctionKey function) {
166  0 return false;
167    }
168   
 
169  0 toggle public boolean ruleExists(RuleKey ruleKey) {
170  0 return false;
171    }
172   
173    };
174   
 
175  125 toggle protected ExistenceChecker getChecker() {
176  125 return checker;
177    }
178   
 
179  29 toggle protected ExistenceChecker getCheckerWithoutClass() {
180  29 return checkerWithoutClass;
181    }
182   
183   
184    }