Mirror of the JODE repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
jode/jode/test/src/net/sf/jode/bytecode/BlockTest.java

44 lines
1.2 KiB

package net.sf.jode.bytecode;
import junit.framework.*;
import java.io.*;
public class BlockTest extends TestCase implements Opcodes {
public BlockTest(String name) {
super(name);
}
public void testJsr() {
Block b1 = new Block();
Block b2 = new Block();
Instruction jsr = Instruction.forOpcode(opc_jsr);
b1.setCode(new Instruction[] { jsr }, new Block[] { b2, null } );
assertEquals("pop", 0, b1.maxpop);
assertEquals("push", 0, b1.maxpush);
assertEquals("delta", 0, b1.delta);
try {
b1.setCode(new Instruction[] { jsr }, new Block[] { b2 });
fail("jsr must have two successors");
} catch (IllegalArgumentException ex) {
}
try {
b1.setCode(new Instruction[] { jsr },
new Block[] { null, b2 });
fail("jsr succ mustn't be null");
} catch (IllegalArgumentException ex) {
}
try {
b1.setCode(new Instruction[] { jsr,
Instruction.forOpcode(opc_nop) },
new Block[] { null, b2 });
fail("jsr must be last in block");
} catch (IllegalArgumentException ex) {
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new BlockTest("testJsr"));
return suite;
}
}