= #JxnPortable\docs\programmer_examples\demos\JavaPrimitiveParameterCastTest.jxn

! Test automatischer Cast bei Methodenaufruf


oldDebug = $this.setDebug false


d8 = 64.
f4 = JxnCast.toFloat 64.
i8 = JxnCast.toLong 64
i4  = 64
i2 = JxnCast.toShort 64
b1 = JxnCast.toByte 64
ch = '@'


#function $test( pluggable )
!
JxnPrimitiveWrapper.setPluggable pluggable
!
JxnParameterCheck.testDouble( d8 )
JxnParameterCheck.testDouble( f4 )
JxnParameterCheck.testDouble( i8 )
JxnParameterCheck.testDouble( i4 )
JxnParameterCheck.testDouble( i2 )
JxnParameterCheck.testDouble( b1 )
JxnParameterCheck.testDouble( ch )
JxnParameterCheck.testDouble( true )
JxnParameterCheck.testDouble( false )
!
JxnParameterCheck.testFloat( d8 )
JxnParameterCheck.testFloat( f4 )
JxnParameterCheck.testFloat( i8 )
JxnParameterCheck.testFloat( i4 )
JxnParameterCheck.testFloat( i2 )
JxnParameterCheck.testFloat( b1 )
JxnParameterCheck.testFloat( ch )
JxnParameterCheck.testFloat( true ) 
JxnParameterCheck.testFloat( false )
!
JxnParameterCheck.testLong( d8 )
JxnParameterCheck.testLong( f4 )
JxnParameterCheck.testLong( i8 )
JxnParameterCheck.testLong( i4 )
JxnParameterCheck.testLong( i2 )
JxnParameterCheck.testLong( b1 )
JxnParameterCheck.testLong( ch )
JxnParameterCheck.testLong( true ) 
JxnParameterCheck.testLong( false )
!
JxnParameterCheck.testInt( d8 )
JxnParameterCheck.testInt( f4 )
JxnParameterCheck.testInt( i8 )
JxnParameterCheck.testInt( i4 )
JxnParameterCheck.testInt( i2 )
JxnParameterCheck.testInt( b1 )
JxnParameterCheck.testInt( ch )
JxnParameterCheck.testInt( true ) 
JxnParameterCheck.testInt( false )
!
JxnParameterCheck.testShort( d8 )
JxnParameterCheck.testShort( f4 )
JxnParameterCheck.testShort( i8 )
JxnParameterCheck.testShort( i4 )
JxnParameterCheck.testShort( i2 )
JxnParameterCheck.testShort( b1 )
JxnParameterCheck.testShort( ch )
JxnParameterCheck.testShort( true ) 
JxnParameterCheck.testShort( false )
!
JxnParameterCheck.testByte( d8 )
JxnParameterCheck.testByte( f4 )
JxnParameterCheck.testByte( i8 )
JxnParameterCheck.testByte( i4 )
JxnParameterCheck.testByte( i2 )
JxnParameterCheck.testByte( b1 )
JxnParameterCheck.testByte( ch )
JxnParameterCheck.testByte( true ) 
JxnParameterCheck.testByte( false )
!
JxnParameterCheck.testChar( d8 )
JxnParameterCheck.testChar( f4 )
JxnParameterCheck.testChar( i8 )
JxnParameterCheck.testChar( i4 )
JxnParameterCheck.testChar( i2 )
JxnParameterCheck.testChar( b1 )
JxnParameterCheck.testChar( ch )
JxnParameterCheck.testChar( true ) 
JxnParameterCheck.testChar( false )
!
JxnParameterCheck.testBoolean( d8 )
JxnParameterCheck.testBoolean( f4 )
JxnParameterCheck.testBoolean( i8 )
JxnParameterCheck.testBoolean( i4 )
JxnParameterCheck.testBoolean( i2 )
JxnParameterCheck.testBoolean( b1 )
JxnParameterCheck.testBoolean( ch )
JxnParameterCheck.testBoolean( true )
JxnParameterCheck.testBoolean( false )
!
#return
#endfunction
$test.setDebug 1


$test "Java"
$test "Safe"

! here no downcast possible w/o overflow
2 Float.MAX_VALUE
d8 = 2. Float.MAX_VALUE
f4 = JxnCast.toFloat -Long.MIN_VALUE
i8 = JxnCast.toLong -Integer.MIN_VALUE
i4  = -Short.MIN_VALUE
i2 = JxnCast.toShort -Byte.MIN_VALUE
b1 = JxnCast.toByte 64
ch = '\#216'

$test "Safe"
JxnParameterCheck.testChar( 2 i4 )

JxnPrimitiveWrapper.setPluggable ""

$this.setDebug oldDebug