test: hand-coded MDN + WHATWG spec example tests#19
Merged
Conversation
Add two new test files that exercise the canonical examples readers
encounter first when learning URLPattern:
tests/test_spec_examples.py
- WHATWG URLPattern Standard §1.2 shop example:
http{s}?://{:subdomain.}?shop.example/products/:id([0-9]+)#reviews
3 positive matches + 4 negative matches (missing fragment, port
disallowed, search disallowed, non-digit id).
tests/test_mdn_examples.py
- "Using multiple components": kitchen-sink protocol+username+
password+hostname+pathname pattern with full and zero-optional
input matches.
- "Custom prefix and suffix modifiers": {:subdomain.}*example.com
hostname wildcard with named-group expansion across 0–3 labels.
- "Pattern syntax — regex groups": /books/:id(\d+) digit-only
constraint, plus negative cases for letters, trailing junk,
empty id, and signed integers.
23 new test cases, all passing against yarlpattern as-is. The WPT
corpus carries the conformance load; these files document the
pedagogical surface so spec / MDN regressions surface as named
failures.
Part of v0.2.0 roadmap.
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.
Summary
tests/test_spec_examples.pyandtests/test_mdn_examples.py, exercising the canonical examples from the WHATWG URLPattern Standard and MDN.Why these tests are separate from the WPT-corpus suite
The WPT corpus exercises 469 conformance cases by construction, but those entries are terse JSON tuples and not human-readable. The examples written into the prose of the spec and the MDN guide deserve a separate, narrated surface so that:
What's covered
tests/test_spec_examples.py(7 cases)WHATWG URLPattern Standard §1.2 shop example:
#reviews, explicit port disallowed, search disallowed, non-digitidtests/test_mdn_examples.py(16 cases)protocol+username+password+hostname+pathnamepattern with full-population and zero-optional input matches.{:subdomain.}*example.comhostname wildcard with named-group expansion across 0–3 labels, plus 3 negative cases (leading dot, wrong eTLD, trailing dot)./books/:id(\d+)digit-only constraint with 3 positive cases and 4 negative cases (letters, trailing junk, emptyid, signed integers).Test plan
uv run pytest tests/test_spec_examples.py tests/test_mdn_examples.py— 23 passeduv run pytest -q— 603 passed, 19 skipped (was 580 before)just lint— all green (ruff, ty, pyright, semgrep, shellcheck, rumdl, codespell, interrogate, validate-pyproject)Part of the v0.2.0 roadmap.