use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.
the class PatternMatchingTestCase method checkPriority.
public void checkPriority(String patternString, int priority) {
try {
ASTNode node = fParser.parse(patternString);
IExpr pat = AST2Expr.CONST.convert(node);
PatternMatcher matcher = new PatternMatcher(pat);
assertEquals(matcher.getPriority(), priority);
} catch (Exception e) {
e.printStackTrace();
assertEquals(0, priority);
}
}
use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.
the class PatternMatchingTestCase method checkPattern.
public void checkPattern(String patternString, String evalString, String resultString) {
try {
ASTNode node = fParser.parse(patternString);
IExpr pat = AST2Expr.CONST.convert(node);
node = fParser.parse(evalString);
IExpr eval = AST2Expr.CONST.convert(node);
PatternMatcher matcher = new PatternMatcher(pat);
if (matcher.test(eval)) {
ArrayList<IExpr> resultList = new ArrayList<IExpr>();
matcher.getPatterns(resultList, pat);
assertEquals(resultList.toString(), resultString);
return;
}
assertEquals("", resultString);
} catch (Exception e) {
e.printStackTrace();
assertEquals("", resultString);
}
}
use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.
the class PatternMatchingTestCase method comparePriority.
public void comparePriority(String patternString1, String patternString2, int result) {
try {
ASTNode node = fParser.parse(patternString1);
IExpr pat1 = AST2Expr.CONST.convert(node);
node = fParser.parse(patternString1);
IExpr pat2 = AST2Expr.CONST.convert(node);
PatternMatcher matcher1 = new PatternMatcher(pat1);
PatternMatcher matcher2 = new PatternMatcher(pat2);
assertEquals(matcher1.compareTo(matcher2), result);
} catch (Exception e) {
e.printStackTrace();
assertEquals(Integer.MAX_VALUE, result);
}
}
use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.
the class ParserTestCase method testParser14.
public void testParser14() {
try {
Parser p = new Parser();
ASTNode obj = p.parse("-a-b*c!!+d");
assertEquals(obj.dependsOn("d"), true);
assertEquals(obj.dependsOn("x"), false);
} catch (Exception e) {
e.printStackTrace();
assertEquals("", e.getMessage());
}
}
use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.
the class ParserTestCase method testParser20.
public void testParser20() {
try {
Parser p = new Parser();
ASTNode obj = p.parse("B[[;;, 2]]");
assertEquals(obj.toString(), "Part(B, Span(1, All), 2)");
} catch (Exception e) {
e.printStackTrace();
assertEquals("", e.getMessage());
}
}
Aggregations