Class ConversionTck
java.lang.Object
io.micronaut.sourcegen.bytecode.tck.AbstractByteCodeWriterTck
io.micronaut.sourcegen.bytecode.tck.ConversionTck
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidA call by name typed as a primitive the declared return type converts to -<T extends Number> T identity(T)called for along- used as a statement.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidnumberCastToTheBoxOfAnotherIsConvertedNumerically(TypeDef source, TypeDef target, Object argument, Object expected) voidnumericConstantCastToCharConvertsTheNumber(ExpressionDef.Constant constant, char expected) voidprimitiveBranchOfAConditionalIsConvertedToTheConditionalsType(TypeDef.Primitive branch, Object value, Integer expected) voidvoidvoidvoidvoidrequestedSupertypeOfACovariantOverride(TypeDef requested) voidvoidvoidvoidstaticMethodInvokedByNameWithAnotherReturnTypeConvertsTheDeclaredResult(String name, TypeDef requested, List<TypeDef> parameters, List<Object> arguments, Object expected) voidvoidvoidvoidvoidMethods inherited from class AbstractByteCodeWriterTck
assertCall, caller, callWithParameter, classShape, declaredFields, declaredMethods, define, defineInPackage, genericShape, invoke, list, load, outcome, run, run, run, selection, selection, shape, write
-
Constructor Details
-
ConversionTck
public ConversionTck()
-
-
Method Details
-
writesNestedCastsWithoutUnboxingAndReboxingAReference
-
writesObjectValuesPassedToAndReturnedAsTypedValues
-
calleeMethodBoundIsUsedForArgumentConversion
-
castUsesTheEnclosingMethodsBound
-
arrayCastUsesTheEnclosingMethodsBound
-
methodBoundCastShadowsTheClassBound
-
calleeMethodBoundCastsAnObjectArgument
-
requestedWidePrimitiveOfAGenericReturnUnboxesTheDeclaration
-
requestedWidePrimitiveOfAGenericMethodIsDiscardedAndReturned
-
boundedTypeVariableCanUnboxAndWiden
-
characterInferredForAGenericReturnIsUnboxedAsACharacter
-
variableBoundedByIntegerUnboxesAndWidensToLong
-
variableBoundedByCharacterUnboxesAndWidensToInt
-
requestedPrimitiveOfABoxedReturn
-
requestedSupertypeOfTheReturn
-
requestedPrimitiveOfASpecializedBoxedReturn
-
requestedSupertypeOfACovariantOverride
-
requestedPrimitiveOfAnotherBoxedReturn
-
callRequestedAsVoidDiscardsTheReturnedValue
-
requestedPrimitiveOfAGeneratedGenericReturn
-
castBetweenInterfaceArraysIsChecked
-
callConvertedToALongIsDiscardedAsALong
A call by name typed as a primitive the declared return type converts to -<T extends Number> T identity(T)called for along- 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
-
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
-
nullBoxCastToTheBoxOfAnotherNumberThrowsNullPointerException