use of org.cytoscape.equations.IdentDescriptor in project cytoscape-impl by cytoscape.
the class InterpreterTest method testUnaryPlusAndMinus2.
@Test
public void testUnaryPlusAndMinus2() throws Exception {
final Map<String, Class<?>> attribNameToTypeMap = new HashMap<String, Class<?>>();
attribNameToTypeMap.put("attr1", Long.class);
assertTrue(compiler.compile("=-$attr1", attribNameToTypeMap));
final Map<String, IdentDescriptor> nameToDescriptorMap = new HashMap<String, IdentDescriptor>();
nameToDescriptorMap.put("attr1", new IdentDescriptor(5L));
assertEquals(new Double(-5.0), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
}
use of org.cytoscape.equations.IdentDescriptor in project cytoscape-impl by cytoscape.
the class InterpreterTest method testComparisons.
@Test
public void testComparisons() throws Exception {
final Map<String, Class<?>> attribNameToTypeMap = new HashMap<String, Class<?>>();
attribNameToTypeMap.put("x", Double.class);
attribNameToTypeMap.put("y", Double.class);
attribNameToTypeMap.put("limit", Double.class);
assertTrue(compiler.compile("=${x} <= ${y}", attribNameToTypeMap));
final Map<String, IdentDescriptor> nameToDescriptorMap = new HashMap<String, IdentDescriptor>();
nameToDescriptorMap.put("x", new IdentDescriptor(1.2));
nameToDescriptorMap.put("y", new IdentDescriptor(-3.8e-12));
nameToDescriptorMap.put("limit", new IdentDescriptor(-65.23e12));
assertEquals(new Boolean(false), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
assertTrue(compiler.compile("=-15.4^3 > ${limit}", attribNameToTypeMap));
assertEquals(new Boolean(true), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
}
use of org.cytoscape.equations.IdentDescriptor in project cytoscape-impl by cytoscape.
the class InterpreterTest method testDEFINED.
@Test
public void testDEFINED() throws Exception {
final Map<String, Class<?>> attribNameToTypeMap = new HashMap<String, Class<?>>();
attribNameToTypeMap.put("x", Double.class);
assertTrue(compiler.compile("=defined(x)", attribNameToTypeMap));
final Map<String, IdentDescriptor> nameToDescriptorMap = new HashMap<String, IdentDescriptor>();
nameToDescriptorMap.put("x", new IdentDescriptor(1.2));
assertEquals(new Boolean(true), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
assertTrue(compiler.compile("=DEFINED(${limit})", attribNameToTypeMap));
assertEquals(new Boolean(false), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
}
use of org.cytoscape.equations.IdentDescriptor in project cytoscape-impl by cytoscape.
the class InterpreterTest method testBinaryMinus.
@Test
public void testBinaryMinus() throws Exception {
final Map<String, Class<?>> attribNameToTypeMap = new HashMap<String, Class<?>>();
attribNameToTypeMap.put("attr1", Double.class);
attribNameToTypeMap.put("attr2", Double.class);
assertTrue(compiler.compile("=-17.8E-14", attribNameToTypeMap));
assertTrue(compiler.compile("=1-1.5", attribNameToTypeMap));
final Map<String, IdentDescriptor> nameToDescriptorMap = new HashMap<String, IdentDescriptor>();
nameToDescriptorMap.put("attr1", new IdentDescriptor(5.5));
nameToDescriptorMap.put("attr2", new IdentDescriptor(6.5));
assertEquals(new Double(-0.5), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
}
use of org.cytoscape.equations.IdentDescriptor in project cytoscape-impl by cytoscape.
the class InterpreterTest method testIntegerToFloatingPointConversion.
@Test
public void testIntegerToFloatingPointConversion() throws Exception {
final Map<String, Class<?>> attribNameToTypeMap = new HashMap<String, Class<?>>();
attribNameToTypeMap.put("BOB", Long.class);
final Map<String, IdentDescriptor> nameToDescriptorMap = new HashMap<String, IdentDescriptor>();
nameToDescriptorMap.put("BOB", new IdentDescriptor(new Long(3)));
assertTrue(compiler.compile("=$BOB > 5.3", attribNameToTypeMap));
assertEquals(new Boolean(false), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
assertTrue(compiler.compile("=$BOB <= 5.3", attribNameToTypeMap));
assertEquals(new Boolean(true), interpreter.execute(compiler.getEquation(), nameToDescriptorMap));
}
Aggregations