use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class OutDegreeTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new OutDegree(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=OUTDEGREE(101)", variableNameToTypeMap))
fail(compiler.getLastErrorMsg());
final Equation equation = compiler.getEquation();
final Interpreter interpreter = new InterpreterImpl();
final Map<String, IdentDescriptor> variableNameToDescriptorMap = new HashMap<String, IdentDescriptor>();
assertEquals("Equation evaluation returned an unexpected result!", 3L, interpreter.execute(equation, variableNameToDescriptorMap));
}
use of org.cytoscape.equations.internal.EquationParserImpl in project cytoscape-impl by cytoscape.
the class TargetIDTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new TargetID(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=TARGETID(11)", variableNameToTypeMap))
fail(compiler.getLastErrorMsg());
final Equation equation = compiler.getEquation();
final Interpreter interpreter = new InterpreterImpl();
final Map<String, IdentDescriptor> variableNameToDescriptorMap = new HashMap<String, IdentDescriptor>();
assertEquals("Equation evaluation returned an unexpected result!", 101L, interpreter.execute(equation, variableNameToDescriptorMap));
}
Aggregations