Repository: jsonata-js/jsonata (js)

Issue:
$boolean(arg) when arg is no-match
Just a query. I wanted something that returns "true" if a arg path evaluates to truthy, and "false" if falsey or not found (no match).

data:
```
{
  "_formValues": {
    "test": true
  }
}
```

Jsonata expressiosn:

`$not(_formValues.test)` returns `false`
`$not(_formValues.test2)` returns `true`

But: 

`$boolean(_formValues.test)` returns `true`
`$boolean(_formValues.test2)` returns `*no match*`

I found it a bit inconsistent that a `$boolean(arg)` can return `*no match*`. Should it be returning `false` instead when hit against a *no match*? Or perhaps someone can explain why this is perfectly good and logical :)

Using: Jsonata 1.8.2 (as in the exerciser)

Pull request description:
$not on empty sequence should return empty sequence
resolves #433 

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>

Patch:
diff --git a/src/functions.js b/src/functions.js
index 9ba8d43..00a6b87 100644
--- a/src/functions.js
+++ b/src/functions.js
@@ -1433,6 +1433,11 @@ const functions = (() => {
      * @returns {boolean} - NOT arg
      */
     function not(arg) {
+        // undefined inputs always return undefined
+        if (typeof arg === 'undefined') {
+            return undefined;
+        }
+
         return !boolean(arg);
     }
 


Test patch:
diff --git a/test/test-suite/groups/boolean-expresssions/case027.json b/test/test-suite/groups/boolean-expresssions/case027.json
new file mode 100644
index 0000000..95f8404
--- /dev/null
+++ b/test/test-suite/groups/boolean-expresssions/case027.json
@@ -0,0 +1,6 @@
+{
+    "expr": "$not(nothing)",
+    "data": {},
+    "bindings": {},
+    "undefinedResult": true
+}
diff --git a/test/test-suite/groups/function-signatures/case001.json b/test/test-suite/groups/function-signatures/case001.json
index 6ffc064..a614397 100644
--- a/test/test-suite/groups/function-signatures/case001.json
+++ b/test/test-suite/groups/function-signatures/case001.json
@@ -2,5 +2,5 @@
     "expr": "λ($arg)<b:b>{$not($arg)}(foo)",
     "dataset": null,
     "bindings": {},
-    "result": true
-}
\ No newline at end of file
+    "undefinedResult": true
+}