### Question:
DeadRemovalStrategy implements OptimizationStrategy { List<Integer> getDeadAssignmentAddresses() { return addresses.stream().filter(this::isDeadAssignment).collect(Collectors.toList()); } DeadRemovalStrategy(ExecutionGraphManipulator manipulator); @Override Map<String, Integer> getOptimizationCounts(); @Override boolean perform(); void setRemoveWeak(boolean removeWeak);  }### Answer:
@Test public void doesNotDetectAssignmentReassignedInOnlyOneMultiverse() { String methodName = "reassignedInOnlyOneMultiverse(I)I"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAssignmentAddresses(); Collections.sort(found); List<Integer> expected = new LinkedList<Integer>(); assertEquals(expected, found); }
@Test public void detectsUnusedResultOfMethodInvocationWithSideEffects() { String methodName = "unusedResultWithSideEffects()I"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAssignmentAddresses(); List<Integer> expected = new LinkedList<Integer>(); assertEquals(expected, found); }
@Test public void doesNotDetectMoveOpWithOnlyOneRegisterReassigned() { String methodName = "moveP0IntoV0With30Locals(I)V"; ExecutionGraphManipulator manipulator = getOptimizedGraph(methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAssignmentAddresses(); assertEquals(0, found.size()); }
@Test public void detectsDeadTryCatchBlock() { String methodName = "deadTryCatchBlock()V"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAssignmentAddresses(); List<Integer> expected = Collections.singletonList(0); assertEquals(expected, found); }
@Test public void detectsMoveResultWithUnusedAssignment() { ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, "moveResult()Ljava/lang/String;", MethodState.ResultRegister, "some string", "Ljava/lang/String;"); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAssignmentAddresses(); List<Integer> expected = Arrays.asList(3, 7); assertEquals(expected, found); }
@Test public void detectsUnusedAssignment() { String methodName = "unusedAssignment()I"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAssignmentAddresses(); List<Integer> expected = Collections.singletonList(0); assertEquals(expected, found); }