Package: TestSequence$TestData

TestSequence$TestData

nameinstructionbranchcomplexitylinemethod
TestSequence.TestData(TestSequence, CallSequence, int, int)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

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.interpreter.traces;
25:
26: import java.util.Iterator;
27: import java.util.List;
28: import java.util.Vector;
29:
30: import org.overture.ast.util.Utils;
31:
32: @SuppressWarnings("serial")
33: public class TestSequence extends Vector<CallSequence>
34: {
35:         private class TestData
36:         {
37:                 public final int index;
38:                 public final int stem;
39:                 public final CallSequence test;
40:
41:                 public TestData(CallSequence test, int stem, int index)
42:                 {
43:                         this.test = test;
44:                         this.stem = stem;
45:                         this.index = index;
46:                 }
47:         }
48:
49:         final List<TestData> failedCallSeqs = new Vector<TestData>();
50:
51:         /**
52:          * Filter remaining tests based on one set of results. The result list passed in is the result of running the test,
53:          * which is the n'th test in the TestSequence (from 1 - size).
54:          *
55:          * @param result
56:          * @param test
57:          * @param n
58:          */
59:         public void filter(List<Object> result, CallSequence test, int n)
60:         {
61:                 if (result.get(result.size() - 1) != Verdict.PASSED)
62:                 {
63:                         int stem = result.size() - 1;
64:                         failedCallSeqs.add(new TestData(test, stem, n));
65:                 }
66:         }
67:
68:         @Override
69:         public synchronized Iterator<CallSequence> iterator()
70:         {
71:                 return new Iterator<CallSequence>()
72:                 {
73:                         Iterator<CallSequence> itr = TestSequence.this.iterator();
74:
75:                         @Override
76:                         public boolean hasNext()
77:                         {
78:                                 return itr.hasNext();
79:                         }
80:
81:                         @Override
82:                         public CallSequence next()
83:                         {
84:                                 CallSequence other = itr.next();
85:
86:                                 markFiltered(other);
87:
88:                                 return other;
89:                         }
90:
91:                         @Override
92:                         public void remove()
93:                         {
94:
95:                         }
96:                 };
97:         }
98:
99:         /**
100:          * Mark a call sequence filtered if a call sequence failed that is the prefix of this one
101:          *
102:          * @param other
103:          */
104:         protected void markFiltered(CallSequence other)
105:         {
106:                 for (TestData testData : TestSequence.this.failedCallSeqs)
107:                 {
108:                         if (other.compareStem(testData.test, testData.stem))
109:                         {
110:                                 other.setFilter(testData.index);
111:                                 return;
112:                         }
113:                 }
114:         }
115:
116:         @Override
117:         public String toString()
118:         {
119:                 return Utils.listToString(this, "\n");
120:         }
121:
122: }