chore: Use public API in test utilities (extractSnippet, ...)#2388
Merged
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (350 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.97, 1.94, 4.37, 6.52, 6.93, 10.23, 21.50, 23.30]
line [0.96, 1.90, 4.11, 6.46, 7.15, 10.99, 21.51, 23.32]
line [0.98, 1.95, 3.93, 6.01, 7.39, 11.39, 21.50, 25.42]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.28, 0.52, 0.73, 0.84, 1.07, 1.19, 1.42, 1.63]
line [0.31, 0.51, 0.72, 0.89, 1.18, 1.24, 1.47, 1.60]
line [0.35, 0.56, 0.70, 0.87, 1.10, 1.20, 1.46, 1.62]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.82, 1.85, 3.75, 6.08, 12.03, 25.84, 55.31, 109.22]
line [0.91, 1.95, 3.87, 6.35, 12.28, 25.38, 54.97, 113.83]
line [0.78, 1.93, 3.94, 6.17, 12.25, 25.34, 53.66, 111.45]
|
c426c82 to
edc606f
Compare
edc606f to
123d4b5
Compare
There was a problem hiding this comment.
Pull request overview
Updates TypeGPU’s test snippet-extraction utilities to rely on the public tgpu.resolve + public generator APIs, enabling reuse of extractSnippetFromFn / expectSnippetOf / expectDataTypeOf in public API test suites.
Changes:
- Refactors
extractSnippetFromFnto usetgpu.resolve(..., { unstable_shaderGenerator })and a customWgslGeneratorsubclass to capture returned snippets. - Updates affected tests to
returnthe inspected expression instead of relying on the last-expression-in-block behavior. - Extracts return-statement codegen into
WgslGenerator._returnand exportsSnippettype viaShaderGeneratormembers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/utils/parseResolved.ts | Switches snippet extraction from internal ctx/generator wiring to public tgpu.resolve with a capturing generator. |
| packages/typegpu/tests/tgsl/wgslGenerator.test.ts | Adjusts a test function to return the array expression for the new extraction approach. |
| packages/typegpu/tests/tgsl/memberAccess.test.ts | Updates snippet expectations by adding explicit return statements in inspected functions. |
| packages/typegpu/tests/std/numeric/add.test.ts | Updates inspected functions to explicitly return expressions for type inference assertions. |
| packages/typegpu/src/tgsl/wgslGenerator.ts | Refactors return-statement generation into a dedicated _return method used by _statement. |
| packages/typegpu/src/tgsl/shaderGenerator_members.ts | Re-exports Snippet type to make it available via the ShaderGenerator public surface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
123d4b5 to
17b7556
Compare
This was referenced Apr 16, 2026
17b7556 to
6d2959c
Compare
6d2959c to
c7e9ac4
Compare
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.
This will allow us to use
expectSnippetOf,expectDataTypeOfandextractSnippetin public API tests