Search in sources :

Example 1 with BooleanVariable

use of org.matheclipse.parser.client.eval.BooleanVariable in project symja_android_library by axkr.

the class EvalDoubleTestCase method testEval009.

public void testEval009() {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        BooleanVariable vb = new BooleanVariable(true);
        engine.defineVariable("$1", vb);
        double d = engine.evaluate("If[$1, 1, 0]");
        Assert.assertEquals(d, 1d, DoubleEvaluator.EPSILON);
        vb.setValue(false);
        d = engine.evaluate();
        Assert.assertEquals(d, 0d, DoubleEvaluator.EPSILON);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.assertEquals("", e.getMessage());
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) BooleanVariable(org.matheclipse.parser.client.eval.BooleanVariable) MathException(org.matheclipse.parser.client.math.MathException)

Example 2 with BooleanVariable

use of org.matheclipse.parser.client.eval.BooleanVariable in project symja_android_library by axkr.

the class EvalDoubleTestCase method testEval006.

public void testEval006() {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        BooleanVariable vb = new BooleanVariable(true);
        engine.defineVariable("$1", vb);
        BooleanVariable vb2 = new BooleanVariable(true);
        engine.defineVariable("$2", vb2);
        double d = engine.evaluate("If[$1 && $2, 1, 0]");
        Assert.assertEquals(d, 1d, DoubleEvaluator.EPSILON);
        vb.setValue(false);
        d = engine.evaluate();
        Assert.assertEquals(d, 0d, DoubleEvaluator.EPSILON);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.assertEquals("", e.getMessage());
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) BooleanVariable(org.matheclipse.parser.client.eval.BooleanVariable) MathException(org.matheclipse.parser.client.math.MathException)

Aggregations

BooleanVariable (org.matheclipse.parser.client.eval.BooleanVariable)2 DoubleEvaluator (org.matheclipse.parser.client.eval.DoubleEvaluator)2 MathException (org.matheclipse.parser.client.math.MathException)2