Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions docs/labs/create_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,33 +619,36 @@ requested, and the second is post-processed pattern that should result.
There's no need for a "failure" test suite here, because we
demand exact results for every test case.

Here is an example (expressed in YAML format):

~~~~yaml
preprocessing:
-
- |-
[\n\r]+
- ""
-
- |-
[ \t]+\\s\+[ \t]+
- "\\s+"
-
- |-
(\\s\*)?[ \t]+(\\s\*)?
- "\\s*"
preprocessingTests:
-
- |-
\s* console \. log \( (["'`])Hello,\x20world!\1 \) ; \s*
- |-
\s*console\s*\.\s*log\s*\(\s*(["'`])Hello,\x20world!\1\s*\)\s*;\s*
-
- |-
\s* foo \s+ bar \\string\\ \s*
- |-
\s*foo\s+bar\s*\\string\\\s*
Here is an example:

~~~~javascript
preprocessing: [
[
// Ignore newlines
String.raw`[\n\r]+`,
""
],
[
// Convert \s+ surrounded by tabs/spaces as \s+ (optimization)
String.raw`[ \t]+\\s\+[ \t]+`,
String.raw`\s+`
],
[
// Convert 1+ spaces/tabs, optionally surrounded by \s*, as \s*
String.raw`(\\s\*)?[ \t]+(\\s\*)?`,
String.raw`\s*`
]
],
preprocessingTests: [
[
String.raw`\s* console \. log \( (["'${BACKQUOTE}])Hello,\x20world!\1 \) ; \s*`,
String.raw`\s*console\s*\.\s*log\s*\(\s*(["'${BACKQUOTE}])Hello,\x20world!\1\s*\)\s*;\s*`
],
[
String.raw`\s* foo \s+ bar \\string\\ \s*`,
String.raw`\s*foo\s+bar\s*\\string\\\s*`
]
]
~~~~

Here is an explanation of each of these preprocessing elements
Expand Down