Package: OutputTestBase

OutputTestBase

nameinstructionbranchcomplexitylinemethod
OutputTestBase(String, String, String)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
buildClassList(List)
M: 9 C: 26
74%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 6
86%
M: 0 C: 1
100%
buildModulesList(List)
M: 9 C: 26
74%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 6
86%
M: 0 C: 1
100%
init()
M: 10 C: 27
73%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 9
90%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.tests.output.util;
2:
3: import java.io.File;
4: import java.util.LinkedList;
5: import java.util.List;
6:
7: import org.junit.Assert;
8: import org.junit.Before;
9: import org.overture.ast.definitions.SClassDefinition;
10: import org.overture.ast.lex.Dialect;
11: import org.overture.ast.modules.AModuleModules;
12: import org.overture.ast.node.INode;
13: import org.overture.codegen.utils.GeneralCodeGenUtils;
14: import org.overture.config.Release;
15: import org.overture.config.Settings;
16:
17: abstract public class OutputTestBase extends SpecificationTestBase
18: {
19:         public OutputTestBase(String nameParameter, String inputParameter,
20:                         String resultParameter)
21:         {
22:                 super(nameParameter, inputParameter, resultParameter);
23:         }
24:
25:         @Before
26:         public void init()
27:         {
28:                 File f = new File(modelPath);
29:
30:•                if (GeneralCodeGenUtils.isVdmPpSourceFile(f))
31:                 {
32:                         Settings.dialect = Dialect.VDM_PP;
33:•                } else if (GeneralCodeGenUtils.isVdmSlSourceFile(f))
34:                 {
35:                         Settings.dialect = Dialect.VDM_SL;
36:•                } else if (GeneralCodeGenUtils.isVdmRtSourceFile(f))
37:                 {
38:                         Settings.dialect = Dialect.VDM_RT;
39:                 } else
40:                 {
41:                         Assert.fail("The file does not have a valid VDM source file extension. Got: "
42:                                         + modelPath);
43:                 }
44:
45:                 Settings.release = Release.VDM_10;
46:         }
47:
48:         public List<AModuleModules> buildModulesList(List<INode> ast)
49:         {
50:                 List<AModuleModules> modules = new LinkedList<AModuleModules>();
51:
52:•                for (INode c : ast)
53:                 {
54:•                        if (c instanceof AModuleModules)
55:                         {
56:                                 modules.add((AModuleModules) c);
57:                         } else
58:                         {
59:                                 Assert.fail("Expected only modules got " + c);
60:                         }
61:                 }
62:                 return modules;
63:         }
64:
65:         public List<SClassDefinition> buildClassList(List<INode> ast)
66:         {
67:                 List<SClassDefinition> classes = new LinkedList<SClassDefinition>();
68:
69:•                for (INode c : ast)
70:                 {
71:•                        if (c instanceof SClassDefinition)
72:                         {
73:                                 classes.add((SClassDefinition) c);
74:                         } else
75:                         {
76:                                 Assert.fail("Expected only classes got " + c);
77:                         }
78:                 }
79:                 return classes;
80:         }
81:
82:         abstract protected String getUpdatePropertyString();
83: }