Class ConversionTck

java.lang.Object
io.micronaut.sourcegen.bytecode.tck.AbstractByteCodeWriterTck
io.micronaut.sourcegen.bytecode.tck.ConversionTck

public abstract class ConversionTck extends AbstractByteCodeWriterTck
Conversions: casts, boxing and unboxing, primitive widening of arguments and of requested return types, and values discarded after they are converted.

A backend runs these tests by extending this class and implementing AbstractByteCodeWriterTck.write(io.micronaut.sourcegen.model.ObjectDef).

Since:
2.3
  • Constructor Details

    • ConversionTck

      public ConversionTck()
  • Method Details

    • writesUnboxingOfAnyNumberAndCastsThroughUnrelatedTypes

      @Test public void writesUnboxingOfAnyNumberAndCastsThroughUnrelatedTypes() throws Exception
      Throws:
      Exception
    • writesNestedCastsWithoutUnboxingAndReboxingAReference

      @Test public void writesNestedCastsWithoutUnboxingAndReboxingAReference() throws Exception
      Throws:
      Exception
    • writesObjectValuesPassedToAndReturnedAsTypedValues

      @Test public void writesObjectValuesPassedToAndReturnedAsTypedValues() throws Exception
      Throws:
      Exception
    • calleeMethodBoundIsUsedForArgumentConversion

      @Test public void calleeMethodBoundIsUsedForArgumentConversion() throws Exception
      Throws:
      Exception
    • castUsesTheEnclosingMethodsBound

      @Test public void castUsesTheEnclosingMethodsBound() throws Exception
      Throws:
      Exception
    • arrayCastUsesTheEnclosingMethodsBound

      @Test public void arrayCastUsesTheEnclosingMethodsBound() throws Exception
      Throws:
      Exception
    • methodBoundCastShadowsTheClassBound

      @Test public void methodBoundCastShadowsTheClassBound() throws Exception
      Throws:
      Exception
    • calleeMethodBoundCastsAnObjectArgument

      @Test public void calleeMethodBoundCastsAnObjectArgument() throws Exception
      Throws:
      Exception
    • requestedWidePrimitiveOfAGenericReturnUnboxesTheDeclaration

      @Test public void requestedWidePrimitiveOfAGenericReturnUnboxesTheDeclaration() throws Exception
      Throws:
      Exception
    • requestedWidePrimitiveOfAGenericMethodIsDiscardedAndReturned

      @Test public void requestedWidePrimitiveOfAGenericMethodIsDiscardedAndReturned() throws Exception
      Throws:
      Exception
    • boundedTypeVariableCanUnboxAndWiden

      @Test public void boundedTypeVariableCanUnboxAndWiden() throws Exception
      Throws:
      Exception
    • characterInferredForAGenericReturnIsUnboxedAsACharacter

      @Test public void characterInferredForAGenericReturnIsUnboxedAsACharacter() throws Exception
      Throws:
      Exception
    • variableBoundedByIntegerUnboxesAndWidensToLong

      @Test public void variableBoundedByIntegerUnboxesAndWidensToLong() throws Exception
      Throws:
      Exception
    • variableBoundedByCharacterUnboxesAndWidensToInt

      @Test public void variableBoundedByCharacterUnboxesAndWidensToInt() throws Exception
      Throws:
      Exception
    • requestedPrimitiveOfABoxedReturn

      @Test public void requestedPrimitiveOfABoxedReturn() throws Exception
      Throws:
      Exception
    • requestedSupertypeOfTheReturn

      @Test public void requestedSupertypeOfTheReturn() throws Exception
      Throws:
      Exception
    • requestedPrimitiveOfASpecializedBoxedReturn

      @Test public void requestedPrimitiveOfASpecializedBoxedReturn() throws Exception
      Throws:
      Exception
    • requestedSupertypeOfACovariantOverride

      @ParameterizedTest(name="StringBuilder.append(String) requested as {0} invokes the override, not a bridge") @MethodSource("supertypesOfStringBuilder") public void requestedSupertypeOfACovariantOverride(TypeDef requested) throws Exception
      Throws:
      Exception
    • requestedPrimitiveOfAnotherBoxedReturn

      @Test public void requestedPrimitiveOfAnotherBoxedReturn() throws Exception
      Throws:
      Exception
    • callRequestedAsVoidDiscardsTheReturnedValue

      @Test public void callRequestedAsVoidDiscardsTheReturnedValue() throws Exception
      Throws:
      Exception
    • requestedPrimitiveOfAGeneratedGenericReturn

      @Test public void requestedPrimitiveOfAGeneratedGenericReturn() throws Exception
      Throws:
      Exception
    • castBetweenInterfaceArraysIsChecked

      @Test public void castBetweenInterfaceArraysIsChecked() throws Exception
      Throws:
      Exception
    • callConvertedToALongIsDiscardedAsALong

      @Test public void callConvertedToALongIsDiscardedAsALong() throws Exception
      A call by name typed as a primitive the declared return type converts to - <T extends Number> T identity(T) called for a long - used as a statement. The result is discarded after it is converted, when it takes two stack slots.
      Throws:
      Exception
    • numericConstantCastToCharConvertsTheNumber

      @ParameterizedTest(name="(char) {0} converts the number it holds, as javac converts the literal") @MethodSource("constantsCastToChar") public void numericConstantCastToCharConvertsTheNumber(ExpressionDef.Constant constant, char expected) throws Exception
      Throws:
      Exception
    • primitiveBranchOfAConditionalIsConvertedToTheConditionalsType

      @ParameterizedTest(name="a conditional typed Integer converts its {0} branch to int before boxing it") @MethodSource("primitiveBranchesOfAnIntegerConditional") public void primitiveBranchOfAConditionalIsConvertedToTheConditionalsType(TypeDef.Primitive branch, Object value, Integer expected) throws Exception
      Throws:
      Exception
    • nullBranchOfAConditionalTypedAsAPrimitiveThrowsNullPointerException

      @Test public void nullBranchOfAConditionalTypedAsAPrimitiveThrowsNullPointerException() throws Exception
      Throws:
      Exception
    • staticMethodInvokedByNameWithAnotherReturnTypeConvertsTheDeclaredResult

      @ParameterizedTest(name="{0} invokes the declared method and converts its result") @MethodSource("staticCallsByNameOfAnotherReturnType") public void staticMethodInvokedByNameWithAnotherReturnTypeConvertsTheDeclaredResult(String name, TypeDef requested, List<TypeDef> parameters, List<Object> arguments, Object expected) throws Exception
      Throws:
      Exception
    • numberCastToTheBoxOfAnotherIsConvertedNumerically

      @ParameterizedTest(name="a {0} cast to the box of another number is converted, not checked") @MethodSource("numericCastsToAnotherBox") public void numberCastToTheBoxOfAnotherIsConvertedNumerically(TypeDef source, TypeDef target, Object argument, Object expected) throws Exception
      Throws:
      Exception
    • nullBoxCastToTheBoxOfAnotherNumberThrowsNullPointerException

      @Test public void nullBoxCastToTheBoxOfAnotherNumberThrowsNullPointerException() throws Exception
      Throws:
      Exception