From 2f385c83eb78851623ade4deb05753625b34ef4d Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 20 Oct 2011 15:59:24 +0400 Subject: [PATCH] simplify feature changes --- .../jscl/FromJsclNumericTextProcessor.java | 6 +- .../calculator/jscl/JsclOperation.java | 3 +- .../android/calculator/math/Functions.java | 12 +-- .../android/calculator/math/MathType.java | 16 +++- .../calculator/model/DummyTextProcessor.java | 2 +- .../model/FromJsclSimplifyTextProcessor.java | 96 +++++++++++++++++++ .../calculator/model/ParseException.java | 5 + .../calculator/model/ToJsclTextProcessor.java | 22 +++-- .../calculator/model/VarsRegisterImpl.java | 4 +- .../model/CalculatorEngineTest.java | 4 +- .../FromJsclSimplifyTextProcessorTest.java | 32 +++++++ .../model/ToJsclTextProcessorTest.java | 55 ++++++++--- 12 files changed, 217 insertions(+), 40 deletions(-) create mode 100644 src/main/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessor.java create mode 100644 src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java diff --git a/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java b/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java index 3809f4fe..216bc897 100644 --- a/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java +++ b/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java @@ -32,10 +32,10 @@ class FromJsclNumericTextProcessor implements TextProcessor { result = String.valueOf(roundedValue); } } catch (NumberFormatException e) { - result = result.replace(MathType.INFINITY_DEF, MathType.INFINITY); - if (result.contains(MathType.IMAGINARY_NUMBER_DEF)) { + result = result.replace(MathType.INFINITY_JSCL, MathType.INFINITY); + if (result.contains(MathType.IMAGINARY_NUMBER_JSCL)) { try { - result = createResultForComplexNumber(result.replace(MathType.IMAGINARY_NUMBER_DEF, MathType.IMAGINARY_NUMBER)); + result = createResultForComplexNumber(result.replace(MathType.IMAGINARY_NUMBER_JSCL, MathType.IMAGINARY_NUMBER)); } catch (NumberFormatException e1) { // throw original one throw new ParseException(e); diff --git a/src/main/java/org/solovyev/android/calculator/jscl/JsclOperation.java b/src/main/java/org/solovyev/android/calculator/jscl/JsclOperation.java index e12ebdd0..0641b24a 100644 --- a/src/main/java/org/solovyev/android/calculator/jscl/JsclOperation.java +++ b/src/main/java/org/solovyev/android/calculator/jscl/JsclOperation.java @@ -8,11 +8,12 @@ package org.solovyev.android.calculator.jscl; import org.jetbrains.annotations.NotNull; import org.solovyev.android.calculator.model.DummyTextProcessor; +import org.solovyev.android.calculator.model.FromJsclSimplifyTextProcessor; import org.solovyev.android.calculator.model.TextProcessor; public enum JsclOperation { - simplify(DummyTextProcessor.instance), + simplify(new FromJsclSimplifyTextProcessor()), elementary(DummyTextProcessor.instance), importCommands(DummyTextProcessor.instance), numeric(new FromJsclNumericTextProcessor()); diff --git a/src/main/java/org/solovyev/android/calculator/math/Functions.java b/src/main/java/org/solovyev/android/calculator/math/Functions.java index 389290cb..ef8d8298 100644 --- a/src/main/java/org/solovyev/android/calculator/math/Functions.java +++ b/src/main/java/org/solovyev/android/calculator/math/Functions.java @@ -31,20 +31,20 @@ public class Functions { public final static String TANH = "tanh"; public final static String ATAN = "atan"; public final static String ATANH = "atanh"; - public final static String LOG = "log"; + public final static String LN = "ln"; + public final static String LN_JSCL = "log"; + public final static String MOD = "mod"; public final static String EXP = "exp"; - public final static String SQRT_SIGN = "√"; - public final static String SQRT = "sqrt"; - public final static String E = "E"; - public final static String E_POWER = "10^"; + public final static String SQRT = "√"; + public final static String SQRT_JSCL = "sqrt"; public static final List allPrefix; static { - final List functions = new ArrayList(Arrays.asList(SIN, SINH, ASIN, ASINH, COS, COSH, ACOS, ACOSH, TAN, TANH, ATAN, ATANH, LOG, LN, MOD, SQRT, SQRT_SIGN, EXP, E)); + final List functions = new ArrayList(Arrays.asList(SIN, SINH, ASIN, ASINH, COS, COSH, ACOS, ACOSH, TAN, TANH, ATAN, ATANH, LN, LN_JSCL, MOD, SQRT, SQRT_JSCL, EXP)); Collections.sort(functions, new MathEntityComparator()); allPrefix = functions; } diff --git a/src/main/java/org/solovyev/android/calculator/math/MathType.java b/src/main/java/org/solovyev/android/calculator/math/MathType.java index 34a86703..32739f33 100644 --- a/src/main/java/org/solovyev/android/calculator/math/MathType.java +++ b/src/main/java/org/solovyev/android/calculator/math/MathType.java @@ -19,8 +19,9 @@ import static org.solovyev.common.utils.CollectionsUtils.get; public enum MathType { digit, - constant, dot, + power_10, + constant, function, postfix_function, unary_operation, @@ -30,13 +31,16 @@ public enum MathType { close_group_symbol, text; + public final static Character POWER_10 = 'E'; + public final static String POWER_10_JSCL = "10^"; + public static final String IMAGINARY_NUMBER = "i"; - public static final String IMAGINARY_NUMBER_DEF = "sqrt(-1)"; + public static final String IMAGINARY_NUMBER_JSCL = "sqrt(-1)"; public static final String PI = "π"; public static final String E = "e"; public final static String NAN = "NaN"; public final static String INFINITY = "∞"; - public final static String INFINITY_DEF = "Infinity"; + public final static String INFINITY_JSCL = "Infinity"; public static final List constants = Arrays.asList(E, PI, IMAGINARY_NUMBER, NAN, INFINITY); @@ -44,6 +48,7 @@ public enum MathType { public static final List dots = Arrays.asList('.'); + public static final List unaryOperations = Arrays.asList('-', '=', '!'); public static final List binaryOperations = Arrays.asList('-', '+', '*', '×', '∙', '/', '^'); @@ -88,6 +93,11 @@ public enum MathType { return new Result(dot, String.valueOf(foundCharacter)); } + foundCharacter = characterStartWithFinder.isFound(POWER_10) ? POWER_10 : null; + if (foundCharacter != null) { + return new Result(power_10, String.valueOf(foundCharacter)); + } + foundCharacter = get(postfixFunctions, characterStartWithFinder); if (foundCharacter != null) { return new Result(postfix_function, String.valueOf(foundCharacter)); diff --git a/src/main/java/org/solovyev/android/calculator/model/DummyTextProcessor.java b/src/main/java/org/solovyev/android/calculator/model/DummyTextProcessor.java index bad92e21..02974bf2 100644 --- a/src/main/java/org/solovyev/android/calculator/model/DummyTextProcessor.java +++ b/src/main/java/org/solovyev/android/calculator/model/DummyTextProcessor.java @@ -20,6 +20,6 @@ public enum DummyTextProcessor implements TextProcessor { @NotNull @Override public String process(@NotNull String s) throws ParseException { - return s.replace(ToJsclTextProcessor.SPECIAL_STRING, ""); + return s; } } diff --git a/src/main/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessor.java b/src/main/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessor.java new file mode 100644 index 00000000..e39a0e35 --- /dev/null +++ b/src/main/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessor.java @@ -0,0 +1,96 @@ +package org.solovyev.android.calculator.model; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.solovyev.android.calculator.StartsWithFinder; +import org.solovyev.android.calculator.math.MathType; +import org.solovyev.common.utils.CollectionsUtils; +import org.solovyev.common.utils.Finder; + +/** + * User: serso + * Date: 10/20/11 + * Time: 2:59 PM + */ +public class FromJsclSimplifyTextProcessor implements TextProcessor { + + @NotNull + @Override + public String process(@NotNull String s) throws ParseException { + final StringBuilder sb = new StringBuilder(); + + MathType.Result mathTypeResult = null; + StringBuilder numberBuilder = null; + String number = null; + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + + mathTypeResult = MathType.getType(s, i); + + final MathType mathType = mathTypeResult.getMathType(); + + number = null; + if (mathType == MathType.digit || mathType == MathType.dot || mathType == MathType.power_10) { + if (numberBuilder == null) { + numberBuilder = new StringBuilder(); + } + numberBuilder.append(mathTypeResult.getMatch()); + } else { + if (numberBuilder != null) { + try { + number = numberBuilder.toString(); + Double.valueOf(number); + } catch (NumberFormatException e) { + number = null; + } + + numberBuilder = null; + } + } + + replaceSystemVars(sb, number); + + if (mathType == MathType.constant) { + sb.append(mathTypeResult.getMatch()); + i += mathTypeResult.getMatch().length() - 1; + } else if (ch == '*') { + sb.append("×"); + } else { + sb.append(ch); + } + } + + if (numberBuilder != null) { + try { + number = numberBuilder.toString(); + Double.valueOf(number); + } catch (NumberFormatException e) { + number = null; + } + + numberBuilder = null; + } + + replaceSystemVars(sb, number); + + return sb.toString(); + } + + private void replaceSystemVars(StringBuilder sb, String number) { + if (number != null) { + final String finalNumber = number; + final Var var = CollectionsUtils.get(CalculatorEngine.instance.getVarsRegister().getSystemVars(), new Finder() { + @Override + public boolean isFound(@Nullable Var var) { + return var != null && finalNumber.equals(var.getValue()); + } + }); + + if (var != null) { + sb.delete(sb.length() - number.length(), sb.length()); + sb.append(var.getName()); + } + } + } + +} diff --git a/src/main/java/org/solovyev/android/calculator/model/ParseException.java b/src/main/java/org/solovyev/android/calculator/model/ParseException.java index 33041bfe..108b32a1 100644 --- a/src/main/java/org/solovyev/android/calculator/model/ParseException.java +++ b/src/main/java/org/solovyev/android/calculator/model/ParseException.java @@ -14,6 +14,11 @@ import org.solovyev.common.exceptions.SersoException; * Time: 9:25 PM */ public class ParseException extends SersoException { + + public ParseException(String message) { + super(message); + } + public ParseException(Throwable cause) { super(cause); } diff --git a/src/main/java/org/solovyev/android/calculator/model/ToJsclTextProcessor.java b/src/main/java/org/solovyev/android/calculator/model/ToJsclTextProcessor.java index ddb9c39c..2ad284d8 100644 --- a/src/main/java/org/solovyev/android/calculator/model/ToJsclTextProcessor.java +++ b/src/main/java/org/solovyev/android/calculator/model/ToJsclTextProcessor.java @@ -21,11 +21,9 @@ import java.util.List; class ToJsclTextProcessor implements TextProcessor { - public static final String SPECIAL_STRING = "☀☀☀"; - @Override @NotNull - public PreparedExpression process(@NotNull String s) { + public PreparedExpression process(@NotNull String s) throws ParseException { final StartsWithFinder startsWithFinder = new StartsWithFinder(s, 0); final StringBuilder sb = new StringBuilder(); @@ -44,6 +42,8 @@ class ToJsclTextProcessor implements TextProcessor { sb.append(')'); } else if (ch == '×' || ch == '∙') { sb.append("*"); + } else if (mathType == MathType.power_10) { + sb.append(MathType.POWER_10_JSCL); } else if (mathType == MathType.function) { sb.append(toJsclFunction(mathTypeResult.getMatch())); i += mathTypeResult.getMatch().length() - 1; @@ -51,9 +51,10 @@ class ToJsclTextProcessor implements TextProcessor { // NOTE: fix for jscl for EMPTY functions processing (see tests) startsWithFinder.setI(i + 1); if ( i < s.length() && CollectionsUtils.get(MathType.groupSymbols, startsWithFinder) != null) { - i += 2; + throw new ParseException("Empty function: " + mathTypeResult.getMatch()); + /*i += 2; sb.append("(" + SPECIAL_STRING + ")"); - mathTypeResult = new MathType.Result(MathType.close_group_symbol, ")"); + mathTypeResult = new MathType.Result(MathType.close_group_symbol, ")");*/ } } else if (mathType == MathType.constant) { sb.append(mathTypeResult.getMatch()); @@ -167,11 +168,9 @@ class ToJsclTextProcessor implements TextProcessor { final String result; if (function.equals(Functions.LN)) { - result = Functions.LOG; - } else if (function.equals(Functions.SQRT_SIGN)) { - result = Functions.SQRT; - } else if (function.equals(Functions.E)) { - result = Functions.E_POWER; + result = Functions.LN_JSCL; + } else if (function.equals(Functions.SQRT)) { + result = Functions.SQRT_JSCL; } else { result = function; } @@ -215,11 +214,14 @@ class ToJsclTextProcessor implements TextProcessor { if (mathTypeBefore == MathType.constant || (mathTypeBefore != MathType.binary_operation && mathTypeBefore != MathType.unary_operation && + mathTypeBefore != MathType.power_10 && mathTypeBefore != MathType.function && mathTypeBefore != MathType.open_group_symbol)) { if (mathType == MathType.constant) { sb.append("*"); + } else if (mathType == MathType.power_10) { + sb.append("*"); } else if (mathType == MathType.open_group_symbol && mathTypeBefore != null) { sb.append("*"); } else if (mathType == MathType.digit && ((mathTypeBefore != MathType.digit && mathTypeBefore != MathType.dot) || mathTypeBefore == MathType.constant)) { diff --git a/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java b/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java index bd5fd353..724ba5a5 100644 --- a/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java +++ b/src/main/java/org/solovyev/android/calculator/model/VarsRegisterImpl.java @@ -149,13 +149,13 @@ class VarsRegisterImpl implements VarsRegister { builder = new Var.Builder(systemVarName, Math.PI); varDescription = R.string.c_pi_description; } else if (systemVarName.equals(MathType.IMAGINARY_NUMBER)) { - builder = new Var.Builder(systemVarName, MathType.IMAGINARY_NUMBER_DEF); + builder = new Var.Builder(systemVarName, MathType.IMAGINARY_NUMBER_JSCL); varDescription = R.string.c_i_description; } else if (systemVarName.equals(MathType.NAN)) { builder = new Var.Builder(systemVarName, MathType.NAN); varDescription = R.string.c_nan_description; } else if (systemVarName.equals(MathType.INFINITY)) { - builder = new Var.Builder(systemVarName, MathType.INFINITY_DEF); + builder = new Var.Builder(systemVarName, MathType.INFINITY_JSCL); varDescription = R.string.c_infinity_description; } else { throw new IllegalArgumentException(systemVarName + " is not supported yet!"); diff --git a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java index 857cbd03..cede9000 100644 --- a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java +++ b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java @@ -52,13 +52,13 @@ public class CalculatorEngineTest { try { cm.evaluate(JsclOperation.numeric, "cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos(cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos())))))))))))))))))))))))))))))))))))))"); Assert.fail(); - } catch (EvalError e){ + } catch (ParseException e){ } Assert.assertEquals("NaN", cm.evaluate(JsclOperation.numeric, "ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(100)))))))))))))))")); try { cm.evaluate(JsclOperation.numeric, "cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos())))))))))))))))))))))))))))))))))))"); Assert.fail(); - } catch (EvalError e){ + } catch (ParseException e){ } Assert.assertEquals("0.73909", cm.evaluate(JsclOperation.numeric, "cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(1))))))))))))))))))))))))))))))))))))")); diff --git a/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java b/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java new file mode 100644 index 00000000..49503d8d --- /dev/null +++ b/src/test/java/org/solovyev/android/calculator/model/FromJsclSimplifyTextProcessorTest.java @@ -0,0 +1,32 @@ +package org.solovyev.android.calculator.model; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.solovyev.android.calculator.jscl.JsclOperation; + +/** + * User: serso + * Date: 10/20/11 + * Time: 3:43 PM + */ +public class FromJsclSimplifyTextProcessorTest { + + @BeforeClass + public static void setUp() throws Exception { + CalculatorEngine.instance.init(null, null); + } + + @Test + public void testProcess() throws Exception { + FromJsclSimplifyTextProcessor tp = new FromJsclSimplifyTextProcessor(); + Assert.assertEquals("t11×e", tp.process("t11*2.718281828459045")); + Assert.assertEquals("e", tp.process("2.718281828459045")); + Assert.assertEquals("te×e", tp.process("t2.718281828459045*2.718281828459045")); + + CalculatorEngine.instance.getVarsRegister().addVar(null, new Var.Builder("t2.718281828459045", "2")); + Assert.assertEquals("t2.718281828459045×e", tp.process("t2.718281828459045*2.718281828459045")); + + } +} diff --git a/src/test/java/org/solovyev/android/calculator/model/ToJsclTextProcessorTest.java b/src/test/java/org/solovyev/android/calculator/model/ToJsclTextProcessorTest.java index 6f92077e..b82fa384 100644 --- a/src/test/java/org/solovyev/android/calculator/model/ToJsclTextProcessorTest.java +++ b/src/test/java/org/solovyev/android/calculator/model/ToJsclTextProcessorTest.java @@ -9,6 +9,7 @@ package org.solovyev.android.calculator.model; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import org.solovyev.android.calculator.jscl.JsclOperation; /** * User: serso @@ -26,19 +27,49 @@ public class ToJsclTextProcessorTest { public void testProcess() throws Exception { final ToJsclTextProcessor preprocessor = new ToJsclTextProcessor(); - Assert.assertEquals( "sin(4)*cos(5)", preprocessor.process("sin(4)cos(5)")); - Assert.assertEquals( "3.141592653589793*sin(4)*3.141592653589793*cos(sqrt(5))", preprocessor.process("πsin(4)πcos(√(5))")); - Assert.assertEquals( "3.141592653589793*sin(4)+3.141592653589793*cos(sqrt(5))", preprocessor.process("πsin(4)+πcos(√(5))")); - Assert.assertEquals( "3.141592653589793*sin(4)+3.141592653589793*cos(sqrt(5+sqrt(-1)))", preprocessor.process("πsin(4)+πcos(√(5+i))")); - Assert.assertEquals( "3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))", preprocessor.process("πsin(4.01)+πcos(√(5+i))")); - Assert.assertEquals( "2.718281828459045^3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))", preprocessor.process("e^πsin(4.01)+πcos(√(5+i))")); - Assert.assertEquals( "2.718281828459045^3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))*10^2", preprocessor.process("e^πsin(4.01)+πcos(√(5+i))E2")); - Assert.assertEquals( "2.718281828459045^3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))*10^-2", preprocessor.process("e^πsin(4.01)+πcos(√(5+i))E-2")); - Assert.assertEquals( "log(foo)", preprocessor.process("ln()")); - Assert.assertEquals( "log(foo)*log(foo)", preprocessor.process("ln()ln()")); - Assert.assertEquals( "2.718281828459045*log(foo)*2.718281828459045*log(foo)*log(foo)*log(foo)*log(foo)*2.718281828459045", preprocessor.process("eln()eln()ln()ln()ln()e")); - Assert.assertEquals( "log(log(log(log(log(log(log(log(log(log(log(log(log(log(log(foo)))))))))))))))", preprocessor.process("ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln()))))))))))))))")); + Assert.assertEquals( "sin(4)*asin(0.5)*sqrt(2)", preprocessor.process("sin(4)asin(0.5)sqrt(2)").toString()); + Assert.assertEquals( "sin(4)*cos(5)", preprocessor.process("sin(4)cos(5)").toString()); + Assert.assertEquals( "3.141592653589793*sin(4)*3.141592653589793*cos(sqrt(5))", preprocessor.process("πsin(4)πcos(√(5))").toString()); + Assert.assertEquals( "3.141592653589793*sin(4)+3.141592653589793*cos(sqrt(5))", preprocessor.process("πsin(4)+πcos(√(5))").toString()); + Assert.assertEquals( "3.141592653589793*sin(4)+3.141592653589793*cos(sqrt(5+sqrt(-1)))", preprocessor.process("πsin(4)+πcos(√(5+i))").toString()); + Assert.assertEquals( "3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))", preprocessor.process("πsin(4.01)+πcos(√(5+i))").toString()); + Assert.assertEquals( "2.718281828459045^3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))", preprocessor.process("e^πsin(4.01)+πcos(√(5+i))").toString()); + Assert.assertEquals( "2.718281828459045^3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))*10^2", preprocessor.process("e^πsin(4.01)+πcos(√(5+i))E2").toString()); + Assert.assertEquals( "2.718281828459045^3.141592653589793*sin(4.01)+3.141592653589793*cos(sqrt(5+sqrt(-1)))*10^-2", preprocessor.process("e^πsin(4.01)+πcos(√(5+i))E-2").toString()); + Assert.assertEquals( "10^2", preprocessor.process("E2").toString()); + Assert.assertEquals( "10^-2", preprocessor.process("E-2").toString()); + Assert.assertEquals( "10^-1/2", preprocessor.process("E-1/2").toString()); + Assert.assertEquals( "10^-1.2", preprocessor.process("E-1.2").toString()); + Assert.assertEquals( "10^(-1.2)", preprocessor.process("E(-1.2)").toString()); + Assert.assertEquals( "10^10^", preprocessor.process("EE").toString()); + try { + preprocessor.process("ln()"); + Assert.fail(); + } catch (ParseException e) { + } + try { + preprocessor.process("ln()ln()"); + Assert.fail(); + } catch (ParseException e) { + } + try { + preprocessor.process("eln()eln()ln()ln()ln()e"); + Assert.fail(); + } catch (ParseException e) { + } + + try { + preprocessor.process("ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln(ln()))))))))))))))"); + Assert.fail(); + } catch (ParseException e) { + } + + try { + preprocessor.process("cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos(cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos())))))))))))))))))))))))))))))))))))))"); + Assert.fail(); + } catch (ParseException e) { + } } @Test