Skip to content

Commit 957e7a1

Browse files
committed
Test independence of Readers returned by ScriptInfo.getReader()
Signed-off-by: Squareys <Squareys@googlemail.com>
1 parent fb7ed5d commit 957e7a1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/java/org/scijava/script/ScriptInfoTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static org.junit.Assert.assertTrue;
3636
import static org.junit.Assert.fail;
3737

38+
import java.io.BufferedReader;
3839
import java.io.File;
3940
import java.io.IOException;
4041
import java.io.Reader;
@@ -124,6 +125,26 @@ public void testVersion() throws IOException {
124125
FileUtils.deleteRecursively(tmpDir);
125126
}
126127

128+
/**
129+
* Ensures the ScriptInfos Reader can be reused for multiple executions of the
130+
* script.
131+
*/
132+
@Test
133+
public void testReaderSanity() throws Exception {
134+
final String script = "" + //
135+
"% @LogService log\n" + //
136+
"% @OUTPUT Integer output";
137+
138+
ScriptInfo info = new ScriptInfo(context, "hello.bsizes", new StringReader(
139+
script));
140+
BufferedReader reader1 = info.getReader();
141+
BufferedReader reader2 = info.getReader();
142+
143+
assertEquals("Readers are not independent.", reader1.read(), reader2
144+
.read());
145+
146+
}
147+
127148
@Plugin(type = ScriptLanguage.class)
128149
public static class BindingSizes extends AbstractScriptLanguage {
129150

0 commit comments

Comments
 (0)