diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/CastCounterTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/CastCounterTest.java index 63b9a2fae65..4fa62fb9c11 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/CastCounterTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/CastCounterTest.java @@ -8,6 +8,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import sootup.core.jimple.basic.Local; import sootup.core.model.Body; import sootup.core.types.*; import sootup.core.util.Utils; @@ -38,10 +39,10 @@ public void setup() { public void testInvokeStmt() { final Body.BodyBuilder builder = createMethodsBuilder("invokeStmt", "void"); Map map = new HashMap<>(); - map.put("l0", classType); - map.put("l1", super1); - map.put("l2", PrimitiveType.getInt()); - map.put("l3", sub2); + map.put("$l0", classType); + map.put("$l1", super1); + map.put("$l2", PrimitiveType.getInt()); + map.put("$l3", sub2); map.put("$stack4", sub1); map.put("$stack5", sub2); Typing typing = createTyping(builder.getLocals(), map); @@ -69,9 +70,9 @@ public void testInvokeStmt() { public void testAssignStmt() { final Body.BodyBuilder builder = createMethodsBuilder("assignStmt", "void"); Map map = new HashMap<>(); - map.put("l0", classType); - map.put("l1", Type.createArrayType(super1, 1)); - map.put("l2", super1); + map.put("$l0", classType); + map.put("$l1", Type.createArrayType(super1, 1)); + map.put("$l2", super1); map.put("$stack3", sub1); Typing typing = createTyping(builder.getLocals(), map); CastCounter counter = new CastCounter(builder, function, hierarchy); @@ -88,13 +89,16 @@ public void testAssignStmt() { public void testInvokeStmtWithNewCasts() { final Body.BodyBuilder builder = createMethodsBuilder("invokeStmt", "void"); Map map = new HashMap<>(); - map.put("l0", classType); - map.put("l1", super1); - map.put("l2", PrimitiveType.getLong()); - map.put("l3", super2); + map.put("$l0", classType); + map.put("$l1", super1); + map.put("$l2", PrimitiveType.getLong()); + map.put("$l3", super2); map.put("$stack4", sub1); map.put("$stack5", sub2); - Typing typing = createTyping(builder.getLocals(), map); + + final Set locals = builder.getLocals(); + + Typing typing = createTyping(locals, map); CastCounter counter = new CastCounter(builder, function, hierarchy); Assert.assertEquals(3, counter.getCastCount(typing)); counter.insertCastStmts(typing); @@ -129,9 +133,9 @@ public void testInvokeStmtWithNewCasts() { public void testAssignStmtWithNewCasts() { final Body.BodyBuilder builder = createMethodsBuilder("assignStmt", "void"); Map map = new HashMap<>(); - map.put("l0", classType); - map.put("l1", object); - map.put("l2", super1); + map.put("$l0", classType); + map.put("$l1", object); + map.put("$l2", super1); map.put("$stack3", sub1); Typing typing = createTyping(builder.getLocals(), map); diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java index 04b1859ea70..7354e1655bd 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/interceptors/typeresolving/TypeAssignerTestSuite.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import org.junit.Assert; import sootup.core.jimple.basic.Local; import sootup.core.model.Body; import sootup.core.signatures.MethodSignature; @@ -51,6 +52,14 @@ public Body.BodyBuilder createMethodsBuilder(String methodName, String returnTyp } public Typing createTyping(Set locals, Map map) { + + final Optional foundOpt = + locals.stream() + .filter(local -> !map.containsKey(local.toString())) + .peek(i -> System.out.println("TEST: missing mapping for: " + i)) + .findAny(); + Assert.assertFalse(foundOpt.isPresent()); + Typing typing = new Typing(locals); for (Local l : typing.getLocals()) { if (map.containsKey(l.getName())) {