Commit 2b8248e
committed
Add property-based tests for parser and type checker
Use `proptest` to assert that the parser and type checker never panic
on arbitrary input, and that well-formed programs drawn from a small
grammar parse and type check without errors. The regression file is
checked in so the failing cases we've already found are rerun on each
test run.
The property tests uncovered three real bugs, which are also fixed
here:
- The lexer panicked on non-ASCII whitespace because it advanced by
one byte rather than the character's UTF-8 length.
- The lexer panicked on unrecognized non-ASCII characters for the
same reason when constructing the "unrecognized syntax" diagnostic.
- `parse_tuple_literal_or_parentheses` hit a forward-progress
assertion on inputs like `(,{` where the inner expression parser
emitted a diagnostic without consuming a token. It now breaks out
of the loop instead.1 parent d3f0dbb commit 2b8248e
File tree
7 files changed
+408
-18
lines changed- proptest-regressions
- src
- checks
- parser
7 files changed
+408
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
5 | 20 | | |
6 | 21 | | |
7 | 22 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments