|
| 1 | +package org.scijava.script.process; |
| 2 | + |
| 3 | +import static org.junit.Assert.*; |
| 4 | + |
| 5 | +import java.io.StringReader; |
| 6 | + |
| 7 | +import org.junit.After; |
| 8 | +import org.junit.Before; |
| 9 | +import org.junit.Test; |
| 10 | +import org.scijava.Context; |
| 11 | +import org.scijava.script.ScriptInfo; |
| 12 | + |
| 13 | +public class ParameterScriptProcessorTest { |
| 14 | + |
| 15 | + private Context context; |
| 16 | + |
| 17 | + @Before |
| 18 | + public void setUp() { |
| 19 | + context = new Context(); |
| 20 | + } |
| 21 | + |
| 22 | + @After |
| 23 | + public void tearDown() { |
| 24 | + context.dispose(); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void testScriptParameterParsing() { |
| 29 | + String script = "" + // |
| 30 | + "% @String legacyStyleParameter\n" + |
| 31 | + "% #@ String commentedHeaderParameter\n" + |
| 32 | + "% ############## Some Comment ###########\n" + |
| 33 | + "#@ String implicitInputParameter\n" + |
| 34 | + "#@input String explicitInputParameter\n" + |
| 35 | + "\n" + |
| 36 | + "% @String legacyStyleBodyParameter\n" + |
| 37 | + "% #@ String commentedBodyParameter\n" + |
| 38 | + "\n" + |
| 39 | + "#@output implicitlyTypedOutputParameter\n" + |
| 40 | + "#@output String explicitlyTypedOutputParameter\n"; |
| 41 | + final ScriptInfo info = new ScriptInfo(context, ".bsizes", new StringReader(script)); |
| 42 | + assertEquals("legacyStyleParameter", info.getInput("legacyStyleParameter").getName()); |
| 43 | + assertEquals("implicitInputParameter", info.getInput("implicitInputParameter").getName()); |
| 44 | + assertEquals("explicitInputParameter", info.getInput("explicitInputParameter").getName()); |
| 45 | + |
| 46 | + assertEquals("implicitlyTypedOutputParameter", info.getOutput("implicitlyTypedOutputParameter").getName()); |
| 47 | + assertEquals("explicitlyTypedOutputParameter", info.getOutput("explicitlyTypedOutputParameter").getName()); |
| 48 | + |
| 49 | + assertNull(info.getInput("commentedHeaderParameter")); |
| 50 | + assertNull(info.getInput("legacyStyleBodyParameter")); |
| 51 | + assertNull(info.getInput("commentedBodyParameter")); |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments