use of 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 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 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 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);
}
use of net.bytebuddy.implementation.bytecode.StackManipulation in project byte-buddy by raphw.
the class ReferenceTypeAwareAssignerTest method testSourceToTargetAssignable.
@Test
public void testSourceToTargetAssignable() throws Exception {
defineAssignability(true, false);
StackManipulation stackManipulation = ReferenceTypeAwareAssigner.INSTANCE.assign(source, target, 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(methodVisitor);
}
Aggregations