2007-02-02 17:29:34 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright (c) 2002 - 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*****************************************************************************/
|
|
|
|
package com.ibm.wala.cast.test;
|
|
|
|
|
2007-07-11 21:07:13 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
2017-03-18 02:04:17 +00:00
|
|
|
import org.junit.Assert;
|
2009-07-27 22:48:04 +00:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2007-07-11 21:07:13 +00:00
|
|
|
import com.ibm.wala.cast.tree.CAstNode;
|
|
|
|
import com.ibm.wala.cast.tree.impl.CAstImpl;
|
2007-02-02 17:29:34 +00:00
|
|
|
import com.ibm.wala.cast.util.CAstPattern;
|
2007-07-11 21:07:13 +00:00
|
|
|
import com.ibm.wala.cast.util.CAstPattern.Segments;
|
2011-04-03 04:08:05 +00:00
|
|
|
import com.ibm.wala.cast.util.CAstPrinter;
|
2007-02-02 17:29:34 +00:00
|
|
|
import com.ibm.wala.core.tests.util.WalaTestCase;
|
|
|
|
|
|
|
|
public class TestCAstPattern extends WalaTestCase {
|
|
|
|
|
|
|
|
private static final int NAME_ASSERTION_SINGLE = 501;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
2007-02-02 17:29:34 +00:00
|
|
|
private static final int NAME_ASSERTION_MULTI = 502;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
2007-02-02 17:29:34 +00:00
|
|
|
private static class TestingCAstImpl extends CAstImpl {
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> testNameMap = new HashMap<>();
|
2007-02-27 18:17:38 +00:00
|
|
|
|
2013-06-25 15:57:37 +00:00
|
|
|
@Override
|
2007-02-27 18:17:38 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
2007-02-02 17:29:34 +00:00
|
|
|
public CAstNode makeNode(int kind, CAstNode children[]) {
|
|
|
|
if (kind == NAME_ASSERTION_SINGLE || kind == NAME_ASSERTION_MULTI) {
|
2009-04-30 13:16:52 +00:00
|
|
|
assert children.length == 2;
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
final Object child0Value = children[0].getValue();
|
|
|
|
assert child0Value instanceof String;
|
|
|
|
final String name = (String) child0Value;
|
2007-02-27 18:17:38 +00:00
|
|
|
@SuppressWarnings("unused")
|
|
|
|
CAstNode result = children[1];
|
|
|
|
if (kind == NAME_ASSERTION_SINGLE) {
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
testNameMap.put(name, children[1]);
|
2007-02-27 18:17:38 +00:00
|
|
|
} else {
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
if (!testNameMap.containsKey(name)) {
|
|
|
|
testNameMap.put(name, new ArrayList<>());
|
2007-02-27 18:17:38 +00:00
|
|
|
}
|
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
((List<CAstNode>) testNameMap.get(children[0].getValue())).add(children[1]);
|
2007-02-27 18:17:38 +00:00
|
|
|
}
|
|
|
|
return children[1];
|
2007-02-02 17:29:34 +00:00
|
|
|
} else {
|
2007-02-27 18:17:38 +00:00
|
|
|
return super.makeNode(kind, children);
|
2007-02-02 17:29:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private static void test(CAstPattern p, CAstNode n, Map<String, Object> names) {
|
2009-04-09 20:31:14 +00:00
|
|
|
System.err.println(("testing pattern " + p));
|
|
|
|
System.err.println(("testing with input " + CAstPrinter.print(n)));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
if (names == null) {
|
|
|
|
Assert.assertFalse(p.match(n, null));
|
|
|
|
} else {
|
|
|
|
Segments s = CAstPattern.match(p, n);
|
|
|
|
Assert.assertTrue(s != null);
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
for (String nm : names.keySet()) {
|
2007-02-27 18:17:38 +00:00
|
|
|
Object o = names.get(nm);
|
|
|
|
if (o instanceof CAstNode) {
|
2009-04-09 20:31:14 +00:00
|
|
|
System.err.println(("found " + CAstPrinter.print(s.getSingle(nm)) + " for " + nm));
|
2007-02-27 18:17:38 +00:00
|
|
|
Assert.assertTrue("for name " + nm + ": expected " + names.get(nm) + " but got " + s.getSingle(nm), names.get(nm).equals(
|
|
|
|
s.getSingle(nm)));
|
|
|
|
} else {
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
for (CAstNode node : s.getMultiple(nm)) {
|
|
|
|
System.err.println(("found " + CAstPrinter.print(node) + " for " + nm));
|
2007-02-27 18:17:38 +00:00
|
|
|
}
|
|
|
|
Assert.assertTrue("for name " + nm + ": expected " + names.get(nm) + " but got " + s.getMultiple(nm), names.get(nm)
|
|
|
|
.equals(s.getMultiple(nm)));
|
|
|
|
}
|
2007-02-02 17:29:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern simpleNamePattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",<left>\"prefix\",\"suffix\")");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode simpleNameAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleNameMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleNameMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleName() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleNamePattern, simpleNameAst, simpleNameMap);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern simpleStarNamePattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",*,<right>\"suffix\")");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode simpleStarNameAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleStarNameMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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"))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleStarNameMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleStarName() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleStarNamePattern, simpleStarNameAst, simpleStarNameMap);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern simpleRepeatedPattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",<children>@(VAR(*))@)");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode simpleRepeatedAstOne;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleRepeatedMapOne;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleRepeatedMapOne = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleRepeatedOne() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleRepeatedPattern, simpleRepeatedAstOne, simpleRepeatedMapOne);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CAstNode simpleRepeatedAstTwo;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleRepeatedMapTwo;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleRepeatedMapTwo = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleRepeatedTwo() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleRepeatedPattern, simpleRepeatedAstTwo, simpleRepeatedMapTwo);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CAstNode simpleRepeatedAstThree;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleRepeatedMapThree;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleRepeatedMapThree = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleRepeatedThree() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleRepeatedPattern, simpleRepeatedAstThree, simpleRepeatedMapThree);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern simpleDoubleStarPattern = CAstPattern.parse("<top>BINARY_EXPR(\"+\",<children>**)");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode simpleDoubleStarAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleDoubleStarMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleDoubleStarMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleDoubleStar() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleDoubleStarPattern, simpleDoubleStarAst, simpleDoubleStarMap);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern simpleAlternativePattern = CAstPattern
|
|
|
|
.parse("<top>BINARY_EXPR(\"+\",<firstchild>|(VAR(\"suffix\")||VAR(\"prefix\"))|,*)");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode simpleAlternativeAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleAlternativeMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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"))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleAlternativeMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleAlternative() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleAlternativePattern, simpleAlternativeAst, simpleAlternativeMap);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern simpleOptionalPattern = CAstPattern
|
|
|
|
.parse("<top>BINARY_EXPR(\"+\",?(VAR(\"prefix\"))?,<child>VAR(\"suffix\"))");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode simpleOptionalAstWith;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleOptionalMapWith;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleOptionalMapWith = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleOptionalWith() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleOptionalPattern, simpleOptionalAstWith, simpleOptionalMapWith);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CAstNode simpleOptionalAstNot;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> simpleOptionalMapNot;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
simpleOptionalMapNot = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testSimpleOptionalNot() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(simpleOptionalPattern, simpleOptionalAstNot, simpleOptionalMapNot);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final String recursiveTreeStr = "|({leaf}|(<const>CONSTANT()||VAR(<vars>*))|||{node}BINARY_EXPR(\"+\",`leaf`,|(`leaf`||`node`)|))|";
|
2007-02-02 17:29:34 +00:00
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern recursiveTreePattern = CAstPattern.parse(recursiveTreeStr);
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
private final CAstNode recursiveTreeOneAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> recursiveTreeOneMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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"))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
recursiveTreeOneMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testRecursiveTreeOne() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(recursiveTreePattern, recursiveTreeOneAst, recursiveTreeOneMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CAstNode recursiveTreeTwoAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> recursiveTreeTwoMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
recursiveTreeTwoMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testRecursiveTreeTwo() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(recursiveTreePattern, recursiveTreeTwoAst, recursiveTreeTwoMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CAstNode recursiveTreeFiveAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> recursiveTreeFiveMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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"))))))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
recursiveTreeFiveMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testRecursiveTreeFive() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(recursiveTreePattern, recursiveTreeFiveAst, recursiveTreeFiveMap);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern buggyRecursiveTreePattern = CAstPattern
|
|
|
|
.parse("|({leaf}|(<const>CONSTANT()||VAR(<vars>*))|||{node}BINARY_EXPR(\"+\",`leaf`,`node`))|");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testBuggyRecursiveTreeOne() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(buggyRecursiveTreePattern, recursiveTreeOneAst, null);
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testBuggyRecursiveTreeTwo() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(buggyRecursiveTreePattern, recursiveTreeTwoAst, null);
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testBuggyRecursiveTreeFive() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(buggyRecursiveTreePattern, recursiveTreeFiveAst, null);
|
|
|
|
}
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private static final String extraTestsStr = "BINARY_EXPR(|(\"==\"||\"\\==\")|,|(CONSTANT()||VAR(CONSTANT()))|,|(CONSTANT()||VAR(CONSTANT()))|)";
|
2007-02-02 17:29:34 +00:00
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
private final CAstPattern testedTreePattern = CAstPattern.parse("{top}|(" + recursiveTreeStr + "||BINARY_EXPR(\",\","
|
|
|
|
+ extraTestsStr + ",`top`))|");
|
2007-02-02 17:29:34 +00:00
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testTestedTreeOne() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(testedTreePattern, recursiveTreeOneAst, recursiveTreeOneMap);
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testTestedTreeTwo() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(testedTreePattern, recursiveTreeTwoAst, recursiveTreeTwoMap);
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testTestedTreeFive() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(testedTreePattern, recursiveTreeFiveAst, recursiveTreeFiveMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final CAstNode testedTreeOneAst;
|
2007-02-27 18:17:38 +00:00
|
|
|
|
Fix nearly all Eclipse warnings about using raw types
Along the way, I also converted many "for (;;)" loops into modern
"for (:)" loops. I didn't systematically look for all opportunities
to do this, though. I merely made this change where I was already
converting raw Iterator uses into modern Iterator<...> uses.
Better use of generics also allowed many casts to become statically
redundant. I have removed all such redundant casts.
Only three raw-types warnings remain after this batch of fixes. All
three involve raw uses of CallGraphBuilder. I've tried to fix these
too, but it quickly snowballs into a cascade of changes that may or
may not eventually reach a statically-type-save fixed point. I may
give these last few problem areas another go in the future. For now,
though, the hundreds of other fixes seem worth keeping even if there
are a few stragglers.
This commit may change some public APIs, but only by making weaker
type signatures stronger by replacing raw types with generic types.
For example, we may change something like "Set" into "Set<String>",
but we're not adding new arguments, changing any
underlying (post-generics-erasure) types, etc.
2017-07-09 18:38:35 +00:00
|
|
|
private final Map<String, Object> testedTreeOneMap;
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestingCAstImpl Ast = new TestingCAstImpl();
|
|
|
|
|
2007-02-27 18:17:38 +00:00
|
|
|
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")))));
|
2007-02-02 17:29:34 +00:00
|
|
|
|
|
|
|
testedTreeOneMap = Ast.testNameMap;
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:48:04 +00:00
|
|
|
@Test public void testTestedTreeOneWithTest() {
|
2007-02-02 17:29:34 +00:00
|
|
|
test(testedTreePattern, testedTreeOneAst, testedTreeOneMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|