blob: 4f132a097faf17d96d2bb58081eada8d9a953f27 [file] [log] [blame]
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>oob on arrays.</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.fieldShouldBeNull = async () => {
const program = `
struct Foo {
int x;
int y;
int z;
}
bool foo(uint i) {
Foo[10] foos;
thread Foo* foo = &foos[i];
thread int* ptr = &(foo->z);
*ptr = 42;
return foos[0].z == 42;
}
bool bar() {
Foo[10] foos;
thread Foo* foo = &foos[424242];
thread int* ptr = &(foo->z);
return foo == &foos[0];
}
float3 retFloat3()
{
return float3(10.0, 0.0, 0.0);
}
float[10] retFloatArray()
{
float[10] v;
v[0] = 10.0;
return v;
}
bool baz() {
return retFloat3()[42] == 10.0;
}
bool jaz() {
return retFloatArray()[42] == 10.0;
}
`;
for (let i = 0; i < 10; ++i)
assert_equals(await callBoolFunction(program, "foo", [makeUint(i)]), i === 0 ? true : false);
assert_equals(await callBoolFunction(program, "foo", [makeUint(10)]), true);
assert_equals(await callBoolFunction(program, "foo", [makeUint(1000000)]), true);
assert_equals(await callBoolFunction(program, "foo", [makeUint(0xffffffff)]), true);
assert_equals(await callBoolFunction(program, "bar", []), true);
assert_equals(await callBoolFunction(program, "baz", []), true);
assert_equals(await callBoolFunction(program, "jaz", []), true);
};
runTests(whlslTests);
</script>
</html>