[WHLSL] Move WHLSL tests to their own folder
[WebKit-https.git] / LayoutTests / webgpu / whlsl / casts.html
1 <!DOCTYPE html>
2 <html>
3 <meta charset=utf-8>
4 <meta name="timeout" content="long">
5 <title>Bad add.</title>
6 <script src="js/test-harness.js"></script>
7 <script src="../js/webgpu-functions.js"></script>
8 <script src="../../resources/testharness.js"></script>
9 <script src="../../resources/testharnessreport.js"></script>
10 <script>
11 const whlslTests = {};
12
13 whlslTests.casts = async () =>
14 {
15     let program = `
16         struct Foo {
17             int x;
18         }
19         struct Bar {
20             int y;
21         }
22         operator Bar(Foo foo) {
23             Bar b;
24             b.y = foo.x + 7;
25             return b;
26         }
27         int baz(int z) {
28             Foo foo;
29             foo.x = z;
30             Bar b = Bar(foo);
31             return b.y;
32         }
33     `;
34     assert_equals(await callIntFunction(program, "baz", [makeInt(6)]), 13);
35 }
36
37 whlslTests.selfCasts = async () =>
38 {
39     let program = `
40         struct Foo {
41             int x;
42         }
43         int foo()
44         {
45             Foo foo;
46             foo.x = 21;
47             Foo bar = Foo(foo);
48             bar.x = 42;
49             return foo.x + bar.x;
50         }
51     `;
52     assert_equals(await callIntFunction(program, "foo", []), 21 + 42);
53 }
54
55 runTests(whlslTests);
56 </script>
57 </html>
58