Add tests for parser escape-sequence and error-case contract#21317
Open
johanrd wants to merge 2 commits intoemberjs:mainfrom
Open
Add tests for parser escape-sequence and error-case contract#21317johanrd wants to merge 2 commits intoemberjs:mainfrom
johanrd wants to merge 2 commits intoemberjs:mainfrom
Conversation
Contributor
|
thanks for doing this! lemme know when it's ready for review |
Contributor
Author
|
i think now! |
| astEqual('\\\\{{foo}}', b.template([b.text('\\'), b.mustache(b.path('foo'))])); | ||
| }); | ||
|
|
||
| // k=3: \\\{{ → real mustache, TWO literal backslashes emitted as TextNode. |
Contributor
There was a problem hiding this comment.
I'm kinda surprised this is how it works today 🙈
Contributor
There was a problem hiding this comment.
can the modules here be regular qunit modules spit in to multiple files? we shouldn't do this for the existing modules, but for new modules, I'd like the new tests to be less weird then their predecessors
NullVoxPopuli
previously approved these changes
Apr 16, 2026
c4de195 to
5989442
Compare
|
|
||
| const { test } = QUnit; | ||
|
|
||
| QUnit.module('[glimmer-syntax] Parser - parse error regression fixtures'); |
Contributor
There was a problem hiding this comment.
I mean lilke:
module('module name', function() {
tests here
});
…ract tests
Split into three files by concern:
- parser-escape-test.ts: backslash escape sequences (\{{, \\{{, \\\{{)
in top-level text, elements, attributes, and unclosed cases.
- parser-whitespace-test.ts: tilde stripping and standalone detection.
- parser-error-test.ts: inputs that must be rejected ({{}}}, {{~}}, {{@}}, etc).
parser-node-test.ts is unchanged.
5989442 to
e3e3ab3
Compare
johanrd
added a commit
to johanrd/ember.js
that referenced
this pull request
Apr 17, 2026
…rate files) With emberjs#21317 merged, the escape-sequence, whitespace-control, and error tests live in their own files. Remove the 259 lines that were ported into parser-node-test.ts before the split.
johanrd
added a commit
to johanrd/ember.js
that referenced
this pull request
Apr 17, 2026
NullVoxPopuli
approved these changes
Apr 17, 2026
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 regression tests for parser behaviors that downstream tools (prettier, ember-cli) rely on — escape sequences (
\{{,\\{{,\\\{{), error cases ({{}},{{~}},{{@}}), whitespace control, and standalone stripping.Found by hitting real prettier smoke-test failures while exploring the parser (index-based & single-pass index-based). No behavior change; tests pass against current Jison parser.
Why upstream these if the prettier smoke test already catches them?
The prettier smoke test catches these — but only after cloning prettier, installing deps, and running jest (~2 min). These tests catch the same regressions in the normal qunit suite with specific AST assertions — faster feedback, clearer failure messages, and no external dependency.
Prettier fixtures that caught the regressions
Error cases (different error message text):
_errors_/invalid-3.hbs—{{}}_errors_/invalid.hbs—{{@name}(unclosed)_errors_/tilde-comments-1.hbs—{{~}}_errors_/tilde-comments-2.hbs—{{~~}}Escape-handling (different AST shape → different formatted output):
mustache-statement/escaped.hbs—\{{,\\{{,\\\{{sequences