|
32 | 32 | package org.scijava.plugins.scripting.clojure; |
33 | 33 |
|
34 | 34 | import static org.junit.Assert.assertEquals; |
| 35 | +import static org.junit.Assert.assertFalse; |
| 36 | +import static org.junit.Assert.assertSame; |
| 37 | +import static org.junit.Assert.assertTrue; |
35 | 38 | import static org.junit.Assert.fail; |
36 | 39 |
|
37 | 40 | import java.io.IOException; |
@@ -114,4 +117,27 @@ public void testParameters() throws InterruptedException, ExecutionException, |
114 | 117 | assertEquals(expected, actual); |
115 | 118 | } |
116 | 119 |
|
| 120 | + @Test |
| 121 | + public void testBindings() { |
| 122 | + final Context context = new Context(ScriptService.class); |
| 123 | + final ScriptService scriptService = context.getService(ScriptService.class); |
| 124 | + |
| 125 | + ScriptLanguage clojure = scriptService.getLanguageByName("clojure"); |
| 126 | + assertSame(ClojureScriptLanguage.class, clojure.getClass()); |
| 127 | + |
| 128 | + final ScriptEngine engine = clojure.getScriptEngine(); |
| 129 | + final Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE); |
| 130 | + final int bSize = bindings.size(); |
| 131 | + |
| 132 | + assertEquals(bSize, bindings.keySet().size()); |
| 133 | + assertFalse(bindings.keySet().contains("foo")); |
| 134 | + |
| 135 | + engine.put("foo", "bar"); |
| 136 | + assertEquals("bar", engine.get("foo")); |
| 137 | + assertEquals("bar", bindings.get("foo")); |
| 138 | + assertEquals(bSize + 1, bindings.size()); |
| 139 | + |
| 140 | + assertEquals(bSize + 1, bindings.keySet().size()); |
| 141 | + assertTrue(bindings.keySet().contains("foo")); |
| 142 | + } |
117 | 143 | } |
0 commit comments