test: Enforce only argument-less functions as input to expectDataType#2704
Conversation
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased | ❔ Unknown |
|---|---|---|---|
| 0 | 321 | 0 | 0 |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
| Test | tsdown |
|---|---|
| tgpu_init.ts | 256.45 kB ( |
| tgpu_initFromDevice.ts | 255.93 kB ( |
| tgpu_resolve.ts | 187.16 kB ( |
| tgpu_resolveWithContext.ts | 187.10 kB ( |
| tgpu_bindGroupLayout.ts | 69.01 kB ( |
| tgpu_mutableAccessor.ts | 65.98 kB ( |
| tgpu_accessor.ts | 65.97 kB ( |
| tgpu_privateVar.ts | 65.30 kB ( |
| tgpu_workgroupVar.ts | 65.30 kB ( |
| tgpu_const.ts | 64.53 kB ( |
| tgpu_fn.ts | 37.97 kB ( |
| tgpu_fragmentFn.ts | 37.91 kB ( |
| tgpu_vertexFn.ts | 37.72 kB ( |
| tgpu_computeFn.ts | 37.43 kB ( |
| tgpu_vertexLayout.ts | 26.61 kB ( |
| tgpu_comptime.ts | 14.41 kB ( |
| tgpu_unroll.ts | 2.60 kB ( |
| tgpu_slot.ts | 1.57 kB ( |
| tgpu_lazy.ts | 1.22 kB ( |
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.88, 1.79, 3.75, 6.07, 6.63, 10.59, 20.50, 22.32]
line [0.90, 1.76, 3.96, 5.45, 6.93, 10.37, 19.69, 21.79]
line [0.88, 1.72, 3.95, 5.51, 6.38, 11.31, 19.08, 21.12]
---
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.34, 0.53, 0.68, 0.84, 1.13, 1.13, 1.34, 1.47]
line [0.31, 0.51, 0.71, 0.83, 1.15, 1.12, 1.33, 1.45]
line [0.28, 0.49, 0.65, 0.83, 1.07, 1.07, 1.30, 1.49]
---
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.78, 1.81, 4.06, 5.55, 11.13, 23.82, 50.03, 102.80]
line [0.92, 1.88, 4.09, 5.65, 11.24, 23.28, 51.36, 102.21]
line [0.89, 1.88, 3.85, 5.74, 11.01, 23.38, 50.24, 101.81]
|
There was a problem hiding this comment.
Pull request overview
This PR updates TypeGPU’s test utilities to ensure expectDataTypeOf (and related helpers) only accept argument-less “snippet producer” callbacks, and adjusts an existing TGSL conversion test to match the stricter contract.
Changes:
- Narrow
expectDataTypeOf(andexpectSnippetOf) to accept only() => unknowncallbacks. - Refactor the pointer-dereferencing conversion test to wrap parameterized GPU logic in an argument-less callback passed to
expectDataTypeOf.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/typegpu/tests/utils/parseResolved.ts | Tightens test helper callback types to enforce argument-less snippet producers. |
| packages/typegpu/tests/tgsl/conversion.test.ts | Updates the pointer dereferencing test to comply with the new helper signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — narrowed the expectDataTypeOf and expectSnippetOf test helpers to accept only argument-less functions, and updated the single affected test to wrap its tgpu.fn-style call in a parameterless 'use gpu' function.
- Narrow helper signatures in
packages/typegpu/tests/utils/parseResolved.tsfromTgpuFn | (() => unknown)to() => unknownfor bothexpectDataTypeOfandexpectSnippetOf. - Update
conversion.test.tsso the pointer-dereferencing test wraps the snippet in() => { 'use gpu'; ... return fn(numRef); }instead of passingfndirectly.
ℹ️ extractSnippetFromFn still accepts TgpuFn
The underlying extractor used by these helpers retains the TgpuFn | (() => unknown) signature. All current callers already pass parameterless functions, so it is consistent in practice and does not block this change. Worth aligning in a follow-up if the stricter contract should apply there too.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
Why? This way, we can never inspect a snippet of type argument |
@aleksanderkatan That's true. I'm generally not super happy with how the current testing API changes the meaning of |
c3dd811 to
a460688
Compare

'use gpu'functions passed to are meant to create and return snippets to be inspected