use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class PrimitiveUnboxingDelegateWideningTest method testTrivialBoxing.
@Test
public void testTrivialBoxing() throws Exception {
StackManipulation stackManipulation = PrimitiveUnboxingDelegate.forReferenceType(referenceTypeDescription).assignUnboxedTo(primitiveTypeDescription, chainedAssigner, Assigner.Typing.STATIC);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(sizeChange));
assertThat(size.getMaximalSize(), is(interimMaximum));
verify(methodVisitor).visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(referenceType), unboxingMethodName, unboxingMethodDescriptor, false);
verify(methodVisitor).visitInsn(wideningOpcode);
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 PrimitiveWideningDelegateIllegalTest method testIllegalBoolean.
@Test(expected = IllegalStateException.class)
public void testIllegalBoolean() throws Exception {
StackManipulation stackManipulation = PrimitiveWideningDelegate.forPrimitive(sourceTypeDescription).widenTo(targetTypeDescription);
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 VoidAwareAssignerTest method testAssignNonVoidToNonVoid.
@Test
public void testAssignNonVoidToNonVoid() throws Exception {
Assigner voidAwareAssigner = new VoidAwareAssigner(chainedAssigner);
StackManipulation chainedStackManipulation = mock(StackManipulation.class);
when(chainedAssigner.assign(sourceTypeDescription, targetTypeDescription, Assigner.Typing.STATIC)).thenReturn(chainedStackManipulation);
StackManipulation stackManipulation = voidAwareAssigner.assign(sourceTypeDescription, targetTypeDescription, Assigner.Typing.STATIC);
assertThat(stackManipulation, is(chainedStackManipulation));
verify(chainedAssigner).assign(sourceTypeDescription, targetTypeDescription, Assigner.Typing.STATIC);
verifyNoMoreInteractions(chainedAssigner);
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class VoidAwareAssignerTest method testAssignVoidToVoid.
@Test
public void testAssignVoidToVoid() throws Exception {
when(sourceTypeDescription.represents(void.class)).thenReturn(true);
when(targetTypeDescription.represents(void.class)).thenReturn(true);
Assigner voidAwareAssigner = new VoidAwareAssigner(chainedAssigner);
StackManipulation stackManipulation = voidAwareAssigner.assign(sourceTypeDescription, targetTypeDescription, Assigner.Typing.STATIC);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(0));
assertThat(size.getMaximalSize(), is(0));
verifyZeroInteractions(chainedAssigner);
}
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 testAssignDefaultValue.
@Test
public void testAssignDefaultValue() throws Exception {
Assigner voidAwareAssigner = new VoidAwareAssigner(chainedAssigner);
StackManipulation stackManipulation = voidAwareAssigner.assign(source, target, Assigner.Typing.DYNAMIC);
assertThat(stackManipulation.isValid(), is(true));
StackManipulation.Size size = stackManipulation.apply(methodVisitor, implementationContext);
assertThat(size.getSizeImpact(), is(StackSize.of(targetType).getSize()));
assertThat(size.getMaximalSize(), is(StackSize.of(targetType).getSize()));
verify(methodVisitor).visitInsn(opcode);
verifyNoMoreInteractions(methodVisitor);
}
Aggregations