From 006829e89bf2bcf8e50f9e947fef7aa8626b6f01 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 20 Jun 2016 13:33:51 -0400 Subject: [PATCH] add simple arguments test --- .../test/java/org/elasticsearch/painless/CastTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/CastTests.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/CastTests.java index fcee0ddeb3e..0551965f067 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/CastTests.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/CastTests.java @@ -162,6 +162,15 @@ public class CastTests extends ScriptTestCase { assertEquals(5, exec("def x = 5; return (int)x.longValue();")); } + /** + * Currently these do not adopt the argument value, we issue a separate cast! + */ + public void testArgumentsDef() { + assertEquals(5, exec("def x = 5L; return (+(int)x);")); + assertEquals(6, exec("def x = 5; def y = 1L; return x + (int)y")); + assertEquals('b', exec("def x = 'abcdeg'; def y = 1L; x.charAt((int)y)")); + } + /** * Unary operators adopt the return value */