use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.implementation.bytecode.assign.Assigner 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.assign.Assigner 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.assign.Assigner 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.assign.Assigner 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.assign.Assigner 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