# HG changeset patch # User Jaroslav Tulach # Date 1452179191 -3600 # Node ID 9aded7e1e122cd12668e6a16ad1ccf3a00828667 # Parent 0ef597d272565d4da2b39efd5695f17a5f51ab72 When integer values are on input of any language, the result should be the same regardless they are stored as int or float or double diff -r 0ef597d27256 -r 9aded7e1e122 truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java --- a/truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java Thu Jan 07 15:54:23 2016 +0100 +++ b/truffle/com.oracle.truffle.tck/src/com/oracle/truffle/tck/TruffleTCK.java Thu Jan 07 16:06:31 2016 +0100 @@ -522,6 +522,28 @@ } @Test + public void testPlusWithDoubleFloatSameAsInt() throws Exception { + int x = RANDOM.nextInt(100); + int y = RANDOM.nextInt(100); + float a = x; + float b = y; + double u = a; + double v = b; + + PolyglotEngine.Value floatPlus = findGlobalSymbol(plus(float.class, float.class)); + PolyglotEngine.Value doublePlus = findGlobalSymbol(plus(double.class, double.class)); + PolyglotEngine.Value intPlus = findGlobalSymbol(plus(int.class, int.class)); + + Number floatResult = floatPlus.execute(a, b).as(Number.class); + Number doubleResult = doublePlus.execute(a, b).as(Number.class); + Number intResult = intPlus.execute(a, b).as(Number.class); + + assertEquals("Correct value computed via int: (" + a + " + " + b + ")", x + y, intResult.intValue()); + assertEquals("Correct value computed via float: (" + a + " + " + b + ")", intResult.intValue(), floatResult.intValue()); + assertEquals("Correct value computed via double: (" + a + " + " + b + ")", intResult.intValue(), doubleResult.intValue()); + } + + @Test public void testPlusWithFloat() throws Exception { float a = RANDOM.nextFloat() * 100.0f; float b = RANDOM.nextFloat() * 100.0f;