Search in sources :

Example 1 with VariableChannel

use of pcgen.cdom.formula.VariableChannel 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)

Aggregations

Test (org.junit.Test)1 ScopeInstance (pcgen.base.formula.base.ScopeInstance)1 VariableLibrary (pcgen.base.formula.base.VariableLibrary)1 ScopeInstanceFactory (pcgen.base.formula.inst.ScopeInstanceFactory)1 SimpleNode (pcgen.base.formula.parse.SimpleNode)1 ReconstructionVisitor (pcgen.base.formula.visitor.ReconstructionVisitor)1 VariableChannel (pcgen.cdom.formula.VariableChannel)1