Search in sources :

Example 16 with VariableID

use of pcgen.base.formula.base.VariableID in project pcgen by PCGen.

the class LookupFunctionTest method testInvalidBadSemantics1.

@Test
public void testInvalidBadSemantics1() {
    Finder finder = new Finder();
    finder.map.put(TableColumn.class, "Value", buildColumn("Value", numberManager));
    finder.map.put(TableColumn.class, "Result", buildColumn("Result", stringManager));
    VariableLibrary vl = getVariableLibrary();
    WriteableVariableStore vs = getVariableStore();
    ColumnFormatFactory cfac = new ColumnFormatFactory(finder);
    FormatManager<?> columnMgr = cfac.build("STRING", formatLibrary);
    vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr);
    VariableID columnID = vl.getVariableID(getGlobalScopeInst(), "ResultColumn");
    vs.put(columnID, columnMgr.convert("Value"));
    String formula = "lookup(badf(),\"That\",ResultColumn)";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : WriteableVariableStore(pcgen.base.formula.base.WriteableVariableStore) ColumnFormatFactory(pcgen.cdom.format.table.ColumnFormatFactory) VariableID(pcgen.base.formula.base.VariableID) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 17 with VariableID

use of pcgen.base.formula.base.VariableID in project pcgen by PCGen.

the class LookupFunctionTest method testInvalidWrongFormat2.

@Test
public void testInvalidWrongFormat2() {
    Finder finder = new Finder();
    DataTable dt = doTableSetup();
    finder.map.put(DataTable.class, "A", dt);
    finder.map.put(TableColumn.class, "Value", buildColumn("Value", numberManager));
    finder.map.put(TableColumn.class, "Result", buildColumn("Result", stringManager));
    VariableLibrary vl = getVariableLibrary();
    WriteableVariableStore vs = getVariableStore();
    TableFormatFactory fac = new TableFormatFactory(finder);
    FormatManager<?> tableMgr = fac.build("STRING,NUMBER", formatLibrary);
    vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr);
    VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA");
    vs.put(tableID, tableMgr.convert("A"));
    ColumnFormatFactory cfac = new ColumnFormatFactory(finder);
    FormatManager<?> columnMgr = cfac.build("STRING", formatLibrary);
    vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr);
    VariableID columnID = vl.getVariableID(getGlobalScopeInst(), "ResultColumn");
    vs.put(columnID, columnMgr.convert("Value"));
    String formula = "lookup(TableA,3,ResultColumn)";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : TableFormatFactory(pcgen.cdom.format.table.TableFormatFactory) DataTable(pcgen.cdom.format.table.DataTable) WriteableVariableStore(pcgen.base.formula.base.WriteableVariableStore) VariableID(pcgen.base.formula.base.VariableID) ColumnFormatFactory(pcgen.cdom.format.table.ColumnFormatFactory) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 18 with VariableID

use of pcgen.base.formula.base.VariableID in project pcgen by PCGen.

the class AbstractFormulaTestCase method getVariable.

protected VariableID<Number> getVariable(String formula) {
    VariableLibrary variableLibrary = getVariableLibrary();
    variableLibrary.assertLegalVariableID(formula, localSetup.getGlobalScopeInst().getLegalScope(), numberManager);
    return (VariableID<Number>) variableLibrary.getVariableID(localSetup.getGlobalScopeInst(), formula);
}
Also used : VariableID(pcgen.base.formula.base.VariableID) VariableLibrary(pcgen.base.formula.base.VariableLibrary)

Example 19 with VariableID

use of pcgen.base.formula.base.VariableID in project pcgen by PCGen.

the class LookupFunctionTest method testInvalidWrongFormat1.

@Test
public void testInvalidWrongFormat1() {
    Finder finder = new Finder();
    finder.map.put(TableColumn.class, "Value", buildColumn("Value", numberManager));
    finder.map.put(TableColumn.class, "Result", buildColumn("Result", stringManager));
    VariableLibrary vl = getVariableLibrary();
    WriteableVariableStore vs = getVariableStore();
    ColumnFormatFactory cfac = new ColumnFormatFactory(finder);
    FormatManager<?> columnMgr = cfac.build("STRING", formatLibrary);
    vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr);
    VariableID columnID = vl.getVariableID(getGlobalScopeInst(), "ResultColumn");
    vs.put(columnID, columnMgr.convert("Value"));
    String formula = "lookup(3,\"That\",ResultColumn)";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : WriteableVariableStore(pcgen.base.formula.base.WriteableVariableStore) ColumnFormatFactory(pcgen.cdom.format.table.ColumnFormatFactory) VariableID(pcgen.base.formula.base.VariableID) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Example 20 with VariableID

use of pcgen.base.formula.base.VariableID in project pcgen by PCGen.

the class LookupFunctionTest method testInvalidBadSemantics2.

@Test
public void testInvalidBadSemantics2() {
    Finder finder = new Finder();
    DataTable dt = doTableSetup();
    finder.map.put(DataTable.class, "A", dt);
    finder.map.put(TableColumn.class, "Value", buildColumn("Value", numberManager));
    finder.map.put(TableColumn.class, "Result", buildColumn("Result", stringManager));
    VariableLibrary vl = getVariableLibrary();
    WriteableVariableStore vs = getVariableStore();
    TableFormatFactory fac = new TableFormatFactory(finder);
    FormatManager<?> tableMgr = fac.build("STRING,NUMBER", formatLibrary);
    vl.assertLegalVariableID("TableA", getGlobalScope(), tableMgr);
    VariableID tableID = vl.getVariableID(getGlobalScopeInst(), "TableA");
    vs.put(tableID, tableMgr.convert("A"));
    ColumnFormatFactory cfac = new ColumnFormatFactory(finder);
    FormatManager<?> columnMgr = cfac.build("STRING", formatLibrary);
    vl.assertLegalVariableID("ResultColumn", getGlobalScope(), columnMgr);
    VariableID columnID = vl.getVariableID(getGlobalScopeInst(), "ResultColumn");
    vs.put(columnID, columnMgr.convert("Value"));
    String formula = "lookup(TableA,badf(),ResultColumn)";
    SimpleNode node = TestUtilities.doParse(formula);
    isNotValid(formula, node, numberManager, null);
}
Also used : TableFormatFactory(pcgen.cdom.format.table.TableFormatFactory) DataTable(pcgen.cdom.format.table.DataTable) WriteableVariableStore(pcgen.base.formula.base.WriteableVariableStore) VariableID(pcgen.base.formula.base.VariableID) ColumnFormatFactory(pcgen.cdom.format.table.ColumnFormatFactory) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) Test(org.junit.Test)

Aggregations

VariableID (pcgen.base.formula.base.VariableID)20 VariableLibrary (pcgen.base.formula.base.VariableLibrary)16 Test (org.junit.Test)14 SimpleNode (pcgen.base.formula.parse.SimpleNode)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 ScopeInstance (pcgen.base.formula.base.ScopeInstance)6 FormulaSemantics (pcgen.base.formula.base.FormulaSemantics)3 LegalScope (pcgen.base.formula.base.LegalScope)3 ReconstructionVisitor (pcgen.base.formula.visitor.ReconstructionVisitor)3 SemanticsVisitor (pcgen.base.formula.visitor.SemanticsVisitor)3 Equipment (pcgen.core.Equipment)3 PCGenModifier (pcgen.base.calculation.PCGenModifier)2 EvaluationManager (pcgen.base.formula.base.EvaluationManager)2 ManagerFactory (pcgen.base.formula.base.ManagerFactory)2 EvaluateVisitor (pcgen.base.formula.visitor.EvaluateVisitor)2 ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)2 LoadContext (pcgen.rules.context.LoadContext)2