blob: 0d9c94694c8af10d9e0ff9b6c4e8eab5a9ff3512 [file] [log] [blame]
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>Test loops.</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.dereferenceDefaultNullArrayRef = async () =>
{
let program = `
int foo()
{
thread int[] p;
return p[0];
}
`;
assert_equals(await callIntFunction(program, "foo", []), 0);
}
whlslTests.defaultInitializedNullArrayRefIntLiteral = async () =>
{
let program = `
int foo()
{
thread int[] p = null;
return p[0];
}
`;
assert_equals(await callIntFunction(program, "foo", []), 0);
}
whlslTests.passNullToPtrMonomorphicArrayRef = async () =>
{
let program = `
int foo(thread int[] ptr)
{
return ptr[0u];
}
int bar()
{
return foo(null);
}
`;
assert_equals(await callIntFunction(program, "bar", []), 0);
}
whlslTests.loadNull = async () =>
{
await checkFail(
`
void sink(thread int* x) { }
void foo() { sink(*null); }
`);
}
runTests(whlslTests);
</script>
</html>