Assert the compiled scope independently of the wire format's shape - #121
Open
NullVoxPopuli wants to merge 3 commits into
Open
Assert the compiled scope independently of the wire format's shape#121NullVoxPopuli wants to merge 3 commits into
NullVoxPopuli wants to merge 3 commits into
Conversation
NullVoxPopuli
force-pushed
the
object-scope-test-coverage
branch
from
August 12, 2026 18:16
4a239b7 to
a5f9f6e
Compare
Older compilers emit the wire format's scope as an array
(`scope: () => [Setup]`); newer ones emit an object
(`scope: () => ({ Foo: Setup })`). Both carry the same information — the names
the template uses, mapped to the JS they resolve to — but the array form leaves
the names implicit, in the `locals` we handed the compiler.
Add a `wireScope` helper that reads either shape back into the same mapping, by
pairing an array-form scope with those locals. That lets a test assert on the
compiled scope without caring which ember-source is installed, which matters
because the try scenarios float that dependency from 3.28 through beta.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NullVoxPopuli
force-pushed
the
object-scope-test-coverage
branch
from
August 12, 2026 18:29
5ee859f to
176cf7c
Compare
NullVoxPopuli
commented
Aug 12, 2026
|
|
||
| let source = (node: babel.types.Node) => src.slice(node.start!, node.end!); | ||
|
|
||
| if (t.isObjectExpression(value.body)) { |
NullVoxPopuli
commented
Aug 12, 2026
| return [name, source(prop.value)]; | ||
| }) | ||
| ); | ||
| } else if (t.isArrayExpression(value.body)) { |
NullVoxPopuli
commented
Aug 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.
Test-only. Extracted from #120 so that PR can be purely the fix it describes.
Older compilers emit the wire format's scope as an array (
scope: () => [Setup]); newer ones emit an object (scope: () => ({ Foo: Setup })). Verified against both:Both shapes carry the same information — the names the template uses, mapped to the JS they resolve to — but the array form leaves the names implicit, in the
localswe hand the compiler.This adds a
wireScopehelper that reads either shape back into the same mapping, pairing an array-form scope with those locals. A test can then assert on the compiled scope without caring which ember-source is installed, which matters because the try scenarios float that dependency from 3.28 through beta. It also makes failures legible:Green on
mainas-is — no implementation change. #120 uses the same helper to show a case that isn't handled correctly today.🤖 Generated with Claude Code