Skip to content

Commit

Permalink
Issue #18 Javadoc - Setting for disabling lazy evaluation of
Browse files Browse the repository at this point in the history
multiplication

More tests to show the differences
  • Loading branch information
axkr committed Mar 5, 2018
1 parent 147fc50 commit 570edac
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,29 @@ public static boolean isFileSystemEnabled(EvalEngine engine) {
}

/**
* If <code>true</code> the <code>*</code> operator must be written for a <code>Times()</code> expression.
* <p>
* If <code>true</code> the <code>*</code> operator must be written for a <code>Times()</code> expression. I.e. you
* cannot write <code>2(b+c)</code> anymore, but have to write <code>2*(b+c)</code> to get
* <code>Times(2, Plus(b, c))</code>.
* </p>
* <p>
* You also enable <a href="https://en.wikipedia.org/wiki/Scientific_notation#E-notation">scientific E-notation</a>.
* I.e. <code>1E-2</code> is converted to a double value <code>0.01</code> for floating point numbers and not parsed
* as <code>Plus(-2, E)</code> anymore.
* </p>
* <p>
* You also enable integer literal input with a prefix, similar to
* <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">Java integer literals</a>
* <ul>
* <li><code>0b</code> or <code>0B</code> for binary numbers</li>
* <li><code>0x</code> or <code>0X</code> for hexadecimal numbers</li>
* <li><code>0o</code> or <code>0O</code> for octal numbers</li>
* </ul>
* </p>
* <p>
*
* </p>
* <p>
*/
public static boolean EXPLICIT_TIMES_OPERATOR = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ public void testSystem004() {
check("Chop(2.0+I*(-2.4492935982947064E-16))", "2.0+I*(-22.65787)");
check("Chop((-2.4492935982947064E-16)+I*0.5)", "-22.65787+I*0.5");

check("Chop({2.0+I*(-2.4492935982947064E-16),(-2.4492935982947064E-16)+I*0.5})", "{2.0+I*(-22.65787),-22.65787+I*0.5}");
check("Chop({2.0+I*(-2.4492935982947064E-16),(-2.4492935982947064E-16)+I*0.5})",
"{2.0+I*(-22.65787),-22.65787+I*0.5}");
} else {
check("Chop((-2.4492935982947064E-16)+I*(-1.0E-19))", "0");
check("Chop(2.0+I*(-2.4492935982947064E-16))", "2.0");
Expand Down Expand Up @@ -3604,12 +3605,20 @@ public void testGithub18() {
try {
Config.EXPLICIT_TIMES_OPERATOR = false;
if (!Config.EXPLICIT_TIMES_OPERATOR) {
check("2(b+c) // FullForm", "\"Times(2, Plus(b, c))\"");
check("2(b+c)3 // FullForm", "\"Times(6, Plus(b, c))\"");
check("a(b+c) // FullForm", "\"a(Plus(b, c))\"");
check("a*(b+c) // FullForm", "\"Times(a, Plus(b, c))\"");
check("1E-2 // FullForm", "\"Plus(-2, E)\"");
checkNumeric("1.0E-2 // FullForm", "\"0.7182818284590451\"");
check("2(b+c) // FullForm", //
"\"Times(2, Plus(b, c))\"");
check("2(b+c)3 // FullForm", //
"\"Times(6, Plus(b, c))\"");
check("a(b+c) // FullForm", //
"\"a(Plus(b, c))\"");
check("a*(b+c) // FullForm", //
"\"Times(a, Plus(b, c))\"");
check("1E-2 // FullForm", //
"\"Plus(-2, E)\"");
check("1E+2 // FullForm", //
"\"Plus(2, E)\"");
checkNumeric("1.0E-2 // FullForm", //
"\"0.7182818284590451\"");
checkNumeric("1x-2 // FullForm", //
"\"Plus(-2, x)\"");
check("N(1E-2)", "0.71828");
Expand All @@ -3619,19 +3628,24 @@ public void testGithub18() {
}
Config.EXPLICIT_TIMES_OPERATOR = true;
if (Config.EXPLICIT_TIMES_OPERATOR) {
check("2(b+c)", "Syntax error in line: 1 - End-of-file not reached.\n" +
"2(b+c)\n" +
" ^");
check("2(b+c)3 // FullForm", "Syntax error in line: 1 - End-of-file not reached.\n" +
"2(b+c)3 // FullForm\n" +
" ^");
check("2*(b+c) // FullForm", "\"Times(2, Plus(b, c))\"");
check("2*(b+c)*3 // FullForm", "\"Times(6, Plus(b, c))\"");
check("a(b+c) // FullForm", "\"a(Plus(b, c))\"");
check("a*(b+c) // FullForm", "\"Times(a, Plus(b, c))\"");
check("2(b+c)", //
"Syntax error in line: 1 - End-of-file not reached.\n" + "2(b+c)\n" + " ^");
check("2(b+c)3 // FullForm",
"Syntax error in line: 1 - End-of-file not reached.\n" + "2(b+c)3 // FullForm\n" + " ^");
check("2*(b+c) // FullForm", //
"\"Times(2, Plus(b, c))\"");
check("2*(b+c)*3 // FullForm", //
"\"Times(6, Plus(b, c))\"");
check("a(b+c) // FullForm", //
"\"a(Plus(b, c))\"");
check("a*(b+c) // FullForm", //
"\"Times(a, Plus(b, c))\"");
check("1E-2 // FullForm", //
"\"0.01\"");
checkNumeric("1.0E-2 // FullForm", "\"0.01\"");
check("1E+2 // FullForm", //
"\"100.0\"");
checkNumeric("1.0E-2 // FullForm", //
"\"0.01\"");
checkNumeric("1x-2 // FullForm", //
"Syntax error in line: 1 - End-of-file not reached.\n" + //
"1x-2 // FullForm\n" + //
Expand All @@ -3643,7 +3657,8 @@ public void testGithub18() {
"Syntax error in line: 1 - End-of-file not reached.\n" + //
"0y1\n" + //
" ^");
checkNumeric("-3.1434555694057773E-11", "-3.143455569405777E-11");
checkNumeric("-3.1434555694057773E-11", //
"-3.143455569405777E-11");
}
} finally {
Config.EXPLICIT_TIMES_OPERATOR = old;
Expand Down

0 comments on commit 570edac

Please sign in to comment.