You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/02/25 15:01:31 UTC
[43/43] incubator-tinkerpop git commit: Added some more asserts
around variable scoping with interpreter mode.
Added some more asserts around variable scoping with interpreter mode.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/73489b3a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/73489b3a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/73489b3a
Branch: refs/heads/TINKERPOP-1107
Commit: 73489b3a89bab18d59fc5e1dfc9b23a10c5222ab
Parents: 566c488
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 19 10:05:41 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 25 07:40:47 2016 -0500
----------------------------------------------------------------------
.../jsr223/GremlinGroovyScriptEngineTest.java | 25 ++++++++++++++++++++
1 file changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/73489b3a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
index 17cd809..19ced88 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
@@ -19,6 +19,8 @@
package org.apache.tinkerpop.gremlin.groovy.jsr223;
import groovy.lang.Closure;
+import groovy.lang.MissingPropertyException;
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider;
@@ -55,6 +57,7 @@ import java.util.stream.IntStream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -99,6 +102,17 @@ public class GremlinGroovyScriptEngineTest {
assertEquals(4, engine.eval("yyy = xxx + 1"));
assertEquals(7, engine.eval("def zzz = yyy + xxx"));
assertEquals(4, engine.eval("zzz - xxx"));
+ assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer"));
+ assertEquals("accessible-globally", engine.eval("outer"));
+
+ try {
+ engine.eval("inner");
+ fail("Should not have been able to access 'inner'");
+ } catch (Exception ex) {
+ final Throwable root = ExceptionUtils.getRootCause(ex);
+ assertThat(root, instanceOf(MissingPropertyException.class));
+ }
+
assertEquals(10, engine.eval("addItUp(zzz,xxx)"));
}
@@ -112,6 +126,17 @@ public class GremlinGroovyScriptEngineTest {
assertEquals(4, engine.eval("yyy = xxx + 1", b));
assertEquals(7, engine.eval("def zzz = yyy + xxx", b));
assertEquals(4, engine.eval("zzz - xxx", b));
+ assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer", b));
+ assertEquals("accessible-globally", engine.eval("outer", b));
+
+ try {
+ engine.eval("inner", b);
+ fail("Should not have been able to access 'inner'");
+ } catch (Exception ex) {
+ final Throwable root = ExceptionUtils.getRootCause(ex);
+ assertThat(root, instanceOf(MissingPropertyException.class));
+ }
+
assertEquals(10, engine.eval("addItUp(zzz,xxx)", b));
}