Add a runtime-disabled dialog element skeleton
[WebKit-https.git] / LayoutTests / webgpu / whlsl-bad-ander.html
1 <!DOCTYPE html>
2 <html>
3 <meta charset=utf-8>
4 <meta name="timeout" content="long">
5 <title>Test prefix/postfix.</title>
6 <script src="js/whlsl-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.indexAnderDoesntReturnPointer = async () =>
14 {
15     await checkFail(
16         `
17             struct Foo {
18                 int x;
19             }
20             int operator&[](thread Foo* foo, uint)
21             {
22                 return foo->x;
23             }
24         `);
25 }
26
27 whlslTests.indexAnderDoesntTakeReference = async () =>
28 {
29     await checkFail(
30         `
31             struct Foo {
32                 int x;
33             }
34             thread int* operator&[](Foo foo, uint)
35             {
36                 return &foo.x;
37             }
38         `);
39 }
40
41 whlslTests.anderDoesntReturnPointer = async () => {
42     await checkFail(
43         `
44             struct Foo {
45                 int x;
46             }
47             int operator&.foo(thread Foo* foo)
48             {
49                 return foo->x;
50             }
51         `);
52 }
53
54 whlslTests.anderDoesntTakeReference = async () =>
55 {
56     await checkFail(
57         `
58             struct Foo {
59                 int x;
60             }
61             thread int* operator&.foo(Foo foo)
62             {
63                 return &foo.x;
64             }
65         `);
66 }
67
68 whlslTests.anderWithBadIndex = async () =>
69 {
70     await checkFail(`int foo(thread int[] x) { return x[-1]; }`);
71
72     await checkFail(`int foo(thread int[] x) { return x[1.f]; }`);
73
74     await checkFail(`int foo(thread int[] x, int y) { return x[y]; }`);
75
76     await checkFail(`int foo(thread int[] x, float y) { return x[y]; }`);
77 }
78
79 whlslTests.anderWithNothingWrong = async () =>
80 {
81     let program = `
82         struct Foo {
83             int x;
84         }
85         thread int* operator&.foo(thread Foo* foo)
86         {
87             return &foo->x;
88         }
89         int foo()
90         {
91             Foo x;
92             x.x = 13;
93             return x.foo;
94         }
95     `;
96     assert_equals(await callIntFunction(program, "foo", []), 13);
97 }
98
99 whlslTests.anderWithWrongNumberOfArguments = async () => {
100     await checkFail(
101         `
102             thread int* operator&.foo()
103             {
104                 int x;
105                 return &x;
106             }
107         `);
108
109     await checkFail(
110         `
111             struct Foo {
112                 int x;
113             }
114             thread int* operator&.foo(thread Foo* foo, int blah)
115             {
116                 return &foo->x;
117             }
118         `);
119 }
120
121 runTests(whlslTests);
122 </script>
123 </html>