Skip to content

Commit 19db479

Browse files
committed
ClojureTest: test the new and improved bindings
1 parent 8d04644 commit 19db479

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/org/scijava/plugins/scripting/clojure/ClojureTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
package org.scijava.plugins.scripting.clojure;
3333

3434
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;
3538
import static org.junit.Assert.fail;
3639

3740
import java.io.IOException;
@@ -114,4 +117,27 @@ public void testParameters() throws InterruptedException, ExecutionException,
114117
assertEquals(expected, actual);
115118
}
116119

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+
}
117143
}

0 commit comments

Comments
 (0)