Search in sources :

Example 11 with SimpleNode

use of pcgen.base.formula.parse.SimpleNode in project pcgen by PCGen.

the class DropIntoContextFunctionTest method testInvalidWrongFormat1.

@Test
public void testInvalidWrongFormat1() {
    String formula = "dropIntoContext(3,\"EquipKey\",3)";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 12 with SimpleNode

use of pcgen.base.formula.parse.SimpleNode in project pcgen by PCGen.

the class InputFunctionTest method testGlobalChannelStrength.

@Test
public void testGlobalChannelStrength() {
    VariableLibrary varLib = variableLibraryFacet.get(id.getDatasetID());
    ScopeInstanceFactory instFactory = scopeFacet.get(id);
    ScopeInstance globalInstance = instFactory.getGlobalInstance("Global");
    varLib.assertLegalVariableID(ChannelUtilities.createVarName("STR"), globalInstance.getLegalScope(), numberManager);
    VariableChannel<Number> strChannel = (VariableChannel<Number>) ChannelUtilities.getGlobalChannel(id, "STR");
    String formula = "input(\"STR\")";
    SimpleNode node = TestUtilities.doParse(formula);
    isValid(formula, node, numberManager, null);
    isStatic(formula, node, false);
    evaluatesTo(formula, node, 0);
    strChannel.set(2);
    evaluatesTo(formula, node, 2);
    Object rv = new ReconstructionVisitor().visit(node, new StringBuilder());
    assertEquals(formula, rv.toString());
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) VariableChannel(pcgen.cdom.formula.VariableChannel) ReconstructionVisitor(pcgen.base.formula.visitor.ReconstructionVisitor) ScopeInstanceFactory(pcgen.base.formula.inst.ScopeInstanceFactory) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 13 with SimpleNode

use of pcgen.base.formula.parse.SimpleNode in project pcgen by PCGen.

the class InputFunctionTest method testNotValidNoChannel.

@Test
public void testNotValidNoChannel() {
    String formula = "input(\"notvalid\")";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 14 with SimpleNode

use of pcgen.base.formula.parse.SimpleNode in project pcgen by PCGen.

the class InputFunctionTest method testNotValidNoVar.

@Test
public void testNotValidNoVar() {
    String formula = "input(ab)";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 15 with SimpleNode

use of pcgen.base.formula.parse.SimpleNode in project pcgen by PCGen.

the class InputFunctionTest method testInvalidTooFewArg.

@Test
public void testInvalidTooFewArg() {
    String formula = "input()";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
    formula = "if(\"a\", \"b\")";
    node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Aggregations

SimpleNode (pcgen.base.formula.parse.SimpleNode)24 Test (org.junit.Test)22 VariableLibrary (pcgen.base.formula.base.VariableLibrary)14 VariableID (pcgen.base.formula.base.VariableID)12 WriteableVariableStore (pcgen.base.formula.base.WriteableVariableStore)10 ColumnFormatFactory (pcgen.cdom.format.table.ColumnFormatFactory)8 DataTable (pcgen.cdom.format.table.DataTable)8 TableFormatFactory (pcgen.cdom.format.table.TableFormatFactory)8 FormulaSemantics (pcgen.base.formula.base.FormulaSemantics)4 ReconstructionVisitor (pcgen.base.formula.visitor.ReconstructionVisitor)4 SemanticsVisitor (pcgen.base.formula.visitor.SemanticsVisitor)4 LegalScope (pcgen.base.formula.base.LegalScope)3 ScopeInstance (pcgen.base.formula.base.ScopeInstance)3 EvaluationManager (pcgen.base.formula.base.EvaluationManager)2 EvaluateVisitor (pcgen.base.formula.visitor.EvaluateVisitor)2 Equipment (pcgen.core.Equipment)2 ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)2 LoadContext (pcgen.rules.context.LoadContext)2 RuntimeLoadContext (pcgen.rules.context.RuntimeLoadContext)2 RuntimeReferenceContext (pcgen.rules.context.RuntimeReferenceContext)2