use of org.neo4j.codegen.CodeBlock in project neo4j by neo4j.
the class ByteCodeVerifierTest method shouldVerifyBytecode.
@Test
public void shouldVerifyBytecode() throws Throwable {
// given
CodeGenerator generator = generateCode(BYTECODE, VERIFY_GENERATED_BYTECODE);
ClassHandle handle;
try (ClassGenerator clazz = generator.generateClass(PACKAGE, "SimpleClass");
CodeBlock code = clazz.generateMethod(Integer.class, "box", param(int.class, "value"))) {
handle = clazz.handle();
code.returns(code.load("value"));
}
// when
try {
handle.loadClass();
fail("Should have thrown exception");
}// then
catch (CompilationFailureException expected) {
assertThat(expected.toString(), containsString("box(I)"));
}
}
Aggregations