/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityFloat() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); float value = RANDOM.nextInt(1000) + RANDOM.nextFloat(); Number n = (Number) apply.execute(value).get(); assertDouble("The same value returned", value, n.floatValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityDouble() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); double value = RANDOM.nextInt(1000) + RANDOM.nextDouble(); Number n = (Number) apply.execute(value).get(); assertDouble("The same value returned", value, n.doubleValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityByte() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); byte value = (byte) RANDOM.nextInt(100); Number n = (Number) apply.execute(value).get(); assertEquals("The same value returned", value, n.byteValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityInt() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); int value = RANDOM.nextInt(100); Number n = (Number) apply.execute(value).get(); assertEquals("The same value returned", value, n.intValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityLong() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); long value = RANDOM.nextInt(1000); Number n = (Number) apply.execute(value).get(); assertEquals("The same value returned", value, n.longValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityShort() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); short value = (short) RANDOM.nextInt(100); Number n = (Number) apply.execute(value).get(); assertEquals("The same value returned", value, n.shortValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityString() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); String value = "Value" + RANDOM.nextInt(1000) + RANDOM.nextDouble(); String ret = (String) apply.execute(value).get(); assertEquals("The same value returned", value, ret); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedFloat() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); float value = RANDOM.nextInt(1000) + RANDOM.nextFloat(); BoxedValue boxed = new BoxedValue(value); Number n = (Number) apply.execute(boxed).get(); assertDouble("The same value returned", value, n.floatValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedDouble() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); double value = RANDOM.nextInt(1000) + RANDOM.nextDouble(); BoxedValue boxed = new BoxedValue(value); Number n = (Number) apply.execute(boxed).get(); assertDouble("The same value returned", value, n.doubleValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedString() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); String value = "Value" + RANDOM.nextInt(1000) + RANDOM.nextDouble(); BoxedValue boxed = new BoxedValue(value); String ret = (String) apply.execute(boxed).get(); assertEquals("The same value returned", value, ret); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedShort() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); short value = (short) RANDOM.nextInt(100); BoxedValue boxed = new BoxedValue(value); Number n = (Number) apply.execute(boxed).get(); assertEquals("The same value returned", value, n.shortValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedByte() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); byte value = (byte) RANDOM.nextInt(100); BoxedValue boxed = new BoxedValue(value); Number n = (Number) apply.execute(boxed).get(); assertEquals("The same value returned", value, n.byteValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedInt() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); int value = RANDOM.nextInt(100); BoxedValue boxed = new BoxedValue(value); Number n = (Number) apply.execute(boxed).get(); assertEquals("The same value returned", value, n.intValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveidentityBoxedLong() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); long value = RANDOM.nextInt(1000); BoxedValue boxed = new BoxedValue(value); Number n = (Number) apply.execute(boxed).get(); assertEquals("The same value returned", value, n.longValue()); }
/** @since 0.8 or earlier */ @Test public void testPrimitiveIdentityForeignObject() throws Exception { String id = identity(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); Object fn = new Object(); Object ret = apply.execute(fn).get(); assertSameTruffleObject("The same value returned", fn, ret); }