@Test public void test(){ List<BytecodeInstruction> blockNode= new ArrayList<>(); BytecodeInstruction stmt1 = testingUtils.mockNewStatement(className,"reverse()"); BytecodeInstruction stmt2 = testingUtils.mockNewStatement(className,"sum()"); blockNode.add(stmt1); blockNode.add(stmt2); InterproceduralBasicBlock interproceduralBasicBlock = new InterproceduralBasicBlock(BotsingTestGenerationContext.getInstance().getClassLoaderForSUT(),className, "sum()",blockNode); try{ interproceduralBasicBlock.appendInstruction(null); }catch (IllegalArgumentException e){ assertTrue(e.getMessage().contains("The given instruction is null")); } try{ interproceduralBasicBlock.appendInstruction(stmt1); }catch (IllegalArgumentException e){ assertTrue(e.getMessage().contains("a basic block can not contain the same element twice")); } }
@Override protected boolean appendInstruction(BytecodeInstruction instruction){ if (instruction == null){ throw new IllegalArgumentException("The given instruction is null"); } if (instruction.hasBasicBlockSet()){ LOG.debug("existing basic block: {}", instruction.getBasicBlock().explain()); LOG.debug("current basic block: {}", this.explain()); LOG.debug("DUPLICATE BASIC BLOCK: {} {} {} -- {}", instruction.getClassName(), instruction.getMethodName(),instruction.getLineNumber(),instruction.explain()); } if (this.instructions.contains(instruction)){ throw new IllegalArgumentException("a basic block can not contain the same element twice"); } instruction.basicBlock = this; return this.instructions.add(instruction); }
InterproceduralBasicBlock extends BasicBlock { @Override protected boolean appendInstruction(BytecodeInstruction instruction){ if (instruction == null){ throw new IllegalArgumentException("The given instruction is null"); } if (instruction.hasBasicBlockSet()){ LOG.debug("existing basic block: {}", instruction.getBasicBlock().explain()); LOG.debug("current basic block: {}", this.explain()); LOG.debug("DUPLICATE BASIC BLOCK: {} {} {} -- {}", instruction.getClassName(), instruction.getMethodName(),instruction.getLineNumber(),instruction.explain()); } if (this.instructions.contains(instruction)){ throw new IllegalArgumentException("a basic block can not contain the same element twice"); } instruction.basicBlock = this; return this.instructions.add(instruction); } }
InterproceduralBasicBlock extends BasicBlock { @Override protected boolean appendInstruction(BytecodeInstruction instruction){ if (instruction == null){ throw new IllegalArgumentException("The given instruction is null"); } if (instruction.hasBasicBlockSet()){ LOG.debug("existing basic block: {}", instruction.getBasicBlock().explain()); LOG.debug("current basic block: {}", this.explain()); LOG.debug("DUPLICATE BASIC BLOCK: {} {} {} -- {}", instruction.getClassName(), instruction.getMethodName(),instruction.getLineNumber(),instruction.explain()); } if (this.instructions.contains(instruction)){ throw new IllegalArgumentException("a basic block can not contain the same element twice"); } instruction.basicBlock = this; return this.instructions.add(instruction); } InterproceduralBasicBlock(ClassLoader classLoader, String className, String methodName, List<BytecodeInstruction> blockNodes); }
InterproceduralBasicBlock extends BasicBlock { @Override protected boolean appendInstruction(BytecodeInstruction instruction){ if (instruction == null){ throw new IllegalArgumentException("The given instruction is null"); } if (instruction.hasBasicBlockSet()){ LOG.debug("existing basic block: {}", instruction.getBasicBlock().explain()); LOG.debug("current basic block: {}", this.explain()); LOG.debug("DUPLICATE BASIC BLOCK: {} {} {} -- {}", instruction.getClassName(), instruction.getMethodName(),instruction.getLineNumber(),instruction.explain()); } if (this.instructions.contains(instruction)){ throw new IllegalArgumentException("a basic block can not contain the same element twice"); } instruction.basicBlock = this; return this.instructions.add(instruction); } InterproceduralBasicBlock(ClassLoader classLoader, String className, String methodName, List<BytecodeInstruction> blockNodes);  }
InterproceduralBasicBlock extends BasicBlock { @Override protected boolean appendInstruction(BytecodeInstruction instruction){ if (instruction == null){ throw new IllegalArgumentException("The given instruction is null"); } if (instruction.hasBasicBlockSet()){ LOG.debug("existing basic block: {}", instruction.getBasicBlock().explain()); LOG.debug("current basic block: {}", this.explain()); LOG.debug("DUPLICATE BASIC BLOCK: {} {} {} -- {}", instruction.getClassName(), instruction.getMethodName(),instruction.getLineNumber(),instruction.explain()); } if (this.instructions.contains(instruction)){ throw new IllegalArgumentException("a basic block can not contain the same element twice"); } instruction.basicBlock = this; return this.instructions.add(instruction); } InterproceduralBasicBlock(ClassLoader classLoader, String className, String methodName, List<BytecodeInstruction> blockNodes);   }