Skip to content

test: More robust snippet testing #2697

Description

@iwoplaza

If we need it, there's a way to more granularly test expressions and statements.

Testing expressions

import { CAPTURE, extractSnippetsFromFn } from 'typegpu-testing-utility';

// ...

function foo() {
  'use gpu';
  return 5 + (CAPTURE(6 + 7));
  //                  ^^^^^
}

expect(extractSnippetsFromFn(foo)[0]!.dataType.type).toMatchInlineSnapshot('abstractInt');

Testing statements

import { CAPTURE_FOLLOWING, extractSnippetsFromFn } from 'typegpu-testing-utility';

// ...

function foo() {
  'use gpu';
  CAPTURE_FOLLOWING();
  return 5 + 6 + 7;
  // ^^^^^^^^^^^^^^
}

expect(extractSnippetsFromFn(foo)[0]!.dataType.type).toMatchInlineSnapshot('void');

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions