use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class PrimitiveWideningDelegateTrivialTest method testNoOpAssignment.
@Test
public void testNoOpAssignment() throws Exception {
StackManipulation stackManipulation = PrimitiveWideningDelegate.forPrimitive(sourceTypeDescription).widenTo(targetTypeDescription);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(0));
assertThat(size.getMaximalSize(), is(0));
verify(sourceTypeDescription, atLeast(1)).represents(sourceType);
verify(targetTypeDescription, atLeast(1)).represents(sourceType);
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class VoidAwareAssignerNonVoidToVoidTest method testAssignDefaultValue.
private void testAssignDefaultValue(boolean dynamicallyTyped) throws Exception {
Assigner voidAwareAssigner = new VoidAwareAssigner(chainedAssigner);
StackManipulation stackManipulation = voidAwareAssigner.assign(source, target, Assigner.Typing.of(dynamicallyTyped));
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(-1 * StackSize.of(sourceType).getSize()));
assertThat(size.getMaximalSize(), is(0));
verify(methodVisitor).visitInsn(opcode);
verifyNoMoreInteractions(methodVisitor);
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class VoidAwareAssignerVoidToNonVoidTest method testAssignNoDefaultValue.
@Test(expected = IllegalStateException.class)
public void testAssignNoDefaultValue() throws Exception {
Assigner voidAwareAssigner = new VoidAwareAssigner(chainedAssigner);
StackManipulation stackManipulation = voidAwareAssigner.assign(source, target, Assigner.Typing.STATIC);
assertThat(stackManipulation.isValid(), is(false));
stackManipulation.apply(methodVisitor, implementationContext);
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethodDynamic.
@Test
public void testGenericMethodDynamic() throws Exception {
TypeDescription genericErasure = mock(TypeDescription.class);
when(methodReturnType.asErasure()).thenReturn(genericErasure);
when(declaredMethod.isBootstrap()).thenReturn(true);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).dynamic(FOO, otherType, Collections.<TypeDescription>emptyList(), Collections.emptyList());
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is(MethodInvocation.invoke(declaredMethod).dynamic(FOO, otherType, Collections.<TypeDescription>emptyList(), Collections.emptyList())));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class MethodInvocationGenericTest method testGenericMethodDynamicErasureEqual.
@Test
public void testGenericMethodDynamicErasureEqual() throws Exception {
when(methodReturnType.asErasure()).thenReturn(declaredErasure);
when(declaredMethod.isBootstrap()).thenReturn(true);
StackManipulation stackManipulation = MethodInvocation.invoke(methodDescription).dynamic(FOO, otherType, Collections.<TypeDescription>emptyList(), Collections.emptyList());
assertThat(stackManipulation.isValid(), is(true));
assertThat(stackManipulation, is(MethodInvocation.invoke(declaredMethod).dynamic(FOO, otherType, Collections.<TypeDescription>emptyList(), Collections.emptyList())));
}
Aggregations