Repository navigation
Conversation
Add language-neutral test suite cases for behaviour that the suite does not cover yet: != and = with a missing operand, $match with an undefined input, $merge with empty objects, array constructors on a path in an object field value, conditionals without an else branch in an object field value or in $merge, and $now with a picture string. Co-Authored-By: Claude Code Signed-off-by: Jan Nedbal <jan.nedbal@shipmonk.com>
Add language-neutral test suite cases for $spread with empty and single-key inputs, $map over an empty array, $keys over nested arrays of objects, and $now and $millis. The $now and $millis cases check that one evaluation uses one timestamp. Co-Authored-By: Claude Code Signed-off-by: Jan Nedbal <jan.nedbal@shipmonk.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JSONata ports vendor
test/test-suiteas their conformance bar. The behaviours below have no cases in the suite, and some ports diverge here. This PR adds 35 cases that pin the current reference behaviour. All expected values come from this repo atmaster.Behaviours pinned:
=/!=with a missing operand returnsfalse:missing != null→false. A predicate drops items where the field is missing:items[tag != "b"].id→[1, 4](comparison-operators/case029–case033).$matchwith an undefined input returns undefined, also with a chained.groups[0]:$match(missing, /(a)/).groups[0]→ undefined (new groupfunction-match).$mergeaccepts empty objects, including an object constructor whose fields are all undefined:$merge([{"a": nothing}])→{},$merge([{}, {"b": 1}])→{"b": 1}(function-merge/case005–case008).{"x": items.[{"q": n}]}with two items →{"x": [[{"q": 1}], [{"q": 2}]]}(flattening/case046–case049).$merge:{"a": flag ? {"b": 1}, "c": 2}withflag: false→{"c": 2};$merge([{"a": 1}, flag ? {"b": 2}])→{"a": 1}(conditionals/case009–case012).$now(picture)applies the picture string. All$now()and$millis()calls in one evaluation use the same timestamp, so the cases are deterministic:$now('[Y0001]-[M01]-[D01]') = $fromMillis($millis(), '[Y0001]-[M01]-[D01]')→true(new groupfunction-now).$now()and$millis()return the same value for all calls in one evaluation:($a := $millis(); $sum([1..10000]); $a = $millis())→true. The same shape for$now()also givestrue(function-now/case004, new groupfunction-millis).$spreadreturns undefined for an empty array or object, and unwraps a single-key object:$spread([])→ undefined,$spread({})→ undefined,$spread({"a": 1})→{"a": 1},$spread({"a": 1, "b": 2})→[{"a": 1}, {"b": 2}]. An array input stays an array:$spread([{"a": 1}])→[{"a": 1}](function-spread/case004–case008).$mapover an empty array returns undefined:$map([], function($v){$v})→ undefined,[$map([], function($v){$v})]→[](hof-map/case012–case013).$keysflattens nested arrays of objects:$keys([[{"a": 1}]])→"a",$keys([[{"a": 1}], [{"b": 2}]])→["a", "b"](function-keys/case007–case008).The
=/!=cases pin the behaviour that #476 and #772 discuss. If that behaviour changes, these cases change with it.No engine code changes.
TZ=GMT npm testpasses (lint, 1838 tests, 100% coverage).Signed-off-by: Jan Nedbal jan.nedbal@shipmonk.com
Co-Authored-By: Claude Code
— Claude