From 9ea995efca6f9fce1c1659f9b8473e06991b210b Mon Sep 17 00:00:00 2001
From: Tom Robinson <tlrobinson@gmail.com>
Date: Tue, 20 Dec 2016 16:33:10 -0800
Subject: [PATCH] Negative number literal tests

---
 frontend/test/unit/lib/expressions/parser.spec.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/frontend/test/unit/lib/expressions/parser.spec.js b/frontend/test/unit/lib/expressions/parser.spec.js
index b35b2763aeb..19be7d5aa4b 100644
--- a/frontend/test/unit/lib/expressions/parser.spec.js
+++ b/frontend/test/unit/lib/expressions/parser.spec.js
@@ -52,6 +52,10 @@ describe("lib/expressions/parser", () => {
             expect(compile("1 + 2 + 3 * 4 * 5", expressionOpts)).toEqual(["+", 1, 2, ["*", 3, 4, 5]]);
         });
 
+        it("can handle negative number literals", () => {
+            expect(compile("1 + -1", expressionOpts)).toEqual(["+", 1, -1]);
+        });
+
         // quoted field name w/ a space in it
         it("can parse a field with quotes and spaces", () => {
             expect(compile("\"Toucan Sam\" + B", expressionOpts)).toEqual(["+", ['field-id', 10], ['field-id', 2]]);
@@ -75,6 +79,10 @@ describe("lib/expressions/parser", () => {
             expect(compile("Sum(A)", aggregationOpts)).toEqual(["sum", ["field-id", 1]]);
         });
 
+        it("can handle negative number literals in aggregations", () => {
+            expect(compile("-1 * Count", aggregationOpts)).toEqual(["*", -1, ["count"]]);
+        });
+
         it("can parse complex aggregation", () => {
             expect(compile("1 - Sum(A * 2) / Count", aggregationOpts)).toEqual(["-", 1, ["/", ["sum", ["*", ["field-id", 1], 2]], ["count"]]]);
         });
-- 
GitLab