aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/com/healthmarketscience
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2017-10-14 14:38:17 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2017-10-14 14:38:17 +0000
commit389a37297d6a75052c8852002ba6288c3b02f26c (patch)
treeeee058b12945dd375c3dc282ef7a9a1d40f01601 /src/test/java/com/healthmarketscience
parent774d505946db6b249aad04d8ecac506600731c93 (diff)
downloadjackcess-389a37297d6a75052c8852002ba6288c3b02f26c.tar.gz
jackcess-389a37297d6a75052c8852002ba6288c3b02f26c.zip
handle plus as a unary number modifier; handle precedence of plus/minus in more confusing math expressions
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1127 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java/com/healthmarketscience')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java
index f0e5397..6463106 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java
@@ -52,7 +52,9 @@ public class ExpressionatorTest extends TestCase
validateExpr("13", "<ELiteralValue>{13}");
- validateExpr("-42", "<ELiteralValue>{-42}");
+ validateExpr("-42", "<EUnaryOp>{- <ELiteralValue>{42}}");
+
+ validateExpr("(+37)", "<EParen>{(<EUnaryOp>{+ <ELiteralValue>{37}})}");
doTestSimpleBinOp("EBinaryOp", "+", "-", "*", "/", "\\", "^", "&", "Mod");
doTestSimpleBinOp("ECompOp", "<", "<=", ">", ">=", "=", "<>");
@@ -136,10 +138,18 @@ public class ExpressionatorTest extends TestCase
assertEquals(-i, eval("=-(" + i + ")"));
}
+ for(int i = -10; i <= 10; ++i) {
+ assertEquals(i, eval("=+(" + i + ")"));
+ }
+
for(double i : DBLS) {
assertEquals(-i, eval("=-(" + i + ")"));
}
+ for(double i : DBLS) {
+ assertEquals(i, eval("=+(" + i + ")"));
+ }
+
for(int i = -10; i <= 10; ++i) {
for(int j = -10; j <= 10; ++j) {
assertEquals((i + j), eval("=" + i + " + " + j));
@@ -254,7 +264,10 @@ public class ExpressionatorTest extends TestCase
}
}
-
+ assertEquals(37, eval("=30+7"));
+ assertEquals(23, eval("=30+-7"));
+ assertEquals(23, eval("=30-+7"));
+ assertEquals(23, eval("=30-7"));
}
public void testTypeCoercion() throws Exception