Skip to content

Commit

Permalink
Validating test case
Browse files Browse the repository at this point in the history
  • Loading branch information
iwoplaza committed Jan 25, 2025
1 parent 18dbe5c commit 37aa8bb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/typegpu/tests/derived.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,43 @@ describe('TgpuDerived', () => {
`),
);
});

it('allows slot bindings to pass downstream from derived (#697)', () => {
const utgpu = tgpu['~unstable'];
const valueSlot = utgpu.slot(1).$name('valueSlot');

const derivedFn = utgpu.derived(() => {
return utgpu
.fn([], d.f32)
.does(() => valueSlot.value)
.$name('innerFn');
});

const derivedFnWith2 = derivedFn.with(valueSlot, 2);

const mainFn = utgpu
.fn([])
.does(() => {
derivedFn.value();
derivedFnWith2.value();
})
.$name('main');

expect(parseResolved({ mainFn })).toEqual(
parse(`
fn innerFn() -> f32 {
return 1;
}
fn innerFn_1() -> f32 {
return 2;
}
fn main() {
innerFn();
innerFn_1();
}
`),
);
});
});

0 comments on commit 37aa8bb

Please sign in to comment.