Skip to content

Commit 58103e3

Browse files
committed
More tests: add testParameters()
1 parent 01b5db4 commit 58103e3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/java/org/scijava/plugins/scripting/scala/ScalaTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.junit.Test;
3434
import org.scijava.Context;
3535
import org.scijava.script.ScriptLanguage;
36+
import org.scijava.script.ScriptModule;
3637
import org.scijava.script.ScriptService;
3738

3839
import javax.script.Bindings;
@@ -87,4 +88,23 @@ public void testLocals() throws Exception {
8788
assertNull(engine.get("hello"));
8889
}
8990
}
91+
92+
@Test
93+
public void testParameters() throws Exception {
94+
try (final Context context = new Context(ScriptService.class)) {
95+
final ScriptService scriptService = context.getService(ScriptService.class);
96+
97+
final String script = "" + //
98+
"#@ScriptService ss\n" + //
99+
"#@OUTPUT String language\n" + //
100+
"val sst = ss.asInstanceOf[org.scijava.script.ScriptService]\n" + // `ss` needs cast from `Object`
101+
"val language = sst.getLanguageByName(\"scala\").getLanguageName()\n";
102+
final ScriptModule m = scriptService.run("hello.scala", script, true).get();
103+
104+
final Object actual = m.getOutput("language");
105+
final String expected =
106+
scriptService.getLanguageByName("scala").getLanguageName();
107+
assertEquals(expected, actual);
108+
}
109+
}
90110
}

0 commit comments

Comments
 (0)