use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class PatternMatchingTestCase method check.
public void check(EvalEngine engine, boolean configMode, IAST ast, String strResult) {
try {
StringWriter buf = new StringWriter();
Config.SERVER_MODE = configMode;
if (Config.SERVER_MODE) {
IAST inExpr = ast;
TimeConstrainedEvaluator utility = new TimeConstrainedEvaluator(engine, false, Config.FOREVER);
utility.constrainedEval(buf, inExpr);
} else {
if (ast != null) {
OutputFormFactory off = OutputFormFactory.get();
off.setIgnoreNewLine(true);
OutputFormFactory.get().convert(buf, ast);
}
}
assertEquals(buf.toString(), strResult);
} catch (Exception e) {
e.printStackTrace();
assertEquals(e, "");
}
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class CompareToTestCase method testIssue122c.
public void testIssue122c() {
ISymbol b = F.$s("b");
ISymbol c = F.$s("c");
ISymbol x1 = F.$s("x1");
ISymbol x3 = F.$s("x3");
ISymbol x4 = F.$s("x4");
ISymbol x5 = F.$s("x5");
IPattern x1_c = F.$p(x1, c);
IPattern x3_b = F.$p(x3, b);
IPattern x3_c = F.$p(x3, c);
IPattern x5_c = F.$p(x5, c);
IAST ast1 = F.Times(x3, x5, x5_c);
IAST ast2 = F.Times(F.CN1, x1_c, x3_b, x3_c);
int res = ast1.compareTo(ast2);
assertEquals(2, res);
res = ast2.compareTo(ast1);
assertEquals(-2, res);
check("-Infinity+b+a", "-Infinity+a+b");
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class CompareToTestCase method testIssue122a.
public void testIssue122a() {
ISymbol b = F.$s("b");
ISymbol c = F.$s("c");
ISymbol x1 = F.$s("x1");
ISymbol x3 = F.$s("x3");
ISymbol x4 = F.$s("x4");
ISymbol x5 = F.$s("x5");
IPattern x1_c = F.$p(x1, c);
IPattern x3_b = F.$p(x3, b);
IPattern x3_c = F.$p(x3, c);
IPattern x4_c = F.$p(x4, c);
IAST ast1 = F.Times(F.CN1, x1_c, x3_b, x3_c);
IAST ast2 = F.Times(F.CN1, x3, x5, x1_c, x4_c);
int res = ast1.compareTo(ast2);
assertEquals(-1, res);
res = ast2.compareTo(ast1);
assertEquals(1, res);
check("-Infinity+b+a", "-Infinity+a+b");
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class AbstractTestCase method check.
public void check(EvalEngine engine, boolean configMode, IAST ast, String strResult) {
boolean mode = Config.SERVER_MODE;
try {
StringWriter buf = new StringWriter();
Config.SERVER_MODE = configMode;
if (Config.SERVER_MODE) {
IAST inExpr = ast;
TimeConstrainedEvaluator utility = new TimeConstrainedEvaluator(engine, false, Config.FOREVER);
utility.constrainedEval(buf, inExpr);
} else {
if (ast != null) {
OutputFormFactory off = OutputFormFactory.get();
off.setIgnoreNewLine(true);
off.convert(buf, ast);
}
}
assertEquals(strResult, buf.toString());
} catch (Exception e) {
e.printStackTrace();
assertEquals("", e);
} finally {
Config.SERVER_MODE = mode;
}
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class PatternsTest method testPriority002.
public void testPriority002() {
IAST ast1 = ast(f);
ast1.append(Times(a, x));
IAST ast2 = ast(f);
ast2.append(Times(a_, x_));
PatternMatcher pm1 = new PatternMatcher(ast1);
PatternMatcher pm2 = new PatternMatcher(ast2);
int cpr = pm1.compareTo(pm2);
assertEquals(cpr, -1);
}
Aggregations