Skip to content

test: Enforce only argument-less functions as input to expectDataType#2704

Merged
iwoplaza merged 1 commit into
mainfrom
test/cleanup-use-of-expect-data-type
Jul 10, 2026
Merged

test: Enforce only argument-less functions as input to expectDataType#2704
iwoplaza merged 1 commit into
mainfrom
test/cleanup-use-of-expect-data-type

Conversation

@iwoplaza

@iwoplaza iwoplaza commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

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

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/sdf@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/three@a460688a3883b729ef335dda6b81a51103187303
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@a460688a3883b729ef335dda6b81a51103187303

benchmark
view benchmark

commit
view commit

@iwoplaza iwoplaza marked this pull request as ready for review July 9, 2026 14:25
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 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 ($${\color{green}-3.2\%}$$)
tgpu_initFromDevice.ts 255.93 kB ($${\color{green}-3.4\%}$$)
tgpu_resolve.ts 187.16 kB ($${\color{green}-29.3\%}$$)
tgpu_resolveWithContext.ts 187.10 kB ($${\color{green}-29.4\%}$$)
tgpu_bindGroupLayout.ts 69.01 kB ($${\color{green}-74.0\%}$$)
tgpu_mutableAccessor.ts 65.98 kB ($${\color{green}-75.1\%}$$)
tgpu_accessor.ts 65.97 kB ($${\color{green}-75.1\%}$$)
tgpu_privateVar.ts 65.30 kB ($${\color{green}-75.3\%}$$)
tgpu_workgroupVar.ts 65.30 kB ($${\color{green}-75.4\%}$$)
tgpu_const.ts 64.53 kB ($${\color{green}-75.6\%}$$)
tgpu_fn.ts 37.97 kB ($${\color{green}-85.7\%}$$)
tgpu_fragmentFn.ts 37.91 kB ($${\color{green}-85.7\%}$$)
tgpu_vertexFn.ts 37.72 kB ($${\color{green}-85.8\%}$$)
tgpu_computeFn.ts 37.43 kB ($${\color{green}-85.9\%}$$)
tgpu_vertexLayout.ts 26.61 kB ($${\color{green}-90.0\%}$$)
tgpu_comptime.ts 14.41 kB ($${\color{green}-94.6\%}$$)
tgpu_unroll.ts 2.60 kB ($${\color{green}-99.0\%}$$)
tgpu_slot.ts 1.57 kB ($${\color{green}-99.4\%}$$)
tgpu_lazy.ts 1.22 kB ($${\color{green}-99.5\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

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]
Loading
---
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]
Loading
---
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]
Loading

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (and expectSnippetOf) to accept only () => unknown callbacks.
  • 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.ts from TgpuFn | (() => unknown) to () => unknown for both expectDataTypeOf and expectSnippetOf.
  • Update conversion.test.ts so the pointer-dereferencing test wraps the snippet in () => { 'use gpu'; ... return fn(numRef); } instead of passing fn directly.

ℹ️ 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.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@aleksanderkatan

Copy link
Copy Markdown
Contributor

Why? This way, we can never inspect a snippet of type argument

@iwoplaza

iwoplaza commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

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 return, and I didn't want to extend it further. Inspecting arguments will be possible with the #2697 APIs though!

@iwoplaza iwoplaza force-pushed the test/cleanup-use-of-expect-data-type branch from c3dd811 to a460688 Compare July 10, 2026 10:40
@iwoplaza iwoplaza merged commit c924752 into main Jul 10, 2026
8 checks passed
@iwoplaza iwoplaza deleted the test/cleanup-use-of-expect-data-type branch July 10, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants