Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
132   589   117   1.2
8   447   0.89   110
110     1.06  
1    
 
  VisitorContextTest       Line # 95 132 117 60.4% 0.604
 
  (1)
 
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.module;
17   
18    import java.io.File;
19    import java.lang.reflect.InvocationTargetException;
20   
21    import org.qedeq.base.io.SourceArea;
22    import org.qedeq.base.test.DynamicGetter;
23    import org.qedeq.base.test.QedeqTestCase;
24    import org.qedeq.base.trace.Trace;
25    import org.qedeq.kernel.bo.service.control.QedeqBoFactoryTest;
26    import org.qedeq.kernel.se.base.list.Atom;
27    import org.qedeq.kernel.se.base.list.ElementList;
28    import org.qedeq.kernel.se.base.module.Add;
29    import org.qedeq.kernel.se.base.module.Author;
30    import org.qedeq.kernel.se.base.module.AuthorList;
31    import org.qedeq.kernel.se.base.module.Axiom;
32    import org.qedeq.kernel.se.base.module.ChangedRule;
33    import org.qedeq.kernel.se.base.module.ChangedRuleList;
34    import org.qedeq.kernel.se.base.module.Chapter;
35    import org.qedeq.kernel.se.base.module.ChapterList;
36    import org.qedeq.kernel.se.base.module.Conclusion;
37    import org.qedeq.kernel.se.base.module.ConditionalProof;
38    import org.qedeq.kernel.se.base.module.Existential;
39    import org.qedeq.kernel.se.base.module.FormalProof;
40    import org.qedeq.kernel.se.base.module.FormalProofLine;
41    import org.qedeq.kernel.se.base.module.FormalProofLineList;
42    import org.qedeq.kernel.se.base.module.FormalProofList;
43    import org.qedeq.kernel.se.base.module.Formula;
44    import org.qedeq.kernel.se.base.module.FunctionDefinition;
45    import org.qedeq.kernel.se.base.module.Header;
46    import org.qedeq.kernel.se.base.module.Hypothesis;
47    import org.qedeq.kernel.se.base.module.Import;
48    import org.qedeq.kernel.se.base.module.ImportList;
49    import org.qedeq.kernel.se.base.module.InitialFunctionDefinition;
50    import org.qedeq.kernel.se.base.module.InitialPredicateDefinition;
51    import org.qedeq.kernel.se.base.module.Latex;
52    import org.qedeq.kernel.se.base.module.LatexList;
53    import org.qedeq.kernel.se.base.module.LinkList;
54    import org.qedeq.kernel.se.base.module.LiteratureItem;
55    import org.qedeq.kernel.se.base.module.LiteratureItemList;
56    import org.qedeq.kernel.se.base.module.Location;
57    import org.qedeq.kernel.se.base.module.LocationList;
58    import org.qedeq.kernel.se.base.module.ModusPonens;
59    import org.qedeq.kernel.se.base.module.Node;
60    import org.qedeq.kernel.se.base.module.PredicateDefinition;
61    import org.qedeq.kernel.se.base.module.Proof;
62    import org.qedeq.kernel.se.base.module.ProofList;
63    import org.qedeq.kernel.se.base.module.Proposition;
64    import org.qedeq.kernel.se.base.module.Qedeq;
65    import org.qedeq.kernel.se.base.module.Reason;
66    import org.qedeq.kernel.se.base.module.Rename;
67    import org.qedeq.kernel.se.base.module.Rule;
68    import org.qedeq.kernel.se.base.module.Section;
69    import org.qedeq.kernel.se.base.module.SectionList;
70    import org.qedeq.kernel.se.base.module.Specification;
71    import org.qedeq.kernel.se.base.module.Subsection;
72    import org.qedeq.kernel.se.base.module.SubsectionList;
73    import org.qedeq.kernel.se.base.module.SubsectionType;
74    import org.qedeq.kernel.se.base.module.SubstFree;
75    import org.qedeq.kernel.se.base.module.SubstFunc;
76    import org.qedeq.kernel.se.base.module.SubstPred;
77    import org.qedeq.kernel.se.base.module.Term;
78    import org.qedeq.kernel.se.base.module.Universal;
79    import org.qedeq.kernel.se.base.module.UsedByList;
80    import org.qedeq.kernel.se.common.DefaultModuleAddress;
81    import org.qedeq.kernel.se.common.ModuleAddress;
82    import org.qedeq.kernel.se.common.ModuleDataException;
83    import org.qedeq.kernel.se.visitor.QedeqNotNullTraverser;
84    import org.qedeq.kernel.se.visitor.QedeqVisitor;
85    import org.qedeq.kernel.xml.mapper.Context2SimpleXPath;
86    import org.qedeq.kernel.xml.tracker.SimpleXPath;
87    import org.qedeq.kernel.xml.tracker.XPathLocationParser;
88   
89   
90    /**
91    * Test context of {@link QedeqNotNullTraverser}.
92    *
93    * @author Michael Meyling
94    */
 
95    public class VisitorContextTest extends QedeqTestCase implements QedeqVisitor {
96   
97    /** This class. */
98    private static final Class CLASS = VisitorContextTest.class;
99   
100    /** Traverse QEDEQ module with this traverser. */
101    private QedeqNotNullTraverser traverser;
102   
103    private Qedeq qedeq;
104   
105    private File moduleFile;
106   
 
107  1 toggle public void testContext() throws Exception {
108  1 if (slow()) {
109  1 moduleFile = QedeqBoFactoryTest.getQedeqFile("math/qedeq_set_theory_v1.xml");
110  1 final ModuleAddress globalContext = new DefaultModuleAddress(moduleFile);
111  1 qedeq = QedeqBoFactoryTest.loadQedeq(moduleFile);
112  1 traverser = new QedeqNotNullTraverser(globalContext, this);
113  1 traverser.accept(qedeq);
114    }
115    }
116   
 
117  1263 toggle public void visitEnter(final Atom atom) throws ModuleDataException {
118  1263 checkContext();
119    }
120   
 
121  1516 toggle public void visitEnter(final ElementList list) throws ModuleDataException {
122  1516 checkContext();
123    }
124   
 
125  1 toggle public void visitEnter(final Author author) throws ModuleDataException {
126  1 checkContext();
127    }
128   
 
129  1 toggle public void visitEnter(final AuthorList authorList) throws ModuleDataException {
130  1 checkContext();
131    }
132   
 
133  12 toggle public void visitEnter(final Axiom axiom) throws ModuleDataException {
134  12 checkContext();
135    }
136   
 
137  8 toggle public void visitEnter(final Chapter chapter) throws ModuleDataException {
138  8 checkContext();
139    }
140   
 
141  1 toggle public void visitEnter(final ChapterList chapterList) throws ModuleDataException {
142  1 checkContext();
143    }
144   
 
145  0 toggle public void visitEnter(final ConditionalProof cp) throws ModuleDataException {
146  0 checkContext();
147    }
148   
 
149  88 toggle public void visitEnter(final Formula formula) throws ModuleDataException {
150  88 checkContext();
151    }
152   
 
153  16 toggle public void visitEnter(final FunctionDefinition functionDefinition) throws ModuleDataException {
154  16 checkContext();
155    }
156   
 
157  1 toggle public void visitEnter(final Header header) throws ModuleDataException {
158  1 checkContext();
159    }
160   
 
161  0 toggle public void visitEnter(final Hypothesis hypothesis) throws ModuleDataException {
162  0 checkContext();
163    }
164   
 
165  1 toggle public void visitEnter(final Import imp) throws ModuleDataException {
166  1 checkContext();
167    }
168   
 
169  1 toggle public void visitEnter(final ImportList importList) throws ModuleDataException {
170  1 checkContext();
171    }
172   
 
173  527 toggle public void visitEnter(final Latex latex) throws ModuleDataException {
174  527 checkContext();
175    }
176   
 
177  269 toggle public void visitEnter(final LatexList latexList) throws ModuleDataException {
178  269 checkContext();
179    }
180   
 
181  1 toggle public void visitEnter(final LinkList linkList) throws ModuleDataException {
182  1 checkContext();
183    }
184   
 
185  3 toggle public void visitEnter(final LiteratureItem literatureItem) throws ModuleDataException {
186  3 checkContext();
187    }
188   
 
189  1 toggle public void visitEnter(final LiteratureItemList literatureItemList) throws ModuleDataException {
190  1 checkContext();
191    }
192   
 
193  3 toggle public void visitEnter(final Location location) throws ModuleDataException {
194  3 checkContext();
195    }
196   
 
197  2 toggle public void visitEnter(final LocationList locationList) throws ModuleDataException {
198  2 checkContext();
199    }
200   
 
201  90 toggle public void visitEnter(final Node authorList) throws ModuleDataException {
202  90 checkContext();
203    }
204   
 
205  6 toggle public void visitEnter(final PredicateDefinition predicateDefinition)
206    throws ModuleDataException {
207  6 checkContext();
208    }
209   
 
210  0 toggle public void visitEnter(final FormalProofList formalProofList) throws ModuleDataException {
211  0 checkContext();
212    }
213   
 
214  0 toggle public void visitEnter(final FormalProof proof) throws ModuleDataException {
215  0 checkContext();
216    }
217   
 
218  0 toggle public void visitEnter(final FormalProofLine formalProofLine) throws ModuleDataException {
219  0 checkContext();
220    }
221   
 
222  0 toggle public void visitEnter(final FormalProofLineList formalProofLineList) throws ModuleDataException {
223  0 checkContext();
224    }
225   
 
226  0 toggle public void visitEnter(final Reason reason) throws ModuleDataException {
227  0 checkContext();
228    }
229   
 
230  0 toggle public void visitEnter(final ModusPonens reason) throws ModuleDataException {
231  0 checkContext();
232    }
233   
 
234  0 toggle public void visitEnter(final Add reason) throws ModuleDataException {
235  0 checkContext();
236    }
237   
 
238  0 toggle public void visitEnter(final Rename reason) throws ModuleDataException {
239  0 checkContext();
240    }
241   
 
242  0 toggle public void visitEnter(final SubstFree reason) throws ModuleDataException {
243  0 checkContext();
244    }
245   
 
246  0 toggle public void visitEnter(final SubstFunc reason) throws ModuleDataException {
247  0 checkContext();
248    }
249   
 
250  0 toggle public void visitEnter(final SubstPred reason) throws ModuleDataException {
251  0 checkContext();
252    }
253   
 
254  0 toggle public void visitEnter(final Existential reason) throws ModuleDataException {
255  0 checkContext();
256    }
257   
 
258  0 toggle public void visitEnter(final Universal reason) throws ModuleDataException {
259  0 checkContext();
260    }
261   
 
262  0 toggle public void visitEnter(final Conclusion conclusion) throws ModuleDataException {
263  0 checkContext();
264    }
265   
 
266  18 toggle public void visitEnter(final Proof proof) throws ModuleDataException {
267  18 checkContext();
268    }
269   
 
270  17 toggle public void visitEnter(final ProofList proofList) throws ModuleDataException {
271  17 checkContext();
272    }
273   
 
274  54 toggle public void visitEnter(final Proposition proposition) throws ModuleDataException {
275  54 checkContext();
276    }
277   
 
278  1 toggle public void visitEnter(final Qedeq qedeq) throws ModuleDataException {
279  1 checkContext();
280    }
281   
 
282  1 toggle public void visitEnter(final Rule rule) throws ModuleDataException {
283  1 checkContext();
284    }
285   
 
286  22 toggle public void visitEnter(final Section section) throws ModuleDataException {
287  22 checkContext();
288    }
289   
 
290  5 toggle public void visitEnter(final SectionList sectionList) throws ModuleDataException {
291  5 checkContext();
292    }
293   
 
294  2 toggle public void visitEnter(final Specification specification) throws ModuleDataException {
295  2 checkContext();
296    }
297   
 
298  2 toggle public void visitEnter(final Subsection subsection) throws ModuleDataException {
299  2 checkContext();
300    }
301   
 
302  14 toggle public void visitEnter(final SubsectionList subsectionList) throws ModuleDataException {
303  14 checkContext();
304    }
305   
 
306  0 toggle public void visitEnter(final SubsectionType subsectionType) throws ModuleDataException {
307  0 checkContext();
308    }
309   
 
310  0 toggle public void visitEnter(final Term term) throws ModuleDataException {
311  0 checkContext();
312    }
313   
 
314  0 toggle public void visitEnter(final UsedByList usedByList) throws ModuleDataException {
315  0 checkContext();
316    }
317   
 
318  1 toggle public void visitLeave(final Author author) throws ModuleDataException {
319  1 checkContext();
320    }
321   
 
322  1 toggle public void visitLeave(final AuthorList authorList) throws ModuleDataException {
323  1 checkContext();
324    }
325   
 
326  12 toggle public void visitLeave(final Axiom axiom) throws ModuleDataException {
327  12 checkContext();
328    }
329   
 
330  8 toggle public void visitLeave(final Chapter chapter) throws ModuleDataException {
331  8 checkContext();
332    }
333   
 
334  1 toggle public void visitLeave(final ChapterList chapterList) throws ModuleDataException {
335  1 checkContext();
336    }
337   
 
338  88 toggle public void visitLeave(final Formula formula) throws ModuleDataException {
339  88 checkContext();
340    }
341   
 
342  16 toggle public void visitLeave(final FunctionDefinition functionDefinition) throws ModuleDataException {
343  16 checkContext();
344    }
345   
 
346  1 toggle public void visitLeave(final Header header) throws ModuleDataException {
347  1 checkContext();
348    }
349   
 
350  1 toggle public void visitLeave(final Import imp) throws ModuleDataException {
351  1 checkContext();
352    }
353   
 
354  1 toggle public void visitLeave(final ImportList importList) throws ModuleDataException {
355  1 checkContext();
356    }
357   
 
358  527 toggle public void visitLeave(final Latex latex) throws ModuleDataException {
359  527 checkContext();
360    }
361   
 
362  269 toggle public void visitLeave(final LatexList latexList) throws ModuleDataException {
363  269 checkContext();
364    }
365   
 
366  1 toggle public void visitLeave(final LinkList linkList) throws ModuleDataException {
367  1 checkContext();
368    }
369   
 
370  3 toggle public void visitLeave(final LiteratureItem literatureItem) throws ModuleDataException {
371  3 checkContext();
372    }
373   
 
374  1 toggle public void visitLeave(final LiteratureItemList literatureItemList) throws ModuleDataException {
375  1 checkContext();
376    }
377   
 
378  3 toggle public void visitLeave(final Location location) throws ModuleDataException {
379  3 checkContext();
380    }
381   
 
382  2 toggle public void visitLeave(final LocationList locationList) throws ModuleDataException {
383  2 checkContext();
384    }
385   
 
386  90 toggle public void visitLeave(final Node authorList) throws ModuleDataException {
387  90 checkContext();
388    }
389   
 
390  6 toggle public void visitLeave(final PredicateDefinition predicateDefinition)
391    throws ModuleDataException {
392  6 checkContext();
393    }
394   
 
395  0 toggle public void visitLeave(final FormalProofList formalProofList) throws ModuleDataException {
396  0 checkContext();
397    }
398   
 
399  0 toggle public void visitLeave(final FormalProofLine formalProof) throws ModuleDataException {
400  0 checkContext();
401    }
402   
 
403  0 toggle public void visitLeave(final FormalProof proof) throws ModuleDataException {
404  0 checkContext();
405    }
406   
 
407  0 toggle public void visitLeave(final Reason reason) throws ModuleDataException {
408  0 checkContext();
409    }
410   
 
411  0 toggle public void visitLeave(final FormalProofLineList formalProofLineList) throws ModuleDataException {
412  0 checkContext();
413    }
414   
 
415  0 toggle public void visitLeave(final ModusPonens reason) throws ModuleDataException {
416  0 checkContext();
417    }
418   
 
419  0 toggle public void visitLeave(final Add reason) throws ModuleDataException {
420  0 checkContext();
421    }
422   
 
423  0 toggle public void visitLeave(final Rename reason) throws ModuleDataException {
424  0 checkContext();
425    }
426   
 
427  0 toggle public void visitLeave(final SubstFree reason) throws ModuleDataException {
428  0 checkContext();
429    }
430   
 
431  0 toggle public void visitLeave(final SubstFunc reason) throws ModuleDataException {
432  0 checkContext();
433    }
434   
 
435  0 toggle public void visitLeave(final SubstPred reason) throws ModuleDataException {
436  0 checkContext();
437    }
438   
 
439  0 toggle public void visitLeave(final Existential reason) throws ModuleDataException {
440  0 checkContext();
441    }
442   
 
443  0 toggle public void visitLeave(final Universal reason) throws ModuleDataException {
444  0 checkContext();
445    }
446   
 
447  0 toggle public void visitLeave(final ConditionalProof reason) throws ModuleDataException {
448  0 checkContext();
449    }
450   
 
451  0 toggle public void visitLeave(final Hypothesis hypothesis) throws ModuleDataException {
452  0 checkContext();
453    }
454   
 
455  0 toggle public void visitLeave(final Conclusion conclusion) throws ModuleDataException {
456  0 checkContext();
457    }
458   
 
459  18 toggle public void visitLeave(final Proof proof) throws ModuleDataException {
460  18 checkContext();
461    }
462   
 
463  17 toggle public void visitLeave(final ProofList proofList) throws ModuleDataException {
464  17 checkContext();
465    }
466   
 
467  54 toggle public void visitLeave(final Proposition proposition) throws ModuleDataException {
468  54 checkContext();
469    }
470   
 
471  1 toggle public void visitLeave(final Qedeq qedeq) throws ModuleDataException {
472  1 checkContext();
473    }
474   
 
475  1 toggle public void visitLeave(final Rule rule) throws ModuleDataException {
476  1 checkContext();
477    }
478   
 
479  22 toggle public void visitLeave(final Section section) throws ModuleDataException {
480  22 checkContext();
481    }
482   
 
483  5 toggle public void visitLeave(final SectionList sectionList) throws ModuleDataException {
484  5 checkContext();
485    }
486   
 
487  2 toggle public void visitLeave(final Specification specification) throws ModuleDataException {
488  2 checkContext();
489    }
490   
 
491  2 toggle public void visitLeave(final Subsection subsection) throws ModuleDataException {
492  2 checkContext();
493    }
494   
 
495  14 toggle public void visitLeave(final SubsectionList subsectionList) throws ModuleDataException {
496  14 checkContext();
497    }
498   
 
499  0 toggle public void visitLeave(final SubsectionType subsectionType) throws ModuleDataException {
500  0 checkContext();
501    }
502   
 
503  0 toggle public void visitLeave(final Term term) throws ModuleDataException {
504  0 checkContext();
505    }
506   
 
507  0 toggle public void visitLeave(final UsedByList usedByList) throws ModuleDataException {
508  0 checkContext();
509    }
510   
 
511  1263 toggle public void visitLeave(final Atom atom) throws ModuleDataException {
512  1263 checkContext();
513    }
514   
 
515  1516 toggle public void visitLeave(final ElementList list) throws ModuleDataException {
516  1516 checkContext();
517    }
518   
 
519  0 toggle public void visitEnter(InitialFunctionDefinition functionDefinition)
520    throws ModuleDataException {
521  0 checkContext();
522    }
523   
 
524  1 toggle public void visitEnter(InitialPredicateDefinition predicateDefinition)
525    throws ModuleDataException {
526  1 checkContext();
527    }
528   
 
529  0 toggle public void visitLeave(InitialFunctionDefinition functionDefinition)
530    throws ModuleDataException {
531  0 checkContext();
532    }
533   
 
534  1 toggle public void visitLeave(InitialPredicateDefinition predicateDefinition)
535    throws ModuleDataException {
536  1 checkContext();
537    }
538   
 
539  0 toggle public void visitEnter(ChangedRuleList list) throws ModuleDataException {
540  0 checkContext();
541    }
542   
 
543  0 toggle public void visitEnter(ChangedRule rule) throws ModuleDataException {
544  0 checkContext();
545    }
546   
 
547  0 toggle public void visitLeave(ChangedRuleList list) throws ModuleDataException {
548  0 checkContext();
549    }
550   
 
551  0 toggle public void visitLeave(ChangedRule rule) throws ModuleDataException {
552  0 checkContext();
553    }
554   
 
555  7896 toggle private void checkContext() throws ModuleDataException {
556  7896 final String context = traverser.getCurrentContext().getLocationWithinModule();
557  7896 try {
558  7896 Trace.param(CLASS, "checkContext()",
559    "context > ", context);
560  7896 if (context.length() > 0) {
561  7894 DynamicGetter.get(qedeq, context);
562    }
563    } catch (RuntimeException e) {
564  0 System.err.println(context);
565  0 throw e;
566    } catch (IllegalAccessException e) {
567  0 throw new RuntimeException(e);
568    } catch (InvocationTargetException e) {
569  0 throw new RuntimeException(e);
570    }
571   
572  7896 SimpleXPath xpath = Context2SimpleXPath.getXPath(traverser.getCurrentContext(), qedeq);
573  7896 Trace.param(CLASS, "checkContext()",
574    "xpath < ", xpath);
575  7896 final SourceArea find = XPathLocationParser.findSourceArea(moduleFile,
576    xpath);
577  7896 if (find.getStartPosition() == null) {
578  0 System.out.println(traverser.getCurrentContext());
579  0 throw new RuntimeException("start not found: " + find + "\ncontext: "
580    + context);
581    }
582  7896 if (find.getEndPosition() == null) {
583  0 System.out.println(traverser.getCurrentContext());
584  0 throw new RuntimeException("end not found: " + find + "\ncontext: "
585    + context);
586    }
587    }
588   
589    }