about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2023-01-20T23·47-0800
committerclbot <clbot@tvl.fyi>2023-01-20T23·50+0000
commite20c0d2fbf5dfb1355c1375fd6ae1f9bf1b8b263 (patch)
treeca2cedf8003b31809756a7ed3b55b558b3cbb662
parent7f37cfb184780748ba9c07b483635699ba0a0af2 (diff)
fix(wpcarro/slx): Fix LTE/GTE parsing error r/5718
Fix: `i += 2`. Welp!
Change-Id: I06061f0c5bb5283c8b85bd3f5a6e52e2eb59d4f5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7885
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
-rw-r--r--users/wpcarro/slx.js/index.js4
-rw-r--r--users/wpcarro/slx.js/tests.js8
2 files changed, 8 insertions, 4 deletions
diff --git a/users/wpcarro/slx.js/index.js b/users/wpcarro/slx.js/index.js
index d255bb99f9..3729978c75 100644
--- a/users/wpcarro/slx.js/index.js
+++ b/users/wpcarro/slx.js/index.js
@@ -166,7 +166,7 @@ function tokenize(x) {
         }
         if (x[i] === '<' && i + 1 < x.length && x[i + 1] === '=') {
             result.push(['COMPARE', 'LTE']);
-            i += 1;
+            i += 2;
             continue;
         }
         if (x[i] === '<') {
@@ -176,7 +176,7 @@ function tokenize(x) {
         }
         if (x[i] === '>' && i + i < x.length && x[i + 1] === '=') {
             result.push(['COMPARE', 'GTE']);
-            i += 1;
+            i += 2;
             continue;
         }
         if (x[i] === '>') {
diff --git a/users/wpcarro/slx.js/tests.js b/users/wpcarro/slx.js/tests.js
index 5e8b53d86d..9ed68a588c 100644
--- a/users/wpcarro/slx.js/tests.js
+++ b/users/wpcarro/slx.js/tests.js
@@ -15,7 +15,11 @@ const cfg = {
     dateKey: 'birthday',
 };
 const tests = [
-    ['support numeric comparisons', 'age=83', xs, cfg, [john]],
+    ['support EQ', 'age=83', xs, cfg, [john]],
+    ['supports LT', 'age<83', xs, cfg, [graham]],
+    ['supports LTE', 'age<=83', xs, cfg, [john, graham]],
+    ['supports GT', 'age>48', xs, cfg, [john]],
+    ['supports GTE', 'age>=48', xs, cfg, [john, graham]],
     ['supports grouping (1)', 'last:/^C/ (age=83 OR age=48)', xs, cfg, [john, graham]],
     ['supports grouping (2)', '(age=83)', xs, cfg, [john]],
     ['supports grouping (3)', '(age=83 OR age=48)', xs, cfg, [john, graham]],
@@ -44,7 +48,7 @@ class App extends React.Component {
                     const [label, query, xs, cfg, expected] = test;
                     const actual = select(query, xs, cfg);
                     return (
-                        <tr>
+                        <tr style={{backgroundColor: equal(actual, expected) ? null : 'red'}}>
                           <td>{equal(actual, expected) ? "pass" : "fail"}</td>
                           <td>{label}</td>
                           <td>select("{query}", {JSON.stringify(xs)}, {JSON.stringify(cfg)})</td>