Package: SequenceTraceNode

SequenceTraceNode

nameinstructionbranchcomplexitylinemethod
SequenceTraceNode()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
add(TraceNode)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
get(int)
M: 72 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%
getTests()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
size()
M: 93 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 23 C: 0
0%
M: 1 C: 0
0%
toString()
M: 32 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (C) 2008, 2009 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.codegen.runtime.traces;
25:
26: import java.util.HashMap;
27: import java.util.List;
28: import java.util.Map;
29: import java.util.Vector;
30:
31: public class SequenceTraceNode extends TraceNode implements IIterableTraceNode
32: {
33:         private Map<Integer, Integer[]> indics;
34:
35:         public List<TraceNode> nodes;
36:
37:         public void add(TraceNode node)
38:         {
39:                 nodes.add(node);
40:         }
41:
42:         public SequenceTraceNode()
43:         {
44:                 this.nodes = new Vector<TraceNode>();
45:         }
46:
47:         @Override
48:         public CallSequence get(int index)
49:         {
50:•                if (indics == null)
51:                 {
52:                         size();
53:                 }
54:                 Integer[] select = indics.get(index);
55:
56:                 CallSequence seq = getVars();
57:
58:                 List<TestSequence> nodetests = new Vector<TestSequence>();
59:                 int count = nodes.size();
60:
61:•                for (TraceNode node : nodes)
62:                 {
63:                         TestSequence nt = node.getTests();
64:                         nodetests.add(nt);
65:                 }
66:
67:•                for (int i = 0; i < count; i++)
68:                 {
69:                         TestSequence ith = nodetests.get(i);
70:
71:•                        if (!ith.isEmpty())
72:                         {
73:                                 CallSequence subseq = ith.get(select[i]);
74:                                 seq.addAll(subseq);
75:                         }
76:                 }
77:                 return seq;
78:         }
79:
80:         @Override
81:         public TestSequence getTests()
82:         {
83:                 return new LazyTestSequence(this);
84:         }
85:
86:         @Override
87:         public int size()
88:         {
89:•                if (indics != null)
90:                 {
91:                         return indics.size();
92:                 }
93:
94:                 indics = new HashMap<Integer, Integer[]>();
95:
96:                 List<TestSequence> nodetests = new Vector<TestSequence>();
97:                 int count = nodes.size();
98:                 int[] sizes = new int[count];
99:                 int n = 0;
100:
101:•                for (TraceNode node : nodes)
102:                 {
103:                         TestSequence nt = node.getTests();
104:                         nodetests.add(nt);
105:                         sizes[n++] = nt.size();
106:                 }
107:
108:                 int size = 0;
109:
110:                 Permutor p = new Permutor(sizes);
111:
112:•                while (p.hasNext())
113:                 {
114:                         int[] next = p.next();
115:
116:                         Integer[] select = new Integer[next.length];
117:•                        for (int i = 0; i < next.length; i++)
118:                         {
119:                                 select[i] = next[i];
120:                         }
121:                         indics.put(size, select);
122:                         size++;
123:                 }
124:
125:                 return size;
126:         }
127:
128:         @Override
129:         public String toString()
130:         {
131:                 StringBuilder sb = new StringBuilder();
132:                 String sep = "";
133:
134:•                for (TraceNode node : nodes)
135:                 {
136:                         sb.append(sep);
137:                         sb.append(node.toString());
138:                         sep = "; ";
139:                 }
140:
141:                 return sb.toString();
142:         }
143: }