Repository navigation
Conversation
Seeded generators build valid selectors from a small grammar, arbitrary fragment soup, and arbitrary strings for the setters and constructors. Five properties are checked against them: - invalid input throws the parser's own error, not a TypeError - lossless output reproduces the input - lossy output is stable when parsed and printed again - `sourceIndex` points at the node's own text in the input - a value set through the API reads back the same after printing and parsing They run with `npm run test:property`, outside `npm test`. PROPERTY_RUNS and PROPERTY_SEED set the size and seed. Failures that are already understood are listed in `known.mjs` with what tracks them. Each run reports how many failures every entry explains, and an entry that no longer matches anything is reported so it can go.
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.
Adds the property tests discussed in #359.
npm run test:propertybuilds and runs them. They live insrc/__tests__/property/, sonpm testdoesn't pick them up.PROPERTY_RUNSsets the number of generated inputs (default 2000, which takes about a second) andPROPERTY_SEEDsets the seed (default 1), so any failure can be rerun exactly.There are three generators in
generate.mjs. One builds valid selectors from a small grammar (namespaces, attributes with every operator and both quote styles, nested:not()/:is(), comments, escapes, and uneven whitespace). One concatenates fragments with no grammar, for inputs the parser should reject. The third makes arbitrary strings for the setters and constructors, minus NUL and lone surrogates, since CSS can't spell those.The properties:
input.startsWith(node.toString().trim(), node.sourceIndex)for every nodeknown.mjslists the failures that are already understood, each with what tracks it. A known failure doesn't fail the run, but every run prints how many failures each entry explained, and says when an entry no longer matches anything so it can be deleted. At the default settings onmain:With #359 merged on top, its entry is reported as no longer seen. #358 only shows up through the lossy whitespace bug, since
:hover|aisn't valid CSS and the grammar never writes it. With #358 on top, that entry drops from 14 to 11 at the default settings, and from about 135 to about 100 at 20,000 runs.Three of the entries are new bugs the harness found, and I haven't filed them yet:
a |b(abwith no namespace, inside ana) prints asa|bin lossy mode, which is abin namespacea.a > |bprints asa>|b. These are valid selectors and the output means something else.(,:hover(anda:not(throw a TypeError instead of the parser's error. This goes back to at least 7.1.4.&prints[&|x], which doesn't parse.Happy to open issues or PRs for them, one each, whichever you prefer.
No CI job yet, as you said.