| 38 | import org.junit.jupiter.api.Test; |
| 39 | |
| 40 | public class InputFunctionTest extends AbstractFormulaTestCase |
| 41 | { |
| 42 | |
| 43 | private ScopeFacet scopeFacet = FacetLibrary.getFacet(ScopeFacet.class); |
| 44 | private VariableStoreFacet variableStoreFacet = |
| 45 | FacetLibrary.getFacet(VariableStoreFacet.class); |
| 46 | private SolverManagerFacet solverManagerFacet = |
| 47 | FacetLibrary.getFacet(SolverManagerFacet.class); |
| 48 | private CharID id; |
| 49 | |
| 50 | @BeforeEach |
| 51 | @Override |
| 52 | public void setUp() throws Exception |
| 53 | { |
| 54 | super.setUp(); |
| 55 | getFunctionLibrary().addFunction(new InputFunction()); |
| 56 | id = CharID.getID(context.getDataSetID()); |
| 57 | scopeFacet.set(id, getFormulaManager().getScopeInstanceFactory()); |
| 58 | variableStoreFacet.set(id, getVariableStore()); |
| 59 | solverManagerFacet.set(id, |
| 60 | context.getVariableContext().generateSolverManager(getVariableStore())); |
| 61 | } |
| 62 | |
| 63 | @Test |
| 64 | public void testInvalidTooFewArg() |
| 65 | { |
| 66 | String formula = "input()"; |
| 67 | SimpleNode node = TestUtilities.doParse(formula); |
| 68 | isNotValid(formula, node); |
| 69 | formula = "if(\"a\", \"b\")"; |
| 70 | node = TestUtilities.doParse(formula); |
| 71 | isNotValid(formula, node); |
| 72 | } |
| 73 | |
| 74 | @Test |
| 75 | public void testInvalidNotString() |
| 76 | { |
| 77 | String formula = "input(2)"; |
| 78 | SimpleNode node = TestUtilities.doParse(formula); |
| 79 | isNotValid(formula, node); |
| 80 | } |
| 81 | |
| 82 | @Test |
| 83 | public void testNotValidNoVar() |
| 84 | { |
| 85 | String formula = "input(ab)"; |
| 86 | SimpleNode node = TestUtilities.doParse(formula); |
| 87 | isNotValid(formula, node); |
| 88 | } |
| 89 | |
| 90 | @Test |
| 91 | public void testNotValidNoChannel() |
| 92 | { |
| 93 | String formula = "input(\"notvalid\")"; |
| 94 | SimpleNode node = TestUtilities.doParse(formula); |
| 95 | isNotValid(formula, node); |
| 96 | } |
| 97 | |