Skip to content

Commit f3e1fa7

Browse files
committed
wip: start writing tests
1 parent f2b1cf8 commit f3e1fa7

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

test/Lil.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import {
2+
assertEquals,
3+
assertIsError,
4+
} from "https://esm.sh/jsr/@std/assert@1.0.13"
5+
6+
import {
7+
Lil,
8+
d,
9+
10+
vertex,
11+
fragment,
12+
compute,
13+
14+
uniform,
15+
storage,
16+
} from "../deno.ts"
17+
18+
Deno.test("read storage (Deno specific)", async () => {
19+
class Test extends Lil {
20+
@storage(d.arrayOf(d.u32, 10), "mutable")
21+
accessor data = [0]
22+
23+
@compute
24+
main = ` `
25+
}
26+
27+
const test = new Test()
28+
const g = await test.init()
29+
30+
try {
31+
await g.buffers.data.read()
32+
} catch (e) {
33+
// It seems Deno doesn't support `read`
34+
assertIsError(e)
35+
assertEquals(e.message, "This operation is currently not supported")
36+
}
37+
})
38+
39+
Deno.test("buffers", async () => {
40+
class Test extends Lil {
41+
@storage(d.arrayOf(d.u32, 10), "mutable")
42+
accessor data = [0]
43+
44+
@compute
45+
main = `
46+
@compute
47+
@workgroup_size(8, 8)
48+
fn main(@builtin(global_invocation_id) id: vec3u) {
49+
data[id.x] = id.x;
50+
}
51+
`
52+
}
53+
const test = new Test()
54+
const g = await test.init()
55+
56+
g.compute(10)
57+
})

0 commit comments

Comments
 (0)