Skip to content

Add tests for escapes, shorthand names, trailing commas and booleans - #121

Merged
gregsdennis merged 1 commit into
jsonpath-standard:mainfrom
christoph-sens:tests-escapes-shorthands-boolean-ordering
Oct 13, 2026
Merged

gregsdennis merged 1 commit into
jsonpath-standard:mainfrom
christoph-sens:tests-escapes-shorthands-boolean-ordering

Conversation

@christoph-sens

Copy link
Copy Markdown

Nine tests for cases the suite doesn't cover yet. Differential testing found each of them as a bug in jsonpath-rfc9535, which passes all 706 existing tests. All six bugs are fixed in 2.0.1, thanks to @jg-rp (#24, #25, #26, #27).

Test Selector Expected RFC 9535
name selector, double/single quotes, escaped control character $["\u001f"] ["A"], path $['\u001f'] escapable allows %x75 hexchar, and non-surrogate covers 0000–001F; only unescaped control characters are excluded (2.3.1.1)
name selector, double/single quotes, escaped é, lower case hex e $["\u00e9"] ["A"] HEXDIG is case-insensitive (RFC 5234). The existing lower-case test (\u263a) only uses a
name shorthand, supplementary plane character $.😀 ["A"] name-first includes %xE000-10FFFF (2.5.1.1). The existing test ($.☺) stays in the BMP
name shorthand, hyphen $.a-b invalid - is not a name-char
selector, trailing comma, space $[0, ] invalid bracketed-selection needs a selector after every comma. The existing test $[0,] has no blank
filter, greater than false, number $[?@.a>false] on a: 0 and a: 1 [] < is true only if both values are numbers or both are strings (2.3.5.2.2). The existing boolean tests compare booleans only with booleans and strings
filter, less than or equal to true, number $[?@.a<=true] on a: 0 and a: 1 [] as above; <= is also not true through ==

cts.json is regenerated with build.sh. The diff only adds tests.

Checked against two implementations: jsonpath-rfc9535 2.0.1 and Treetrail (Java, my implementation) pass all 715 tests, and jsonpath-rfc9535 2.0.0 fails all nine new ones.

🤖 Generated with Claude Code

Nine tests for cases the suite does not cover yet, each of which an
implementation got wrong while passing every existing test:

- name selector: \u escapes for control characters (\u001f) and with the
  hex digit e in lower case (\u00e9), in both quote styles
- name shorthand: a supplementary plane character ($.😀) is valid, a
  hyphen ($.a-b) is not
- a trailing comma followed by a blank ($[0, ]) is invalid
- ordering comparisons between a boolean and a number select nothing

Found by differential testing against jsonpath-rfc9535, see
jg-rp/python-jsonpath-rfc9535#24, jsonpath-standard#25, jsonpath-standard#26 and jsonpath-standard#27.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@glyn glyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests look correct to me.

@gregsdennis PTAL

@gregsdennis

Copy link
Copy Markdown
Collaborator

I'll run these through my implementation tonight.

@f3ath f3ath left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, works with my impl.

@gregsdennis

Copy link
Copy Markdown
Collaborator

These all look right to me. I'll run it when I can (probably would highlight a bug in my implementation more than anything wrong here). I think we're good to merge.

@gregsdennis
gregsdennis merged commit 20ebdcc into jsonpath-standard:main Oct 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants