misc. cleanups
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@801 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
ce3a554146
commit
001c9f8142
|
@ -10,6 +10,6 @@ Require-Bundle:
|
|||
com.ibm.wala.cast,
|
||||
com.ibm.wala.core,
|
||||
org.junit
|
||||
Eclipse-AutoStart: true
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: com.ibm.wala.cast.test
|
||||
|
||||
|
|
|
@ -27,28 +27,31 @@ import junit.framework.*;
|
|||
public class TestCAstPattern extends WalaTestCase {
|
||||
|
||||
private static final int NAME_ASSERTION_SINGLE = 501;
|
||||
|
||||
private static final int NAME_ASSERTION_MULTI = 502;
|
||||
|
||||
|
||||
private static class TestingCAstImpl extends CAstImpl {
|
||||
private final Map testNameMap = new HashMap();
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CAstNode makeNode(int kind, CAstNode children[]) {
|
||||
if (kind == NAME_ASSERTION_SINGLE || kind == NAME_ASSERTION_MULTI) {
|
||||
Assertions._assert(children.length == 2);
|
||||
Assertions._assert(children[0].getValue() instanceof String);
|
||||
CAstNode result = children[1];
|
||||
if (kind == NAME_ASSERTION_SINGLE) {
|
||||
testNameMap.put(children[0].getValue(), children[1]);
|
||||
} else {
|
||||
if (! testNameMap.containsKey(children[0].getValue())) {
|
||||
testNameMap.put(children[0].getValue(), new ArrayList());
|
||||
}
|
||||
Assertions._assert(children.length == 2);
|
||||
Assertions._assert(children[0].getValue() instanceof String);
|
||||
@SuppressWarnings("unused")
|
||||
CAstNode result = children[1];
|
||||
if (kind == NAME_ASSERTION_SINGLE) {
|
||||
testNameMap.put(children[0].getValue(), children[1]);
|
||||
} else {
|
||||
if (!testNameMap.containsKey(children[0].getValue())) {
|
||||
testNameMap.put(children[0].getValue(), new ArrayList());
|
||||
}
|
||||
|
||||
((List)testNameMap.get(children[0].getValue())).add( children[1] );
|
||||
}
|
||||
return children[1];
|
||||
((List) testNameMap.get(children[0].getValue())).add(children[1]);
|
||||
}
|
||||
return children[1];
|
||||
} else {
|
||||
return super.makeNode(kind, children);
|
||||
return super.makeNode(kind, children);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,49 +66,36 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
} else {
|
||||
Segments s = CAstPattern.match(p, n);
|
||||
Assert.assertTrue(s != null);
|
||||
for(Iterator ns = names.keySet().iterator(); ns.hasNext(); ) {
|
||||
String nm = (String)ns.next();
|
||||
Object o = names.get(nm);
|
||||
if (o instanceof CAstNode) {
|
||||
Trace.println(
|
||||
"found " + CAstPrinter.print(s.getSingle(nm)) + " for " + nm);
|
||||
Assert.assertTrue(
|
||||
"for name " + nm + ": expected " + names.get(nm) +
|
||||
" but got " + s.getSingle(nm),
|
||||
names.get(nm).equals(s.getSingle(nm)));
|
||||
} else {
|
||||
for(Iterator cs = s.getMultiple(nm).iterator(); cs.hasNext(); ) {
|
||||
Trace.println(
|
||||
"found "+CAstPrinter.print((CAstNode)cs.next())+" for "+nm);
|
||||
}
|
||||
Assert.assertTrue(
|
||||
"for name " + nm + ": expected " + names.get(nm) +
|
||||
" but got " + s.getMultiple(nm),
|
||||
names.get(nm).equals(s.getMultiple(nm)));
|
||||
}
|
||||
for (Iterator ns = names.keySet().iterator(); ns.hasNext();) {
|
||||
String nm = (String) ns.next();
|
||||
Object o = names.get(nm);
|
||||
if (o instanceof CAstNode) {
|
||||
Trace.println("found " + CAstPrinter.print(s.getSingle(nm)) + " for " + nm);
|
||||
Assert.assertTrue("for name " + nm + ": expected " + names.get(nm) + " but got " + s.getSingle(nm), names.get(nm).equals(
|
||||
s.getSingle(nm)));
|
||||
} else {
|
||||
for (Iterator cs = s.getMultiple(nm).iterator(); cs.hasNext();) {
|
||||
Trace.println("found " + CAstPrinter.print((CAstNode) cs.next()) + " for " + nm);
|
||||
}
|
||||
Assert.assertTrue("for name " + nm + ": expected " + names.get(nm) + " but got " + s.getMultiple(nm), names.get(nm)
|
||||
.equals(s.getMultiple(nm)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final CAstPattern simpleNamePattern =
|
||||
CAstPattern.parse("<top>BINARY_EXPR(\"+\",<left>\"prefix\",\"suffix\")");
|
||||
private final CAstPattern simpleNamePattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",<left>\"prefix\",\"suffix\")");
|
||||
|
||||
private final CAstNode simpleNameAst;
|
||||
|
||||
private final Map simpleNameMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleNameAst =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("left"),
|
||||
Ast.makeConstant("prefix")),
|
||||
Ast.makeConstant("suffix")));
|
||||
simpleNameAst = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("left"), Ast.makeConstant("prefix")), Ast
|
||||
.makeConstant("suffix")));
|
||||
|
||||
simpleNameMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -114,24 +104,18 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(simpleNamePattern, simpleNameAst, simpleNameMap);
|
||||
}
|
||||
|
||||
private final CAstPattern simpleStarNamePattern =
|
||||
CAstPattern.parse("<top>BINARY_EXPR(\"+\",*,<right>\"suffix\")");
|
||||
private final CAstPattern simpleStarNamePattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",*,<right>\"suffix\")");
|
||||
|
||||
private final CAstNode simpleStarNameAst;
|
||||
|
||||
private final Map simpleStarNameMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleStarNameAst =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeConstant("prefix"),
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("right"),
|
||||
Ast.makeConstant("suffix"))));
|
||||
simpleStarNameAst = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeConstant("prefix"), Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("right"), Ast
|
||||
.makeConstant("suffix"))));
|
||||
|
||||
simpleStarNameMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -140,25 +124,18 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(simpleStarNamePattern, simpleStarNameAst, simpleStarNameMap);
|
||||
}
|
||||
|
||||
|
||||
private final CAstPattern simpleRepeatedPattern =
|
||||
CAstPattern.parse("<top>BINARY_EXPR(\"+\",<children>@(VAR(*))@)");
|
||||
private final CAstPattern simpleRepeatedPattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",<children>@(VAR(*))@)");
|
||||
|
||||
private final CAstNode simpleRepeatedAstOne;
|
||||
|
||||
private final Map simpleRepeatedMapOne;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleRepeatedAstOne =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix")))));
|
||||
simpleRepeatedAstOne = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("suffix")))));
|
||||
|
||||
simpleRepeatedMapOne = Ast.testNameMap;
|
||||
}
|
||||
|
@ -168,24 +145,16 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
}
|
||||
|
||||
private final CAstNode simpleRepeatedAstTwo;
|
||||
|
||||
private final Map simpleRepeatedMapTwo;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleRepeatedAstTwo =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("prefix"))),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix")))));
|
||||
simpleRepeatedAstTwo = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("prefix"))), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("suffix")))));
|
||||
|
||||
simpleRepeatedMapTwo = Ast.testNameMap;
|
||||
}
|
||||
|
@ -195,28 +164,17 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
}
|
||||
|
||||
private final CAstNode simpleRepeatedAstThree;
|
||||
|
||||
private final Map simpleRepeatedMapThree;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleRepeatedAstThree =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("prefix"))),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("middle"))),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix")))));
|
||||
simpleRepeatedAstThree = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("prefix"))), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("middle"))), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("suffix")))));
|
||||
|
||||
simpleRepeatedMapThree = Ast.testNameMap;
|
||||
}
|
||||
|
@ -225,29 +183,19 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(simpleRepeatedPattern, simpleRepeatedAstThree, simpleRepeatedMapThree);
|
||||
}
|
||||
|
||||
|
||||
private final CAstPattern simpleDoubleStarPattern =
|
||||
CAstPattern.parse("<top>BINARY_EXPR(\"+\",<children>**)");
|
||||
private final CAstPattern simpleDoubleStarPattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",<children>**)");
|
||||
|
||||
private final CAstNode simpleDoubleStarAst;
|
||||
|
||||
private final Map simpleDoubleStarMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleDoubleStarAst =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("prefix"))),
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("children"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix")))));
|
||||
simpleDoubleStarAst = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("prefix"))), Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("children"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("suffix")))));
|
||||
|
||||
simpleDoubleStarMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -256,26 +204,19 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(simpleDoubleStarPattern, simpleDoubleStarAst, simpleDoubleStarMap);
|
||||
}
|
||||
|
||||
private final CAstPattern simpleAlternativePattern =
|
||||
CAstPattern.parse("<top>BINARY_EXPR(\"+\",<firstchild>|(VAR(\"suffix\")||VAR(\"prefix\"))|,*)");
|
||||
private final CAstPattern simpleAlternativePattern = CAstPattern
|
||||
.parse("<top>BINARY_EXPR(\"+\",<firstchild>|(VAR(\"suffix\")||VAR(\"prefix\"))|,*)");
|
||||
|
||||
private final CAstNode simpleAlternativeAst;
|
||||
|
||||
private final Map simpleAlternativeMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleAlternativeAst =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("firstchild"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("prefix"))),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix"))));
|
||||
simpleAlternativeAst = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("firstchild"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("prefix"))), Ast.makeNode(CAstNode.VAR, Ast.makeConstant("suffix"))));
|
||||
|
||||
simpleAlternativeMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -284,27 +225,19 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(simpleAlternativePattern, simpleAlternativeAst, simpleAlternativeMap);
|
||||
}
|
||||
|
||||
|
||||
private final CAstPattern simpleOptionalPattern =
|
||||
CAstPattern.parse("<top>BINARY_EXPR(\"+\",?(VAR(\"prefix\"))?,<child>VAR(\"suffix\"))");
|
||||
private final CAstPattern simpleOptionalPattern = CAstPattern
|
||||
.parse("<top>BINARY_EXPR(\"+\",?(VAR(\"prefix\"))?,<child>VAR(\"suffix\"))");
|
||||
|
||||
private final CAstNode simpleOptionalAstWith;
|
||||
|
||||
private final Map simpleOptionalMapWith;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleOptionalAstWith =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("prefix")),
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("child"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix")))));
|
||||
simpleOptionalAstWith = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeConstant("prefix")), Ast.makeNode(NAME_ASSERTION_SINGLE, Ast
|
||||
.makeConstant("child"), Ast.makeNode(CAstNode.VAR, Ast.makeConstant("suffix")))));
|
||||
|
||||
simpleOptionalMapWith = Ast.testNameMap;
|
||||
}
|
||||
|
@ -314,20 +247,15 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
}
|
||||
|
||||
private final CAstNode simpleOptionalAstNot;
|
||||
|
||||
private final Map simpleOptionalMapNot;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
simpleOptionalAstNot =
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("top"),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(NAME_ASSERTION_SINGLE,
|
||||
Ast.makeConstant("child"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeConstant("suffix")))));
|
||||
simpleOptionalAstNot = Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("top"), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(NAME_ASSERTION_SINGLE, Ast.makeConstant("child"), Ast.makeNode(CAstNode.VAR, Ast
|
||||
.makeConstant("suffix")))));
|
||||
|
||||
simpleOptionalMapNot = Ast.testNameMap;
|
||||
}
|
||||
|
@ -336,30 +264,20 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(simpleOptionalPattern, simpleOptionalAstNot, simpleOptionalMapNot);
|
||||
}
|
||||
|
||||
|
||||
private final String recursiveTreeStr =
|
||||
"|({leaf}|(<const>CONSTANT()||VAR(<vars>*))|||{node}BINARY_EXPR(\"+\",`leaf`,|(`leaf`||`node`)|))|";
|
||||
private final String recursiveTreeStr = "|({leaf}|(<const>CONSTANT()||VAR(<vars>*))|||{node}BINARY_EXPR(\"+\",`leaf`,|(`leaf`||`node`)|))|";
|
||||
|
||||
private final CAstPattern recursiveTreePattern =
|
||||
CAstPattern.parse( recursiveTreeStr );
|
||||
private final CAstPattern recursiveTreePattern = CAstPattern.parse(recursiveTreeStr);
|
||||
|
||||
private final CAstNode recursiveTreeOneAst;
|
||||
|
||||
private final Map recursiveTreeOneMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
recursiveTreeOneAst =
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("x"))),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("y"))));
|
||||
recursiveTreeOneAst = Ast.makeNode(CAstNode.BINARY_EXPR, Ast.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("x"))), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("y"))));
|
||||
|
||||
recursiveTreeOneMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -369,28 +287,17 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
}
|
||||
|
||||
private final CAstNode recursiveTreeTwoAst;
|
||||
|
||||
private final Map recursiveTreeTwoMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
recursiveTreeTwoAst =
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("x"))),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("y"))),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("z")))));
|
||||
recursiveTreeTwoAst = Ast.makeNode(CAstNode.BINARY_EXPR, Ast.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("x"))), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast
|
||||
.makeConstant("y"))), Ast.makeNode(CAstNode.VAR, Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast
|
||||
.makeConstant("z")))));
|
||||
|
||||
recursiveTreeTwoMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -400,46 +307,21 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
}
|
||||
|
||||
private final CAstNode recursiveTreeFiveAst;
|
||||
|
||||
private final Map recursiveTreeFiveMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
recursiveTreeFiveAst =
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("u"))),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("v"))),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("w"))),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("x"))),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("y"))),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("z"))))))));
|
||||
recursiveTreeFiveAst = Ast.makeNode(CAstNode.BINARY_EXPR, Ast.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("u"))), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast
|
||||
.makeConstant("v"))), Ast.makeNode(CAstNode.BINARY_EXPR, Ast.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("w"))), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast
|
||||
.makeConstant("x"))), Ast.makeNode(CAstNode.BINARY_EXPR, Ast.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("y"))), Ast.makeNode(CAstNode.VAR, Ast.makeNode(
|
||||
NAME_ASSERTION_MULTI, Ast.makeConstant("vars"), Ast.makeConstant("z"))))))));
|
||||
|
||||
recursiveTreeFiveMap = Ast.testNameMap;
|
||||
}
|
||||
|
@ -448,8 +330,8 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(recursiveTreePattern, recursiveTreeFiveAst, recursiveTreeFiveMap);
|
||||
}
|
||||
|
||||
private final CAstPattern buggyRecursiveTreePattern =
|
||||
CAstPattern.parse("|({leaf}|(<const>CONSTANT()||VAR(<vars>*))|||{node}BINARY_EXPR(\"+\",`leaf`,`node`))|");
|
||||
private final CAstPattern buggyRecursiveTreePattern = CAstPattern
|
||||
.parse("|({leaf}|(<const>CONSTANT()||VAR(<vars>*))|||{node}BINARY_EXPR(\"+\",`leaf`,`node`))|");
|
||||
|
||||
public void testBuggyRecursiveTreeOne() {
|
||||
test(buggyRecursiveTreePattern, recursiveTreeOneAst, null);
|
||||
|
@ -463,11 +345,10 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
test(buggyRecursiveTreePattern, recursiveTreeFiveAst, null);
|
||||
}
|
||||
|
||||
private static final String extraTestsStr =
|
||||
"BINARY_EXPR(|(\"==\"||\"\\==\")|,|(CONSTANT()||VAR(CONSTANT()))|,|(CONSTANT()||VAR(CONSTANT()))|)";
|
||||
private static final String extraTestsStr = "BINARY_EXPR(|(\"==\"||\"\\==\")|,|(CONSTANT()||VAR(CONSTANT()))|,|(CONSTANT()||VAR(CONSTANT()))|)";
|
||||
|
||||
private final CAstPattern testedTreePattern =
|
||||
CAstPattern.parse("{top}|("+recursiveTreeStr+"||BINARY_EXPR(\",\","+extraTestsStr+",`top`))|");
|
||||
private final CAstPattern testedTreePattern = CAstPattern.parse("{top}|(" + recursiveTreeStr + "||BINARY_EXPR(\",\","
|
||||
+ extraTestsStr + ",`top`))|");
|
||||
|
||||
public void testTestedTreeOne() {
|
||||
test(testedTreePattern, recursiveTreeOneAst, recursiveTreeOneMap);
|
||||
|
@ -482,28 +363,17 @@ public class TestCAstPattern extends WalaTestCase {
|
|||
}
|
||||
|
||||
private final CAstNode testedTreeOneAst;
|
||||
|
||||
private final Map testedTreeOneMap;
|
||||
|
||||
{
|
||||
TestingCAstImpl Ast = new TestingCAstImpl();
|
||||
|
||||
testedTreeOneAst =
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant(","),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("=="),
|
||||
Ast.makeNode(CAstNode.VAR, Ast.makeConstant("x")),
|
||||
Ast.makeConstant(7)),
|
||||
Ast.makeNode(CAstNode.BINARY_EXPR,
|
||||
Ast.makeConstant("+"),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("x"))),
|
||||
Ast.makeNode(CAstNode.VAR,
|
||||
Ast.makeNode(NAME_ASSERTION_MULTI,
|
||||
Ast.makeConstant("vars"),
|
||||
Ast.makeConstant("y")))));
|
||||
testedTreeOneAst = Ast.makeNode(CAstNode.BINARY_EXPR, Ast.makeConstant(","), Ast.makeNode(CAstNode.BINARY_EXPR, Ast
|
||||
.makeConstant("=="), Ast.makeNode(CAstNode.VAR, Ast.makeConstant("x")), Ast.makeConstant(7)), Ast.makeNode(
|
||||
CAstNode.BINARY_EXPR, Ast.makeConstant("+"), Ast.makeNode(CAstNode.VAR, Ast.makeNode(NAME_ASSERTION_MULTI, Ast
|
||||
.makeConstant("vars"), Ast.makeConstant("x"))), Ast.makeNode(CAstNode.VAR, Ast.makeNode(NAME_ASSERTION_MULTI, Ast
|
||||
.makeConstant("vars"), Ast.makeConstant("y")))));
|
||||
|
||||
testedTreeOneMap = Ast.testNameMap;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue