blob: 35517ad403ffeb0d76f56cda4348a5cc52332236 [file] [log] [blame]
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>Test loops.</title>
<script src="js/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>