Package: ConcurrentTraceNode

ConcurrentTraceNode

nameinstructionbranchcomplexitylinemethod
ConcurrentTraceNode()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
get(int)
M: 6 C: 130
96%
M: 4 C: 14
78%
M: 4 C: 6
60%
M: 3 C: 31
91%
M: 0 C: 1
100%
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: 4 C: 101
96%
M: 1 C: 9
90%
M: 1 C: 5
83%
M: 1 C: 25
96%
M: 0 C: 1
100%
toString()
M: 40 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2010 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.interpreter.traces;
25:
26: import java.util.HashMap;
27: import java.util.List;
28: import java.util.Map;
29: import java.util.Vector;
30:
31: import org.overture.interpreter.traces.util.LazyTestSequence;
32: import org.overture.interpreter.traces.util.Pair;
33:
34: public class ConcurrentTraceNode extends TraceNode implements
35:                 IIterableTraceNode
36: {
37:         private Map<Integer, Pair<Integer, Integer>> indics;
38:         public List<TraceNode> nodes;
39:
40:         public ConcurrentTraceNode()
41:         {
42:                 nodes = new Vector<TraceNode>();
43:         }
44:
45:         @Override
46:         public CallSequence get(int index)
47:         {
48:•                if (indics == null)
49:                 {
50:                         size();
51:                 }
52:                 Pair<Integer, Integer> v = indics.get(index);
53:
54:                 List<TestSequence> nodetests = new Vector<TestSequence>();
55:                 int count = nodes.size();
56:
57:•                for (TraceNode node : nodes)
58:                 {
59:                         nodetests.add(node.getTests());
60:                 }
61:
62:                 PermuteArray pa = new PermuteArray(count);
63:
64:                 int r = 0;
65:
66:•                while (pa.hasNext())
67:                 {
68:                         int[] perm = pa.next();
69:                         r++;
70:•                        if (r < v.first)
71:                         {
72:                                 continue;
73:                         }
74:                         
75:                         int[] sizes = new int[count];
76:
77:•                        for (int i = 0; i < count; i++)
78:                         {
79:                                 sizes[i] = nodetests.get(perm[i]).size();
80:                         }
81:
82:                         Permutor p = new Permutor(sizes);
83:
84:                         int j = 0;
85:•                        while (p.hasNext())
86:                         {
87:                                 int[] select = p.next();
88:                                 j++;
89:•                                if(j < v.second)
90:                                 {
91:                                         continue;
92:                                 }
93:                                 CallSequence seq = getVariables();
94:
95:•                                for (int i = 0; i < count; i++)
96:                                 {
97:                                         TestSequence ith = nodetests.get(perm[i]);
98:
99:•                                        if (!ith.isEmpty())
100:                                         {
101:                                                 CallSequence subseq = ith.get(select[i]);
102:                                                 seq.addAll(subseq);
103:                                         }
104:                                 }
105:
106:                                 return seq;
107:                         }
108:                 }
109:
110:                 return null;
111:         }
112:
113:         @Override
114:         public TestSequence getTests()
115:         {
116:                 return new LazyTestSequence(this);
117:         }
118:
119:         @Override
120:         public int size()
121:         {
122:•                if (indics != null)
123:                 {
124:                         return indics.size();
125:                 }
126:
127:                 indics = new HashMap<Integer, Pair<Integer, Integer>>();
128:
129:                 int size = 0;
130:
131:                 List<TestSequence> nodetests = new Vector<TestSequence>();
132:                 int count = nodes.size();
133:
134:•                for (TraceNode node : nodes)
135:                 {
136:                         nodetests.add(node.getTests());
137:                 }
138:
139:                 PermuteArray pa = new PermuteArray(count);
140:
141:                 int r = 0;
142:•                while (pa.hasNext())
143:                 {
144:                         r++;
145:                         int[] sizes = new int[count];
146:                         int[] perm = pa.next();
147:
148:•                        for (int i = 0; i < count; i++)
149:                         {
150:                                 sizes[i] = nodetests.get(perm[i]).size();
151:                         }
152:
153:                         Permutor p = new Permutor(sizes);
154:
155:                         int j = 0;
156:•                        while (p.hasNext())
157:                         {
158:                                 j++;
159:                                 p.next();
160:                                 indics.put(size, new Pair<Integer, Integer>(r, j));
161:                                 size++;
162:                         }
163:                 }
164:
165:                 return size;
166:         }
167:
168:         @Override
169:         public String toString()
170:         {
171:                 StringBuilder sb = new StringBuilder();
172:                 sb.append("|| (");
173:                 String sep = "";
174:
175:•                for (TraceNode node : nodes)
176:                 {
177:                         sb.append(sep);
178:                         sb.append(node.toString());
179:                         sep = ", ";
180:                 }
181:
182:                 sb.append(")");
183:                 return sb.toString();
184:         }
185: }