Testcase generation tool for combinatorial interaction testing
Revision | 952a25fd0cbfbab8452446f6562867fe2e1e87cc (tree) |
---|---|
Time | 2015-10-16 14:12:00 |
Author | t-tutiya <tatsuhiro@ieee...> |
Commiter | t-tutiya |
Support arithmetic comparator !===
Add a TreeSet to represent constrained parameters
@@ -224,8 +224,10 @@ public class Inputer { | ||
224 | 224 | if (t.peepToken() == null) { |
225 | 225 | break; |
226 | 226 | } |
227 | - Node n = new Parse(t, parameterList).parseExpression(); | |
228 | - constraintList.add(n); | |
227 | + //Node n = new Parse(t, parameterList).parseExpression(); | |
228 | + NodeAndConstrainedParameters res = new Parse(t, parameterList).extendedParseExpression(); | |
229 | + constraintList.add(res.node); | |
230 | + System.err.println(res.constrainedParameters.toString()); | |
229 | 231 | } |
230 | 232 | return constraintList; |
231 | 233 | } |
@@ -1,17 +1,34 @@ | ||
1 | 1 | package v1; |
2 | 2 | |
3 | -import java.util.ArrayList; | |
4 | 3 | import java.util.List; |
4 | +import java.util.TreeSet; | |
5 | + | |
6 | +class NodeAndConstrainedParameters { | |
7 | + Node node; | |
8 | + TreeSet<Integer> constrainedParameters; | |
9 | +} | |
5 | 10 | |
6 | 11 | public class Parse { |
7 | 12 | private TokenHandler t; |
8 | 13 | private PList parameterList; |
9 | 14 | |
15 | + private TreeSet<Integer> constrainedParameters = new TreeSet<Integer>(); | |
16 | + | |
10 | 17 | Parse(TokenHandler t, PList parameterList) { |
11 | 18 | this.t = t; |
12 | 19 | this.parameterList = parameterList; |
20 | + | |
21 | + // extension to .. | |
22 | + this.constrainedParameters = new TreeSet<Integer>(); | |
13 | 23 | } |
14 | 24 | |
25 | + public NodeAndConstrainedParameters extendedParseExpression() { | |
26 | + NodeAndConstrainedParameters res = new NodeAndConstrainedParameters(); | |
27 | + res.node = parseExpression(); | |
28 | + res.constrainedParameters = this.constrainedParameters; | |
29 | + return res; | |
30 | + } | |
31 | + | |
15 | 32 | public Node parseExpression() { |
16 | 33 | String nextToken = t.peepToken(); |
17 | 34 | try { |
@@ -19,8 +36,11 @@ public class Parse { | ||
19 | 36 | Error.printError(Main.language == Main.Language.JP ? "制約式に誤りがあります" |
20 | 37 | : "Invalid constraints"); |
21 | 38 | return null; |
22 | - } else if (nextToken.equals("(")) | |
39 | + } | |
40 | + else if (nextToken.equals("(")) { | |
41 | + // debug: System.err.println(this.constrainedParameters.toString()); | |
23 | 42 | return expressionWithParentheses(); |
43 | + } | |
24 | 44 | else { |
25 | 45 | // error |
26 | 46 | Error.printError(Main.language == Main.Language.JP ? "制約に'('がありません" |
@@ -178,28 +198,38 @@ public class Parse { | ||
178 | 198 | else if (token.equals("<>")) |
179 | 199 | return inequalityAtomExpression(); |
180 | 200 | else if (token.equals("===")) |
181 | - return artithmeticEqualityAtomExpression(new EqualTo(), new EqualTo()); | |
201 | + return arithmeticEqualityAtomExpression(new EqualTo(), new EqualTo()); | |
202 | + else if (token.equals("!==")) | |
203 | + return artithmeticInequalityAtomExpression(new EqualTo(), new EqualTo()); | |
182 | 204 | else if (token.equals("<")) |
183 | - return artithmeticEqualityAtomExpression(new LessThan(), new GreaterThan()); | |
205 | + return arithmeticEqualityAtomExpression(new LessThan(), new GreaterThan()); | |
184 | 206 | else if (token.equals(">")) |
185 | - return artithmeticEqualityAtomExpression(new GreaterThan(), new LessThan()); | |
207 | + return arithmeticEqualityAtomExpression(new GreaterThan(), new LessThan()); | |
186 | 208 | else if (token.equals("<=")) |
187 | - return artithmeticEqualityAtomExpression(new LTE(), new GTE()); | |
209 | + return arithmeticEqualityAtomExpression(new LTE(), new GTE()); | |
188 | 210 | else if (token.equals(">=")) |
189 | - return artithmeticEqualityAtomExpression(new GTE(), new LTE()); | |
211 | + return arithmeticEqualityAtomExpression(new GTE(), new LTE()); | |
190 | 212 | else |
191 | 213 | Error.printError(Main.language == Main.Language.JP ? "制約式に == か <> が必要です" |
192 | 214 | : "== or <> expected in constraints"); |
193 | 215 | return null; |
194 | 216 | } |
195 | 217 | |
218 | + private Node artithmeticInequalityAtomExpression(RelationOverDoublePair com1, | |
219 | + RelationOverDoublePair com2) throws OutOfTokenStreamException { | |
220 | + // TODO Auto-generated method stub | |
221 | + BooleanUnaryOperator res = new NotOperator(); | |
222 | + res.Child = arithmeticEqualityAtomExpression(com1, com2); | |
223 | + return res; | |
224 | + } | |
225 | + | |
196 | 226 | private Node inequalityAtomExpression() throws OutOfTokenStreamException { |
197 | 227 | BooleanUnaryOperator res = new NotOperator(); |
198 | 228 | res.Child = equalityAtomExpression(); |
199 | 229 | return res; |
200 | 230 | } |
201 | 231 | |
202 | - private Node artithmeticEqualityAtomExpression(RelationOverDoublePair com1, RelationOverDoublePair com2) | |
232 | + private Node arithmeticEqualityAtomExpression(RelationOverDoublePair com1, RelationOverDoublePair com2) | |
203 | 233 | throws OutOfTokenStreamException { |
204 | 234 | // case 1 val1 val2 com1 |
205 | 235 | // case 2 val1 [para1] com2 |
@@ -353,6 +383,7 @@ public class Parse { | ||
353 | 383 | // 因子名が正しいかチェック |
354 | 384 | try { |
355 | 385 | parameterID = parameterList.getID(para); |
386 | + this.constrainedParameters.add(parameterID); | |
356 | 387 | } catch (NoParameterNameException e) { |
357 | 388 | Error.printError(Main.language == Main.Language.JP ? "制約中の因子名に誤りがあります" |
358 | 389 | : "Invalid parameter name in constraints"); |
@@ -396,6 +427,7 @@ public class Parse { | ||
396 | 427 | // 因子名が正しいかチェック |
397 | 428 | try { |
398 | 429 | parameterID = parameterList.getID(para); |
430 | + this.constrainedParameters.add(parameterID); | |
399 | 431 | } catch (NoParameterNameException e) { |
400 | 432 | Error.printError(Main.language == Main.Language.JP ? "制約中の因子名に誤りがあります" |
401 | 433 | : "Invalid parameter name in constraints"); |
@@ -447,6 +479,8 @@ public class Parse { | ||
447 | 479 | try { |
448 | 480 | parameterID1 = parameterList.getID(para1); |
449 | 481 | parameterID2 = parameterList.getID(para2); |
482 | + this.constrainedParameters.add(parameterID1); | |
483 | + this.constrainedParameters.add(parameterID2); | |
450 | 484 | } catch (NoParameterNameException e) { |
451 | 485 | Error.printError(Main.language == Main.Language.JP ? "制約中の因子名に誤りがあります" |
452 | 486 | : "Invalid parameter name in constraints"); |
@@ -523,6 +557,8 @@ public class Parse { | ||
523 | 557 | try { |
524 | 558 | parameterID1 = parameterList.getID(para1); |
525 | 559 | parameterID2 = parameterList.getID(para2); |
560 | + this.constrainedParameters.add(parameterID1); | |
561 | + this.constrainedParameters.add(parameterID2); | |
526 | 562 | } catch (NoParameterNameException e) { |
527 | 563 | Error.printError(Main.language == Main.Language.JP ? "制約中の因子名に誤りがあります" |
528 | 564 | : "Invalid parameter name in constraints"); |