Skip to content

feat(tests): comprehensive RFC 3987 §2.2 grammar test data - #42

Closed
jkowalleck with Copilot wants to merge 13 commits into
mainfrom
copilot/update-rfc3987-test-data
Closed

jkowalleck with Copilot wants to merge 13 commits into
mainfrom
copilot/update-rfc3987-test-data

Conversation

Copilot AI commented Jul 20, 2026 •

Copy link
Copy Markdown

Both JSON test-data files were sparse — valid_syntax.json had only 3 of 39 sections populated, and invalid_syntax.json had 5 empty sections. RFC 3987 §2.2 is the sole source of truth; no alignment with repo implementation was attempted.

valid_syntax.json (3 → 39 populated sections, 352 total entries)

  • Every grammar production now has cases for: minimal/bare forms, boundary values, structural alternatives, and representative Unicode
  • Key additions per production:
    • scheme: minimal s:, boundary alpha/digit/+/-/. chars
    • iuserinfo / ireg-name: empty, unreserved, pct-encoded, ucschar variants
    • IPv4 / IPv6 / IPvFuture: all 9 IPv6 forms; all 5 dec-octet alternatives; v1.test IPvFuture
    • ipath (all 5 forms): empty, abempty, absolute, rootless, noscheme — each with empty/single/multi-segment variants
    • iquery / ifragment: ipchar + iprivate mix; empty values
    • ucschar / iprivate: boundary codepoints for every defined range (%xA0, %xD7FF, %xF900, %xFDCF, %xFDF0, %xFFEF, plane ranges)
    • pct-encoded: uppercase/lowercase hex, all-zeros %00, %FF

invalid_syntax.json (5 empty sections filled, 545 total entries)

  • isegment-nz-nc: colon forbidden in first segment (a:b); bare colon; space
  • ipath-noscheme: colon-bearing first segment; space; percent-encoding with invalid hex
  • ipath: space; bare ?; bare # (reserved delimiters not allowed in path)
  • irelative-part: missing // before authority; invalid authority chars
  • irelative-ref: fragment-only without #; query-only without ?; space in path

Encoding

  • U+00A0 and all private-use area characters (E000–F8FF, F0000–FFFFD, 100000–10FFFD) stored as explicit \uXXXX escapes (uppercase) to prevent visual ambiguity with ASCII space and other invisible characters.

No tests were run per task constraints. RFC 3987 §2.2 grammar was used as the sole source of truth.

Copilot AI added 7 commits July 20, 2026 10:25
- Populate all 30+ previously empty arrays in valid_syntax.json with
  RFC-driven test cases covering every grammar production in RFC 3987 §2.2:
  ucschar, iunreserved, sub_delims, iuserinfo, h16, dec_octet, ls32,
  ipv6address (all 9 forms), unreserved, ipvfuture, ip_literal, ireg_name,
  ihost, port, iauthority, ipchar, isegment, ipath_abempty, isegment_nz,
  ipath_absolute, ipath_rootless, ipath_empty, ihier_part, iprivate, iquery,
  gen_delims, ifragment, isegment_nz_nc, ipath_noscheme, ipath,
  irelative_part, irelative_ref, reserved, scheme, pct_encoded, ipv4address

- Add invalid test cases to 5 previously empty sections in invalid_syntax.json:
  isegment_nz_nc, ipath_noscheme, ipath, irelative_part, irelative_ref

- Remove RFC-wrong entry: a new IRI entry added by the script using literal
  ASCII asterisks '******example.com:...' was invalid (asterisk is not a
  valid scheme character; scheme must start with ALPHA). Removed.

- All existing entries preserved (no deduplication).
- Source of truth: RFC 3987 §2.2 grammar exclusively.
- No tests were run per task instructions.
…t data

Re-serialize both JSON files with ensure_ascii=True so all non-ASCII
characters (especially invisible private-use area chars like U+E000 and
ucschar boundary values like U+00A0) appear as explicit \\uXXXX escape
sequences. This makes the intent unambiguous in JSON source review.
The previous ensure_ascii=True commit introduced an ambiguous \u10ffFF
representation for the existing iprivate test entry (U+10FF followed by
literal 'FF'). Revert to raw UTF-8 (ensure_ascii=False) which matches
the original file style and avoids this ambiguity. The 'reason' field
for each entry explicitly identifies codepoints by name/number.
In isegment_nz_nc, ipath_noscheme and ipath invalid entries, update
reason text to say 'ASCII space (U+0020)' rather than just 'space',
to avoid confusion with U+00A0 NO-BREAK SPACE which IS valid as a
ucschar within iunreserved and thus allowed in path segments.
Use explicit \uXXXX notation for U+00A0 (NO-BREAK SPACE) in value fields
so they are visually distinct from ASCII space (U+0020). Also escape all
private-use area characters (BMP E000-F8FF, Plane 15 F0000-FFFFD,
Plane 16 100000-10FFFD) for clarity. Visible characters (CJK, Arabic,
Hebrew etc.) remain as raw UTF-8.
Normalise lowercase \uXXXX to uppercase \uXXXX throughout both JSON
files for consistency with the uppercase codepoint notation used in
reason strings (e.g. "U+00A0").
Add "NO-BREAK SPACE" name to U+00A0 references in the ipath_noscheme
and ipath invalid-space entry reason strings, matching the explicit
style used elsewhere in the file.
Copilot AI changed the title [WIP] Update RFC3987 syntax test-data JSON files for grammar compliance feat(tests): comprehensive RFC 3987 §2.2 grammar test data Jul 20, 2026
Copilot AI requested a review from jkowalleck July 20, 2026 10:34
Comment thread tests/test_syntax.py Outdated
yield pytest.param(term, example, id=f"{term}-{example['value']}")


def test_fixture_json_files_are_ascii_only() -> None:

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.

@copilot remove this test. we dont wnat this.

futhermore, add .gitattributes and .editor conf file in that _data dir, and make sire that the files in there are treated as binady by git, and that we wnat the JSON files to be ascii

add a comemnt descibing that this is for compatibility purposes here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 7fc0c0a.

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.

2 participants