Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
99   542   26   3.81
0   298   0.26   26
26     1  
1    
 
  FormulaCheckerLogicalConnectivesTest       Line # 31 99 26 100% 1.0
 
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    import org.qedeq.kernel.bo.logic.common.FormulaChecker;
19    import org.qedeq.kernel.bo.logic.common.LogicalCheckExceptionList;
20    import org.qedeq.kernel.se.base.list.Element;
21    import org.qedeq.kernel.se.common.DefaultModuleAddress;
22    import org.qedeq.kernel.se.common.ModuleContext;
23    import org.qedeq.kernel.xml.parser.BasicParser;
24   
25    /**
26    * For testing the {@link org.qedeq.kernel.bo.logic.FormulaChecker}.
27    * Testing formulas made of logical connectives.
28    *
29    * @author Michael Meyling
30    */
 
31    public class FormulaCheckerLogicalConnectivesTest extends AbstractFormulaChecker {
32   
33    private ModuleContext context;
34   
35    private FormulaChecker checker;
36   
 
37  24 toggle protected void setUp() throws Exception {
38  24 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
39  24 checker = new FormulaCheckerImpl();
40    }
41   
 
42  24 toggle protected void tearDown() throws Exception {
43  24 context = null;
44    }
45   
46    /**
47    * Function: checkFormula(Element)
48    * Type: positive
49    * Data: A & B
50    *
51    * @throws Exception Test failed.
52    */
 
53  1 toggle public void testLogicalConnectivePositive01() throws Exception {
54  1 final Element ele = BasicParser.createElement(
55    "<AND><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></AND>");
56    // System.out.println(ele.toString());
57  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
58  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
59  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
60    .hasErrors());
61    }
62   
63    /**
64    * Function: checkFormula(Element)
65    * Type: positive
66    * Data: A v B
67    *
68    * @throws Exception Test failed.
69    */
 
70  1 toggle public void testLogicalConnectivePositive02() throws Exception {
71  1 final Element ele = BasicParser.createElement(
72    "<OR><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></OR>");
73    // System.out.println(ele.toString());
74  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
75  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
76  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
77    .hasErrors());
78    }
79   
80    /**
81    * Function: checkFormula(Element)
82    * Type: positive
83    * Data: A -> B
84    *
85    * @throws Exception Test failed.
86    */
 
87  1 toggle public void testLogicalConnectivePositive03() throws Exception {
88  1 final Element ele = BasicParser.createElement(
89    "<IMPL><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></IMPL>");
90    // System.out.println(ele.toString());
91  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
92  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
93  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
94    .hasErrors());
95    }
96   
97    /**
98    * Function: checkFormula(Element)
99    * Type: positive
100    * Data: A <-> B
101    *
102    * @throws Exception Test failed.
103    */
 
104  1 toggle public void testLogicalConnectivePositive04() throws Exception {
105  1 final Element ele = BasicParser.createElement(
106    "<EQUI><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></EQUI>");
107    // System.out.println(ele.toString());
108  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
109  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
110  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
111    .hasErrors());
112    }
113   
114    /**
115    * Function: checkFormula(Element)
116    * Type: positive
117    * Data: A & B & C
118    *
119    * @throws Exception Test failed.
120    */
 
121  1 toggle public void testLogicalConnectivePositive05() throws Exception {
122  1 final Element ele = BasicParser.createElement(
123    "<AND><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></AND>");
124    // System.out.println(ele.toString());
125  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
126  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
127  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
128    .hasErrors());
129    }
130   
131    /**
132    * Function: checkFormula(Element)
133    * Type: positive
134    * Data: A v B v C
135    *
136    * @throws Exception Test failed.
137    */
 
138  1 toggle public void testLogicalConnectivePositive06() throws Exception {
139  1 final Element ele = BasicParser.createElement(
140    "<OR><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></OR>");
141    // System.out.println(ele.toString());
142  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
143  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
144  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
145    .hasErrors());
146    }
147   
148    /**
149    * Function: checkFormula(Element)
150    * Type: positive
151    * Data: A <-> B <--> C
152    *
153    * @throws Exception Test failed.
154    */
 
155  1 toggle public void testLogicalConnectivePositive07() throws Exception {
156  1 final Element ele = BasicParser.createElement(
157    "<EQUI><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></EQUI>");
158    // System.out.println(ele.toString());
159  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
160  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
161  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
162    .hasErrors());
163    }
164   
165    /**
166    * Function: checkFormula(Element)
167    * Type: negative, code 30740
168    * Data: &
169    *
170    * @throws Exception Test failed.
171    */
 
172  1 toggle public void testLogicalConnectiveNegative01() throws Exception {
173  1 final Element ele = BasicParser.createElement("<AND />");
174    // System.out.println(ele.toString());
175  1 LogicalCheckExceptionList list =
176    checker.checkFormula(ele, context, getChecker());
177  1 assertEquals(1, list.size());
178  1 assertEquals(30740, list.get(0).getErrorCode());
179    }
180   
181    /**
182    * Function: checkFormula(Element)
183    * Type: negative, code 30740
184    * Data: v
185    *
186    * @throws Exception Test failed.
187    */
 
188  1 toggle public void testLogicalConnectiveNegative02() throws Exception {
189  1 final Element ele = BasicParser.createElement("<OR />");
190    // System.out.println(ele.toString());
191  1 LogicalCheckExceptionList list =
192    checker.checkFormula(ele, context, getChecker());
193  1 assertEquals(1, list.size());
194  1 assertEquals(30740, list.get(0).getErrorCode());
195    }
196   
197    /**
198    * Function: checkFormula(Element)
199    * Type: negative, code 30740
200    * Data: ->
201    *
202    * @throws Exception Test failed.
203    */
 
204  1 toggle public void testLogicalConnectiveNegative03() throws Exception {
205  1 final Element ele = BasicParser.createElement("<IMPL />");
206    // System.out.println(ele.toString());
207  1 LogicalCheckExceptionList list =
208    checker.checkFormula(ele, context, getChecker());
209  1 assertEquals(1, list.size());
210  1 assertEquals(30740, list.get(0).getErrorCode());
211    }
212   
213    /**
214    * Function: checkFormula(Element)
215    * Type: negative, code 30740
216    * Data: <->
217    *
218    * @throws Exception Test failed.
219    */
 
220  1 toggle public void testLogicalConnectiveNegative04() throws Exception {
221  1 final Element ele = BasicParser.createElement("<EQUI />");
222    // System.out.println(ele.toString());
223  1 LogicalCheckExceptionList list =
224    checker.checkFormula(ele, context, getChecker());
225  1 assertEquals(1, list.size());
226  1 assertEquals(30740, list.get(0).getErrorCode());
227    }
228   
229    /**
230    * Function: checkFormula(Element)
231    * Type: negative, code 30740
232    * Data: A &
233    *
234    * @throws Exception Test failed.
235    */
 
236  1 toggle public void testLogicalConnectiveNegative05() throws Exception {
237  1 final Element ele = BasicParser.createElement("<AND><PREDVAR id=\"A\"/></AND>");
238    // System.out.println(ele.toString());
239  1 LogicalCheckExceptionList list =
240    checker.checkFormula(ele, context, getChecker());
241  1 assertEquals(1, list.size());
242  1 assertEquals(30740, list.get(0).getErrorCode());
243    }
244   
245    /**
246    * Function: checkFormula(Element)
247    * Type: negative, code 30740
248    * Data: A v
249    *
250    * @throws Exception Test failed.
251    */
 
252  1 toggle public void testLogicalConnectiveNegative06() throws Exception {
253  1 final Element ele = BasicParser.createElement("<OR><PREDVAR id=\"A\"/></OR>");
254    // System.out.println(ele.toString());
255  1 LogicalCheckExceptionList list =
256    checker.checkFormula(ele, context, getChecker());
257  1 assertEquals(1, list.size());
258  1 assertEquals(30740, list.get(0).getErrorCode());
259    }
260   
261    /**
262    * Function: checkFormula(Element)
263    * Type: negative, code 30740
264    * Data: A ->
265    *
266    * @throws Exception Test failed.
267    */
 
268  1 toggle public void testLogicalConnectiveNegative07() throws Exception {
269  1 final Element ele = BasicParser.createElement("<IMPL><PREDVAR id=\"A\"/></IMPL>");
270    // System.out.println(ele.toString());
271  1 LogicalCheckExceptionList list =
272    checker.checkFormula(ele, context, getChecker());
273  1 assertEquals(1, list.size());
274  1 assertEquals(30740, list.get(0).getErrorCode());
275    }
276   
277    /**
278    * Function: checkFormula(Element)
279    * Type: negative, code 30740
280    * Data: A <->
281    *
282    * @throws Exception Test failed.
283    */
 
284  1 toggle public void testLogicalConnectiveNegative08() throws Exception {
285  1 final Element ele = BasicParser.createElement("<EQUI><PREDVAR id=\"A\"/></EQUI>");
286    // System.out.println(ele.toString());
287  1 LogicalCheckExceptionList list =
288    checker.checkFormula(ele, context, getChecker());
289  1 assertEquals(1, list.size());
290  1 assertEquals(30740, list.get(0).getErrorCode());
291    }
292   
293    /**
294    * Function: checkFormula(Element)
295    * Type: negative, code 30760
296    * Data: A -> B --> C
297    *
298    * @throws Exception Test failed.
299    */
 
300  1 toggle public void testLogicalConnectiveNegative09() throws Exception {
301  1 final Element ele = BasicParser.createElement(
302    "<IMPL><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></IMPL>");
303    // System.out.println(ele.toString());
304  1 LogicalCheckExceptionList list =
305    checker.checkFormula(ele, context, getChecker());
306  1 assertEquals(1, list.size());
307  1 assertEquals(30760, list.get(0).getErrorCode());
308    }
309   
310    /**
311    * Function: checkFormula(Element)
312    * Type: negative, code 30770, free and bound variables mixed
313    * Data: (x = x) & (y = {x | phi})
314    *
315    * @throws Exception Test failed.
316    */
 
317  1 toggle public void testLogicalConnectiveNegative10() throws Exception {
318  1 final Element ele = BasicParser.createElement(
319    "<AND>" +
320    "<PREDVAR id=\"equal\">" +
321    "<VAR id=\"x\" />" +
322    "<VAR id=\"x\" />" +
323    "</PREDVAR>" +
324    "<PREDVAR id=\"equal\">" +
325    "<VAR id=\"y\" />" +
326    "<CLASS>" +
327    "<VAR id=\"x\" />" +
328    "<PREDVAR id=\"phi\" />" +
329    "</CLASS>" +
330    "</PREDVAR>" +
331    "</AND>");
332    // System.out.println(ele.toString());
333  1 LogicalCheckExceptionList list =
334    checker.checkFormula(ele, context, getChecker());
335  1 assertEquals(1, list.size());
336  1 assertEquals(30770, list.get(0).getErrorCode());
337    }
338   
339    /**
340    * Function: checkFormula(Element)
341    * Type: negative, code 30780, free and bound variables mixed
342    * Data: (y = {x | phi}) & (x = x)
343    *
344    * @throws Exception Test failed.
345    */
 
346  1 toggle public void testLogicalConnectiveNegative11() throws Exception {
347  1 final Element ele = BasicParser.createElement(
348    "<AND>" +
349    "<PREDVAR id=\"equal\">" +
350    "<VAR id=\"y\" />" +
351    "<CLASS>" +
352    "<VAR id=\"x\" />" +
353    "<PREDVAR id=\"phi\" />" +
354    "</CLASS>" +
355    "</PREDVAR>" +
356    "<PREDVAR id=\"equal\">" +
357    "<VAR id=\"x\" />" +
358    "<VAR id=\"x\" />" +
359    "</PREDVAR>" +
360    "</AND>");
361    // System.out.println(ele.toString());
362  1 LogicalCheckExceptionList list =
363    checker.checkFormula(ele, context, getChecker());
364  1 assertEquals(1, list.size());
365  1 assertEquals(30780, list.get(0).getErrorCode());
366    }
367   
368    /**
369    * Function: checkFormula(Element)
370    * Type: negative, code 30770, free and bound variables mixed
371    * Data: (x = x) v (y = {x | phi})
372    *
373    * @throws Exception Test failed.
374    */
 
375  1 toggle public void testLogicalConnectiveNegative12() throws Exception {
376  1 final Element ele = BasicParser.createElement(
377    "<OR>" +
378    "<PREDVAR id=\"equal\">" +
379    "<VAR id=\"x\" />" +
380    "<VAR id=\"x\" />" +
381    "</PREDVAR>" +
382    "<PREDVAR id=\"equal\">" +
383    "<VAR id=\"y\" />" +
384    "<CLASS>" +
385    "<VAR id=\"x\" />" +
386    "<PREDVAR id=\"phi\" />" +
387    "</CLASS>" +
388    "</PREDVAR>" +
389    "</OR>");
390    // System.out.println(ele.toString());
391  1 LogicalCheckExceptionList list =
392    checker.checkFormula(ele, context, getChecker());
393  1 assertEquals(1, list.size());
394  1 assertEquals(30770, list.get(0).getErrorCode());
395    }
396   
397    /**
398    * Function: checkFormula(Element)
399    * Type: negative, code 30780, free and bound variables mixed
400    * Data: (y = {x | phi}) v (x = x)
401    *
402    * @throws Exception Test failed.
403    */
 
404  1 toggle public void testLogicalConnectiveNegative13() throws Exception {
405  1 final Element ele = BasicParser.createElement(
406    "<OR>" +
407    "<PREDVAR id=\"equal\">" +
408    "<VAR id=\"y\" />" +
409    "<CLASS>" +
410    "<VAR id=\"x\" />" +
411    "<PREDVAR id=\"phi\" />" +
412    "</CLASS>" +
413    "</PREDVAR>" +
414    "<PREDVAR id=\"equal\">" +
415    "<VAR id=\"x\" />" +
416    "<VAR id=\"x\" />" +
417    "</PREDVAR>" +
418    "</OR>");
419    // System.out.println(ele.toString());
420  1 LogicalCheckExceptionList list =
421    checker.checkFormula(ele, context, getChecker());
422  1 assertEquals(1, list.size());
423  1 assertEquals(30780, list.get(0).getErrorCode());
424    }
425   
426    /**
427    * Function: checkFormula(Element)
428    * Type: negative, code 30770, free and bound variables mixed
429    * Data: (x = x) -> (y = {x | phi})
430    *
431    * @throws Exception Test failed.
432    */
 
433  1 toggle public void testLogicalConnectiveNegative14() throws Exception {
434  1 final Element ele = BasicParser.createElement(
435    "<IMPL>" +
436    "<PREDVAR id=\"equal\">" +
437    "<VAR id=\"x\" />" +
438    "<VAR id=\"x\" />" +
439    "</PREDVAR>" +
440    "<PREDVAR id=\"equal\">" +
441    "<VAR id=\"y\" />" +
442    "<CLASS>" +
443    "<VAR id=\"x\" />" +
444    "<PREDVAR id=\"phi\" />" +
445    "</CLASS>" +
446    "</PREDVAR>" +
447    "</IMPL>");
448    // System.out.println(ele.toString());
449  1 LogicalCheckExceptionList list =
450    checker.checkFormula(ele, context, getChecker());
451  1 assertEquals(1, list.size());
452  1 assertEquals(30770, list.get(0).getErrorCode());
453    }
454   
455    /**
456    * Function: checkFormula(Element)
457    * Type: negative, code 30780, free and bound variables mixed
458    * Data: (y = {x | phi}) -> (x = x)
459    *
460    * @throws Exception Test failed.
461    */
 
462  1 toggle public void testLogicalConnectiveNegative15() throws Exception {
463  1 final Element ele = BasicParser.createElement(
464    "<IMPL>" +
465    "<PREDVAR id=\"equal\">" +
466    "<VAR id=\"y\" />" +
467    "<CLASS>" +
468    "<VAR id=\"x\" />" +
469    "<PREDVAR id=\"phi\" />" +
470    "</CLASS>" +
471    "</PREDVAR>" +
472    "<PREDVAR id=\"equal\">" +
473    "<VAR id=\"x\" />" +
474    "<VAR id=\"x\" />" +
475    "</PREDVAR>" +
476    "</IMPL>");
477    // System.out.println(ele.toString());
478  1 LogicalCheckExceptionList list =
479    checker.checkFormula(ele, context, getChecker());
480  1 assertEquals(1, list.size());
481  1 assertEquals(30780, list.get(0).getErrorCode());
482    }
483   
484    /**
485    * Function: checkFormula(Element)
486    * Type: negative, code 30770, free and bound variables mixed
487    * Data: (x = x) <-> (y = {x | phi})
488    *
489    * @throws Exception Test failed.
490    */
 
491  1 toggle public void testLogicalConnectiveNegative16() throws Exception {
492  1 final Element ele = BasicParser.createElement(
493    "<EQUI>" +
494    "<PREDVAR id=\"equal\">" +
495    "<VAR id=\"x\" />" +
496    "<VAR id=\"x\" />" +
497    "</PREDVAR>" +
498    "<PREDVAR id=\"equal\">" +
499    "<VAR id=\"y\" />" +
500    "<CLASS>" +
501    "<VAR id=\"x\" />" +
502    "<PREDVAR id=\"phi\" />" +
503    "</CLASS>" +
504    "</PREDVAR>" +
505    "</EQUI>");
506    // System.out.println(ele.toString());
507  1 LogicalCheckExceptionList list =
508    checker.checkFormula(ele, context, getChecker());
509  1 assertEquals(1, list.size());
510  1 assertEquals(30770, list.get(0).getErrorCode());
511    }
512   
513    /**
514    * Function: checkFormula(Element)
515    * Type: negative, code 30780, free and bound variables mixed
516    * Data: (y = {x | phi}) <-> (x = x)
517    *
518    * @throws Exception Test failed.
519    */
 
520  1 toggle public void testLogicalConnectiveNegative17() throws Exception {
521  1 final Element ele = BasicParser.createElement(
522    "<EQUI>" +
523    "<PREDVAR id=\"equal\">" +
524    "<VAR id=\"y\" />" +
525    "<CLASS>" +
526    "<VAR id=\"x\" />" +
527    "<PREDVAR id=\"phi\" />" +
528    "</CLASS>" +
529    "</PREDVAR>" +
530    "<PREDVAR id=\"equal\">" +
531    "<VAR id=\"x\" />" +
532    "<VAR id=\"x\" />" +
533    "</PREDVAR>" +
534    "</EQUI>");
535    // System.out.println(ele.toString());
536  1 LogicalCheckExceptionList list =
537    checker.checkFormula(ele, context, getChecker());
538  1 assertEquals(1, list.size());
539  1 assertEquals(30780, list.get(0).getErrorCode());
540    }
541   
542    }