Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart6.png 80% of files have more coverage
158   799   122   1.3
0   505   0.77   122
122     1  
1    
 
  FormulaCheckerGlobalTest       Line # 35 158 122 53.6% 0.53571427
 
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 java.util.List;
19   
20    import org.qedeq.kernel.bo.logic.common.FormulaChecker;
21    import org.qedeq.kernel.bo.logic.common.LogicalCheckExceptionList;
22    import org.qedeq.kernel.se.base.list.Atom;
23    import org.qedeq.kernel.se.base.list.Element;
24    import org.qedeq.kernel.se.base.list.ElementList;
25    import org.qedeq.kernel.se.common.DefaultModuleAddress;
26    import org.qedeq.kernel.se.common.ModuleContext;
27    import org.qedeq.kernel.se.dto.list.DefaultAtom;
28    import org.qedeq.kernel.se.dto.list.DefaultElementList;
29   
30    /**
31    * For testing the {@link org.qedeq.kernel.bo.logic.FormulaChecker}.
32    *
33    * @author Michael Meyling
34    */
 
35    public class FormulaCheckerGlobalTest extends AbstractFormulaChecker {
36   
37    /** Module context for module access. */
38    private ModuleContext context;
39   
40    private FormulaChecker checker;
41   
 
42  19 toggle protected void setUp() throws Exception {
43  19 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
44  19 checker = new FormulaCheckerImpl();
45    }
46   
 
47  19 toggle protected void tearDown() throws Exception {
48  19 context = null;
49    }
50   
51    /**
52    * Function: checkFormula(Element).
53    * Type: positive
54    * Data: y = { x | phi(x)} <-> (all z: z in y <-> z in {x | phi(x)})
55    *
56    * @throws Exception Test failed.
57    */
 
58  1 toggle public void testGlobalFormulaPositive() throws Exception {
59  1 final Element ele = new DefaultElementList("EQUI", new Element[] {
60    new DefaultElementList("PREDCON", new Element[] {
61    new DefaultAtom("equal"),
62    new DefaultElementList("VAR", new Element[] {
63    new DefaultAtom("y"),
64    }),
65    new DefaultElementList("CLASS", new Element[] {
66    new DefaultElementList("VAR", new Element[] {
67    new DefaultAtom("x"),
68    }),
69    new DefaultElementList("PREDVAR", new Element[] {
70    new DefaultAtom("\\phi"),
71    new DefaultElementList("VAR", new Element[] {
72    new DefaultAtom("x"),
73    })
74    })
75    })
76    }),
77    new DefaultElementList("FORALL", new Element[] {
78    new DefaultElementList("VAR", new Element[] {
79    new DefaultAtom("z"),
80    }),
81    new DefaultElementList("EQUI", new Element[] {
82    new DefaultElementList("PREDCON", new Element[] {
83    new DefaultAtom("in"),
84    new DefaultElementList("VAR", new Element[] {
85    new DefaultAtom("z"),
86    }),
87    new DefaultElementList("VAR", new Element[] {
88    new DefaultAtom("y"),
89    })
90    }),
91    new DefaultElementList("PREDCON", new Element[] {
92    new DefaultAtom("in"),
93    new DefaultElementList("VAR", new Element[] {
94    new DefaultAtom("z"),
95    }),
96    new DefaultElementList("CLASS", new Element[] {
97    new DefaultElementList("VAR", new Element[] {
98    new DefaultAtom("x"),
99    }),
100    new DefaultElementList("PREDVAR", new Element[] {
101    new DefaultAtom("\\phi"),
102    new DefaultElementList("VAR", new Element[] {
103    new DefaultAtom("x"),
104    })
105    })
106    })
107    })
108    })
109    })
110    });
111    // System.out.println(ele.toString());
112  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
113  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
114    }
115   
116    /**
117    * Function: checkFormula(Element).
118    * Type: negative, code 30400
119    * Data: element null
120    *
121    * @throws Exception Test failed.
122    */
 
123  1 toggle public void testGlobalFormulaNegative01() throws Exception {
124  1 LogicalCheckExceptionList list =
125    checker.checkFormula(null, context);
126  1 assertEquals(1, list.size());
127  1 assertEquals(30400, list.get(0).getErrorCode());
128    }
129   
130    /**
131    * Function: checkTerm(Element).
132    * Type: negative, code 30400
133    * Data: element null
134    *
135    * @throws Exception Test failed.
136    */
 
137  1 toggle public void testGlobalTermNegative01() throws Exception {
138  1 LogicalCheckExceptionList list =
139    checker.checkFormula(null, context);
140  1 assertEquals(1, list.size());
141  1 assertEquals(30400, list.get(0).getErrorCode());
142    }
143   
144    /**
145    * Function: checkFormula(Element).
146    * Type: negative, code 30410
147    * Data: element getAtom() null
148    *
149    * @throws Exception Test failed.
150    */
 
151  1 toggle public void testGlobalFormulaNegative03() throws Exception {
152  1 LogicalCheckExceptionList list =
153    checker.checkFormula(new DefaultElementList("PREDVAR", new Element[]{new Atom() {
154   
 
155  0 toggle public String getString() {
156  0 return null;
157    }
158   
 
159  1 toggle public boolean isAtom() {
160  1 return true;
161    }
162   
 
163  1 toggle public Atom getAtom() {
164  1 return null;
165    }
166   
 
167  0 toggle public boolean isList() {
168  0 return false;
169    }
170   
 
171  0 toggle public ElementList getList() {
172  0 return null;
173    }
174   
 
175  0 toggle public Element copy() {
176  0 return null;
177    }
178   
 
179  0 toggle public Element replace(final Element search, final Element replacement) {
180  0 return null;
181    }
182    }
183    }), context);
184  1 assertEquals(1, list.size());
185  1 assertEquals(30410, list.get(0).getErrorCode());
186    }
187   
188    /**
189    * Function: checkTerm(Element).
190    * Type: negative, code 30410
191    * Data: element getAtom() null
192    *
193    * @throws Exception Test failed.
194    */
 
195  1 toggle public void testGlobalFormulaNegative04() throws Exception {
196  1 LogicalCheckExceptionList list =
197    checker.checkTerm(new DefaultElementList("FUNCON", new Element[] {new Atom() {
198   
 
199  0 toggle public String getString() {
200  0 return null;
201    }
202   
 
203  1 toggle public boolean isAtom() {
204  1 return true;
205    }
206   
 
207  1 toggle public Atom getAtom() {
208  1 return null;
209    }
210   
 
211  0 toggle public boolean isList() {
212  0 return false;
213    }
214   
 
215  0 toggle public ElementList getList() {
216  0 return null;
217    }
218   
 
219  0 toggle public Element copy() {
220  0 return null;
221    }
222   
 
223  0 toggle public Element replace(final Element search, final Element replacement) {
224  0 return null;
225    }
226    }
227    }), context);
228  1 assertEquals(1, list.size());
229  1 assertEquals(30410, list.get(0).getErrorCode());
230    }
231   
232    /**
233    * Function: checkFormula(Element).
234    * Type: negative, code 30420
235    * Data: element getList() null
236    *
237    * @throws Exception Test failed.
238    */
 
239  1 toggle public void testGlobalFormulaNegative05() throws Exception {
240  1 LogicalCheckExceptionList list =
241    checker.checkFormula(new Element() {
242   
 
243  0 toggle public boolean isAtom() {
244  0 return false;
245    }
246   
 
247  0 toggle public Atom getAtom() {
248  0 return null;
249    }
250   
 
251  1 toggle public boolean isList() {
252  1 return true;
253    }
254   
 
255  1 toggle public ElementList getList() {
256  1 return null;
257    }
258   
 
259  0 toggle public Element copy() {
260  0 return null;
261    }
262   
 
263  0 toggle public Element replace(final Element search, final Element replacement) {
264  0 return null;
265    }
266    }, context);
267  1 assertEquals(1, list.size());
268  1 assertEquals(30420, list.get(0).getErrorCode());
269    }
270   
271    /**
272    * Function: checkTerm(Element).
273    * Type: negative, code 30420
274    * Data: element getList() null
275    *
276    * @throws Exception Test failed.
277    */
 
278  1 toggle public void testGlobalFormulaNegative06() throws Exception {
279  1 LogicalCheckExceptionList list =
280    checker.checkTerm(new Element() {
281   
 
282  0 toggle public boolean isAtom() {
283  0 return false;
284    }
285   
 
286  0 toggle public Atom getAtom() {
287  0 return null;
288    }
289   
 
290  1 toggle public boolean isList() {
291  1 return true;
292    }
293   
 
294  1 toggle public ElementList getList() {
295  1 return null;
296    }
297   
 
298  0 toggle public Element copy() {
299  0 return null;
300    }
301   
 
302  0 toggle public Element replace(final Element search, final Element replacement) {
303  0 return null;
304    }
305    }, context);
306  1 assertEquals(1, list.size());
307  1 assertEquals(30420, list.get(0).getErrorCode());
308    }
309   
310    /**
311    * Function: checkFormula(Element).
312    * Type: negative, code 30430
313    * Data: PREDVAR(null) (atom content is null)
314    *
315    * @throws Exception Test failed.
316    */
 
317  1 toggle public void testGlobalFormulaNegative07() throws Exception {
318  1 LogicalCheckExceptionList list =
319    checker.checkFormula(new DefaultElementList("PREDVAR", new Element[]{new Atom() {
320   
 
321  1 toggle public String getString() {
322  1 return null;
323    }
324   
 
325  1 toggle public boolean isAtom() {
326  1 return true;
327    }
328   
 
329  1 toggle public Atom getAtom() {
330  1 return this;
331    }
332   
 
333  0 toggle public boolean isList() {
334  0 return false;
335    }
336   
 
337  0 toggle public ElementList getList() {
338  0 return null;
339    }
340   
 
341  0 toggle public Element copy() {
342  0 return null;
343    }
344   
 
345  0 toggle public Element replace(final Element search, final Element replacement) {
346  0 return null;
347    }
348    }
349    }), context);
350  1 assertEquals(1, list.size());
351  1 assertEquals(30430, list.get(0).getErrorCode());
352    }
353   
354    /**
355    * Function: checkTerm(Element).
356    * Type: negative, code 30430
357    * Data: FUNCON(null) (atom content is null)
358    *
359    * @throws Exception Test failed.
360    */
 
361  1 toggle public void testGlobalFormulaNegative08() throws Exception {
362  1 LogicalCheckExceptionList list =
363    checker.checkTerm(new DefaultElementList("FUNCON", new Element[]{new Atom() {
364   
 
365  1 toggle public String getString() {
366  1 return null;
367    }
368   
 
369  1 toggle public boolean isAtom() {
370  1 return true;
371    }
372   
 
373  1 toggle public Atom getAtom() {
374  1 return this;
375    }
376   
 
377  0 toggle public boolean isList() {
378  0 return false;
379    }
380   
 
381  0 toggle public ElementList getList() {
382  0 return null;
383    }
384   
 
385  0 toggle public Element copy() {
386  0 return null;
387    }
388   
 
389  0 toggle public Element replace(final Element search, final Element replacement) {
390  0 return null;
391    }
392    }
393    }), context);
394  1 assertEquals(1, list.size());
395  1 assertEquals(30430, list.get(0).getErrorCode());
396    }
397   
398    /**
399    * Function: checkFormula(Element).
400    * Type: negative, code 30440
401    * Data: PREDVAR("") (atom contents has length 0)
402    *
403    * @throws Exception Test failed.
404    */
 
405  1 toggle public void testGlobalFormulaNegative09() throws Exception {
406  1 LogicalCheckExceptionList list =
407    checker.checkFormula(new DefaultElementList("PREDVAR", new Element[]{new Atom() {
408   
 
409  2 toggle public String getString() {
410  2 return "";
411    }
412   
 
413  1 toggle public boolean isAtom() {
414  1 return true;
415    }
416   
 
417  1 toggle public Atom getAtom() {
418  1 return this;
419    }
420   
 
421  0 toggle public boolean isList() {
422  0 return false;
423    }
424   
 
425  0 toggle public ElementList getList() {
426  0 return null;
427    }
428   
 
429  0 toggle public Element copy() {
430  0 return null;
431    }
432   
 
433  0 toggle public Element replace(final Element search, final Element replacement) {
434  0 return null;
435    }
436    }
437    }), context);
438  1 assertEquals(1, list.size());
439  1 assertEquals(30440, list.get(0).getErrorCode());
440    }
441   
442    /**
443    * Function: checkFormula(Element).
444    * Type: negative, code 30440
445    * Data: PREDCON("") (atom contents has length 0)
446    *
447    * @throws Exception Test failed.
448    */
 
449  1 toggle public void testGlobalFormulaNegative11() throws Exception {
450  1 final Element ele = new DefaultElementList("PREDCON", new Element[] {
451    new DefaultAtom("")});
452    // System.out.println(ele.toString());
453  1 LogicalCheckExceptionList list =
454    checker.checkFormula(ele, context);
455  1 assertEquals(1, list.size());
456  1 assertEquals(30440, list.get(0).getErrorCode());
457    }
458   
459    /**
460    * Function: checkTerm(Element).
461    * Type: negative, code 30440
462    * Data: FUNCON("") (atom contents has length 0)
463    *
464    * @throws Exception Test failed.
465    */
 
466  1 toggle public void testGlobalFormulaNegative12() throws Exception {
467  1 final Element ele = new DefaultElementList("FUNCON", new Element[] {
468    new DefaultAtom("")});
469    // System.out.println(ele.toString());
470  1 LogicalCheckExceptionList list =
471    checker.checkTerm(ele, context);
472  1 assertEquals(1, list.size());
473  1 assertEquals(30440, list.get(0).getErrorCode());
474    }
475   
476    /**
477    * Function: checkFormula(Element).
478    * Type: negative, code 30450
479    * Data: operator is null
480    *
481    * @throws Exception Test failed.
482    */
 
483  1 toggle public void testGlobalFormulaNegative13() throws Exception {
484  1 final Element ele = new ElementList() {
485   
 
486  0 toggle public int size() {
487  0 return 0;
488    }
489   
 
490  1 toggle public String getOperator() {
491  1 return null;
492    }
493   
 
494  0 toggle public Element getElement(final int i) {
495  0 return null;
496    }
497   
 
498  0 toggle public List getElements() {
499  0 return null;
500    }
501   
 
502  0 toggle public void add(final Element element) {
503   
504    }
505   
 
506  0 toggle public void insert(final int position, final Element element) {
507    }
508   
 
509  0 toggle public void replace(final int position, final Element element) {
510    }
511   
 
512  0 toggle public void remove(final int i) {
513    }
514   
 
515  0 toggle public boolean isAtom() {
516  0 return false;
517    }
518   
 
519  0 toggle public Atom getAtom() {
520  0 return null;
521    }
522   
 
523  1 toggle public boolean isList() {
524  1 return true;
525    }
526   
 
527  1 toggle public ElementList getList() {
528  1 return this;
529    }
530   
 
531  0 toggle public Element copy() {
532  0 return null;
533    }
534   
 
535  0 toggle public Element replace(final Element search, final Element replacement) {
536  0 return null;
537    }
538   
539    };
540    // System.out.println(ele.toString());
541  1 LogicalCheckExceptionList list =
542    checker.checkFormula(ele, context);
543  1 assertEquals(1, list.size());
544  1 assertEquals(30450, list.get(0).getErrorCode());
545    }
546   
547    /**
548    * Function: checkTerm(Element).
549    * Type: negative, code 30450
550    * Data: operator is null
551    *
552    * @throws Exception Test failed.
553    */
 
554  1 toggle public void testGlobalFormulaNegative14() throws Exception {
555  1 final Element ele = new ElementList() {
556   
 
557  0 toggle public int size() {
558  0 return 0;
559    }
560   
 
561  1 toggle public String getOperator() {
562  1 return null;
563    }
564   
 
565  0 toggle public Element getElement(final int i) {
566  0 return null;
567    }
568   
 
569  0 toggle public List getElements() {
570  0 return null;
571    }
572   
 
573  0 toggle public void add(final Element element) {
574   
575    }
576   
 
577  0 toggle public void insert(final int position, final Element element) {
578    }
579   
 
580  0 toggle public void replace(final int position, final Element element) {
581    }
582   
 
583  0 toggle public void remove(final int i) {
584    }
585   
 
586  0 toggle public boolean isAtom() {
587  0 return false;
588    }
589   
 
590  0 toggle public Atom getAtom() {
591  0 return null;
592    }
593   
 
594  1 toggle public boolean isList() {
595  1 return true;
596    }
597   
 
598  1 toggle public ElementList getList() {
599  1 return this;
600    }
601   
 
602  0 toggle public Element copy() {
603  0 return null;
604    }
605   
 
606  0 toggle public Element replace(final Element search, final Element replacement) {
607  0 return null;
608    }
609    };
610    // System.out.println(ele.toString());
611  1 LogicalCheckExceptionList list =
612    checker.checkTerm(ele, context);
613  1 assertEquals(1, list.size());
614  1 assertEquals(30450, list.get(0).getErrorCode());
615    }
616   
617    /**
618    * Function: checkFormula(Element).
619    * Type: negative, code 30460
620    * Data: operator has length 0
621    *
622    * @throws Exception Test failed.
623    */
 
624  1 toggle public void testGlobalFormulaNegative15() throws Exception {
625  1 final Element ele = new Element() {
626   
 
627  0 toggle public boolean isAtom() {
628  0 return false;
629    }
630   
 
631  0 toggle public Atom getAtom() {
632  0 return null;
633    }
634   
 
635  1 toggle public boolean isList() {
636  1 return true;
637    }
638   
 
639  1 toggle public ElementList getList() {
640  1 return new DefaultElementList("", new Element[] {});
641    }
642   
 
643  0 toggle public Element copy() {
644  0 return null;
645    }
646   
 
647  0 toggle public Element replace(final Element search, final Element replacement) {
648  0 return null;
649    }
650    };
651  1 LogicalCheckExceptionList list =
652    checker.checkFormula(ele, context);
653  1 assertEquals(1, list.size());
654  1 assertEquals(30460, list.get(0).getErrorCode());
655    }
656   
657    /**
658    * Function: checkTerm(Element).
659    * Type: negative, code 30460
660    * Data: operator has length 0
661    *
662    * @throws Exception Test failed.
663    */
 
664  1 toggle public void testGlobalFormulaNegative16() throws Exception {
665  1 final Element ele = new Element() {
666   
 
667  0 toggle public boolean isAtom() {
668  0 return false;
669    }
670   
 
671  0 toggle public Atom getAtom() {
672  0 return null;
673    }
674   
 
675  1 toggle public boolean isList() {
676  1 return true;
677    }
678   
 
679  1 toggle public ElementList getList() {
680  1 return new DefaultElementList("", new Element[] {});
681    }
682   
 
683  0 toggle public Element copy() {
684  0 return null;
685    }
686   
 
687  0 toggle public Element replace(final Element search, final Element replacement) {
688  0 return null;
689    }
690    };
691  1 LogicalCheckExceptionList list =
692    checker.checkTerm(ele, context);
693  1 assertEquals(1, list.size());
694  1 assertEquals(30460, list.get(0).getErrorCode());
695    }
696   
697    /**
698    * Function: checkFormula(Element).
699    * Type: negative, code 30460
700    * Data: operator has length 0
701    *
702    * @throws Exception Test failed.
703    */
 
704  1 toggle public void testGlobalFormulaNegative21() throws Exception {
705  1 final Element ele = new ElementList() {
706   
 
707  0 toggle public int size() {
708  0 return 0;
709    }
710   
 
711  1 toggle public String getOperator() {
712  1 return "";
713    }
714   
 
715  0 toggle public Element getElement(final int i) {
716  0 return null;
717    }
718   
 
719  0 toggle public List getElements() {
720  0 return null;
721    }
722   
 
723  0 toggle public void add(final Element element) {
724   
725    }
726   
 
727  0 toggle public void insert(final int position, final Element element) {
728    }
729   
 
730  0 toggle public void replace(final int position, final Element element) {
731    }
732   
 
733  0 toggle public void remove(final int i) {
734    }
735   
 
736  0 toggle public boolean isAtom() {
737  0 return false;
738    }
739   
 
740  0 toggle public Atom getAtom() {
741  0 return null;
742    }
743   
 
744  1 toggle public boolean isList() {
745  1 return true;
746    }
747   
 
748  1 toggle public ElementList getList() {
749  1 return this;
750    }
751   
 
752  0 toggle public Element copy() {
753  0 return null;
754    }
755   
 
756  0 toggle public Element replace(final Element search, final Element replacement) {
757  0 return null;
758    }
759    };
760    // System.out.println(ele.toString());
761  1 LogicalCheckExceptionList list =
762    checker.checkFormula(ele, context);
763  1 assertEquals(1, list.size());
764  1 assertEquals(30460, list.get(0).getErrorCode());
765    }
766   
767    /**
768    * Function: checkFormula(Element).
769    * Type: negative, code 30470
770    * Data:
771    *
772    * @throws Exception Test failed.
773    */
 
774  1 toggle public void testGlobalFormulaNegative23() throws Exception {
775  1 final Element ele = new DefaultAtom("Atom");
776    // System.out.println(ele.toString());
777  1 LogicalCheckExceptionList list =
778    checker.checkFormula(ele, context);
779  1 assertEquals(1, list.size());
780  1 assertEquals(30470, list.get(0).getErrorCode());
781    }
782   
783    /**
784    * Function: checkTerm(Element).
785    * Type: negative, code 30470
786    * Data:
787    *
788    * @throws Exception Test failed.
789    */
 
790  1 toggle public void testGlobalFormulaNegative24() throws Exception {
791  1 final Element ele = new DefaultAtom("Atom");
792    // System.out.println(ele.toString());
793  1 LogicalCheckExceptionList list =
794    checker.checkTerm(ele, context);
795  1 assertEquals(1, list.size());
796  1 assertEquals(30470, list.get(0).getErrorCode());
797    }
798   
799    }