blob: 51ce1f470ef321f00c07265f19b759ff62db721e [file] [log] [blame]
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>Test prefix/postfix.</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 = {};
const epsilon = 0.0001;
whlslTests.listOfScalarsMatrixConstructors = async () =>
{
let program = `
float a()
{
float2x2 m = float2x2(1, 2, 3, 4);
return m[1][0];
}
float b()
{
float2x3 m = float2x3(1, 2, 3, 4, 5, 6);
return m[1][0];
}
float c()
{
float2x4 m = float2x4(1, 2, 3, 4, 5, 6, 7, 8);
return m[1][0];
}
float d()
{
float3x2 m = float3x2(1, 2, 3, 4, 5, 6);
return m[1][0];
}
float e()
{
float3x3 m = float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9);
return m[1][0];
}
float f()
{
float3x4 m = float3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
return m[1][0];
}
float g()
{
float4x2 m = float4x2(1, 2, 3, 4, 5, 6, 7, 8);
return m[1][0];
}
float h()
{
float4x3 m = float4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
return m[1][0];
}
float i()
{
float4x4 m = float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
return m[1][0];
}
`;
assert_approx_equals(await callFloatFunction(program, "a", []), 3, epsilon);
assert_approx_equals(await callFloatFunction(program, "b", []), 4, epsilon);
assert_approx_equals(await callFloatFunction(program, "c", []), 5, epsilon);
assert_approx_equals(await callFloatFunction(program, "d", []), 3, epsilon);
assert_approx_equals(await callFloatFunction(program, "e", []), 4, epsilon);
assert_approx_equals(await callFloatFunction(program, "f", []), 5, epsilon);
assert_approx_equals(await callFloatFunction(program, "g", []), 3, epsilon);
assert_approx_equals(await callFloatFunction(program, "h", []), 4, epsilon);
assert_approx_equals(await callFloatFunction(program, "i", []), 5, epsilon);
}
runTests(whlslTests);
</script>
</html>