more flows-to tests
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3765 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
f6afa934f8
commit
24caeb7088
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
/**
|
||||
* @author manu
|
||||
*
|
||||
*/
|
||||
public class FlowsToTestArraySetIter {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ArraySet s1 = new ArraySet();
|
||||
ArraySet s2 = new ArraySet();
|
||||
s1.add(new FlowsToType());
|
||||
s2.add(new B());
|
||||
A a = (A) s1.iterator().next();
|
||||
B b = (B) s2.iterator().next();
|
||||
TestUtil.makeVarUsed(b);
|
||||
TestUtil.makeVarUsed(a);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
/**
|
||||
* @author manu
|
||||
*
|
||||
*/
|
||||
public class FlowsToTestFields {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Object o1 = new FlowsToType();
|
||||
Object o2 = new Object();
|
||||
A a1 = new A();
|
||||
A a2 = new A();
|
||||
a1.f = o1;
|
||||
a2.f = o2;
|
||||
Object o3 = a1.f;
|
||||
Object o4 = a2.f;
|
||||
TestUtil.makeVarUsed(o3);
|
||||
TestUtil.makeVarUsed(o4);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
/**
|
||||
* @author manu
|
||||
*
|
||||
*/
|
||||
public class FlowsToTestFieldsHarder {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Object o1 = new FlowsToType();
|
||||
A a1 = new A();
|
||||
a1.f = o1;
|
||||
A a2 = new A();
|
||||
a2.f = a1;
|
||||
A a3 = (A) a2.f;
|
||||
Object o2 = a3.f;
|
||||
TestUtil.makeVarUsed(o2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author manu
|
||||
*
|
||||
*/
|
||||
public class FlowsToTestHashSet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
HashSet s1 = new HashSet();
|
||||
HashSet s2 = new HashSet();
|
||||
s1.add(new FlowsToType());
|
||||
s2.add(new Object());
|
||||
Object o1 = s1.iterator().next();
|
||||
Object o2 = s2.iterator().next();
|
||||
TestUtil.makeVarUsed(o1);
|
||||
TestUtil.makeVarUsed(o2);
|
||||
}
|
||||
}
|
|
@ -234,7 +234,9 @@ public abstract class AbstractPtrTest {
|
|||
// TODO Auto-generated method stub
|
||||
TypeReference flowsToTypeRef = TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff
|
||||
.deployment2CanonicalTypeString("demandpa.FlowsToType"));
|
||||
for (NewSiteReference n : Iterator2Iterable.make(mainMethod.getIR().iterateNewSites())) {
|
||||
final IR mainIR = mainMethod.getIR();
|
||||
// System.err.println(mainIR);
|
||||
for (NewSiteReference n : Iterator2Iterable.make(mainIR.iterateNewSites())) {
|
||||
if (n.getDeclaredType().equals(flowsToTypeRef)) {
|
||||
return heapModel.getInstanceKeyForAllocation(mainMethod, n);
|
||||
}
|
||||
|
|
|
@ -130,4 +130,25 @@ public class NoRefinePtrTest extends AbstractPtrTest {
|
|||
public void testFlowsToId() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doFlowsToSizeTest(TestInfo.FLOWSTO_TEST_ID, 8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowsToFields() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doFlowsToSizeTest(TestInfo.FLOWSTO_TEST_FIELDS, 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowsToFieldsHarder() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doFlowsToSizeTest(TestInfo.FLOWSTO_TEST_FIELDS_HARDER, 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlowsToArraySetIter() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doFlowsToSizeTest(TestInfo.FLOWSTO_TEST_ARRAYSET_ITER, 8);
|
||||
}
|
||||
|
||||
// don't test this until we have a way to handle different library versions
|
||||
// @Test
|
||||
// public void testFlowsToHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
// doFlowsToSizeTest(TestInfo.FLOWSTO_TEST_HASHSET, 8);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -99,4 +99,12 @@ public class TestInfo {
|
|||
|
||||
public static final String FLOWSTO_TEST_ID = "Ldemandpa/FlowsToTestId";
|
||||
|
||||
public static final String FLOWSTO_TEST_FIELDS = "Ldemandpa/FlowsToTestFields";
|
||||
|
||||
public static final String FLOWSTO_TEST_FIELDS_HARDER = "Ldemandpa/FlowsToTestFieldsHarder";
|
||||
|
||||
public static final String FLOWSTO_TEST_ARRAYSET_ITER = "Ldemandpa/FlowsToTestArraySetIter";
|
||||
|
||||
public static final String FLOWSTO_TEST_HASHSET = "Ldemandpa/FlowsToTestHashSet";
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue