Repository: MiSawa/xq (rust)

Issue:
Panics on comparison of booleans
Comparison on booleans panics.

```sh
 $ xq -n 'false < true'
thread 'main' panicked at 'internal error: entered unreachable code', src/intrinsic/comparator.rs:99:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

xq: 0.1.0-d3808e624efc78b26ebd3c464bea59132f83aec8

Pull request description:
Fix boolean comparison. Resolves #15

Patch:
diff --git a/src/intrinsic/comparator.rs b/src/intrinsic/comparator.rs
index fc41f92..a603c02 100644
--- a/src/intrinsic/comparator.rs
+++ b/src/intrinsic/comparator.rs
@@ -73,6 +73,7 @@ impl<'a> Ord for ComparableValue<'a> {
             (Null, Null) | (Boolean(true), Boolean(true)) | (Boolean(false), Boolean(false)) => {
                 Equal
             }
+            (Boolean(lhs), Boolean(rhs)) => Ord::cmp(lhs, rhs),
             (Number(lhs), Number(rhs)) => Ord::cmp(&lhs, &rhs),
             (String(lhs), String(rhs)) => Ord::cmp(&lhs, &rhs),
             (Array(lhs), Array(rhs)) => Iterator::cmp(


Test patch:
diff --git a/tests/hand_written/mod.rs b/tests/hand_written/mod.rs
index 9d9711a..11f6091 100644
--- a/tests/hand_written/mod.rs
+++ b/tests/hand_written/mod.rs
@@ -44,3 +44,30 @@ test!(
     "3.9 2147483647 2147483648.0"
     "#
 );
+
+test!(
+    boolean_comparison,
+    r#"
+    [
+    false < false, false < true, true < false, false < false,
+    false <= false, false <= true, true <= false, false <= false,
+    false > false, false > true, true > false, false > false,
+    false >= false, false >= true, true >= false, false >= false,
+    false == false, false == true, true == false, false == false,
+    false != false, false != true, true != false, false != false
+    ]
+    "#,
+    r#"
+    null
+    "#,
+    r#"
+    [
+    false, true, false, false,
+    true, true, false, true,
+    false, false, true, false,
+    true, false, true, true,
+    true, false, false, true,
+    false, true, true, false
+    ]
+    "#
+);
\ No newline at end of file