| <!DOCTYPE html> |
| <html> |
| <meta charset=utf-8> |
| <meta name="timeout" content="long"> |
| <title>Overload.</title> |
| <script src="js/whlsl-test-harness.js"></script> |
| <script src="js/webgpu-functions.js"></script> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script> |
| const whlslTests = {}; |
| |
| whlslTests.intOverloadResolution = async () => |
| { |
| let program = ` |
| int foo(int) { return 1; } |
| int foo(uint) { return 2; } |
| int foo(float) { return 3; } |
| int bar() { return foo(42); } |
| `; |
| assert_equals(await callIntFunction(program, "bar", []), 1); |
| } |
| |
| whlslTests.intOverloadResolutionReverseOrder = async () => |
| { |
| let program = ` |
| int foo(float) { return 3; } |
| int foo(uint) { return 2; } |
| int foo(int) { return 1; } |
| int bar() { return foo(42); } |
| `; |
| assert_equals(await callIntFunction(program, "bar", []), 1); |
| } |
| |
| whlslTests.notEqualsOverload = async () => |
| { |
| await checkFail( |
| ` |
| struct Foo { } |
| bool operator!=(Foo, Foo) { return true; } |
| `); |
| } |
| |
| runTests(whlslTests); |
| </script> |
| </html> |