Skip to content

Commit c0c6d38

Browse files
committed
Add a test for behavior of nulls
See: #2 (comment)
1 parent af74e45 commit c0c6d38

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎src/test/java/org/scijava/plugins/scripting/beanshell/BeanshellTest.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,25 @@ public void testParameters() throws InterruptedException, ExecutionException,
114114
assertEquals(expected, result);
115115
}
116116

117+
@Test
118+
public void testNull() throws InterruptedException, ExecutionException,
119+
IOException, ScriptException
120+
{
121+
final Context context = new Context(ScriptService.class);
122+
final ScriptService scriptService = context.getService(ScriptService.class);
123+
124+
final String script = "" + //
125+
"#@ ScriptService ss\n" + //
126+
"#@output String ternary\n" + //
127+
"a = null;\n" + //
128+
"ternary = a == null ? \"NULL\" : \"HUH?\";\n";
129+
final ScriptModule m = scriptService.run("nullTest.bsh", script, true).get();
130+
131+
final Object actual = m.getOutput("ternary");
132+
final String expected = "NULL";
133+
assertEquals(expected, actual);
134+
135+
final Object result = m.getReturnValue();
136+
assertEquals(expected, result);
137+
}
117138
}

0 commit comments

Comments
 (0)