use of org.matheclipse.core.form.output.ASCIIPrettyPrinter3 in project symja_android_library by axkr.
the class Console method prettyPrinter3Lines.
private String[] prettyPrinter3Lines(final String inputExpression) {
IExpr result;
final StringWriter buf = new StringWriter();
try {
if (fSeconds <= 0) {
result = fEvaluator.evaluate(inputExpression);
} else {
result = fEvaluator.evaluateWithTimeout(inputExpression, fSeconds, TimeUnit.SECONDS, true);
}
if (result != null) {
if (result.equals(F.Null)) {
return null;
}
ASCIIPrettyPrinter3 strBuffer = new ASCIIPrettyPrinter3();
strBuffer.convert(result);
return strBuffer.toStringBuilder();
}
} catch (final SyntaxError se) {
String msg = se.getMessage();
System.err.println();
System.err.println(msg);
return null;
} catch (final RuntimeException re) {
Throwable me = re.getCause();
if (me instanceof MathException) {
Validate.printException(buf, me);
} else {
Validate.printException(buf, re);
}
return null;
} catch (final Exception e) {
Validate.printException(buf, e);
return null;
} catch (final OutOfMemoryError e) {
Validate.printException(buf, e);
return null;
} catch (final StackOverflowError e) {
Validate.printException(buf, e);
return null;
}
String[] strArray = new String[3];
strArray[0] = "";
strArray[1] = buf.toString();
strArray[3] = "";
return strArray;
}
use of org.matheclipse.core.form.output.ASCIIPrettyPrinter3 in project symja_android_library by axkr.
the class ASCIIPrintTest method check.
private void check(IExpr expr, String str1, String str2, String str3) {
ASCIIPrettyPrinter3 strBuffer = new ASCIIPrettyPrinter3();
strBuffer.convert(expr);
String[] result = strBuffer.toStringBuilder();
assertEquals(result[0].toString(), str1);
assertEquals(result[1].toString(), str2);
assertEquals(result[2].toString(), str3);
}
Aggregations