Diff
Modified: trunk/LayoutTests/ChangeLog (247283 => 247284)
--- trunk/LayoutTests/ChangeLog 2019-07-09 22:40:08 UTC (rev 247283)
+++ trunk/LayoutTests/ChangeLog 2019-07-09 23:05:45 UTC (rev 247284)
@@ -1,3 +1,25 @@
+2019-07-09 Saam Barati <sbar...@apple.com>
+
+ [WHLSL] Add another group of WHLSL JS reference spec tests
+ https://bugs.webkit.org/show_bug.cgi?id=199642
+
+ Reviewed by Robin Morisset.
+
+ * webgpu/whlsl-array-spec-tests-expected.txt: Added.
+ * webgpu/whlsl-array-spec-tests.html: Added.
+ * webgpu/whlsl-enum-spec-tests-expected.txt: Added.
+ * webgpu/whlsl-enum-spec-tests.html: Added.
+ * webgpu/whlsl-equality-expected.txt: Added.
+ * webgpu/whlsl-equality.html: Added.
+ * webgpu/whlsl-matrices-spec-tests-expected.txt: Added.
+ * webgpu/whlsl-matrices-spec-tests.html: Added.
+ * webgpu/whlsl-return-spec-tests-expected.txt: Added.
+ * webgpu/whlsl-return-spec-tests.html: Added.
+ * webgpu/whlsl-simple-getter-setter-expected.txt: Added.
+ * webgpu/whlsl-simple-getter-setter.html: Added.
+ * webgpu/whlsl-simple-while-loop-expected.txt: Added.
+ * webgpu/whlsl-simple-while-loop.html: Added.
+
2019-07-09 Youenn Fablet <you...@apple.com>
XHR CORS requests logged twice in the server
Added: trunk/LayoutTests/webgpu/whlsl-array-spec-tests-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-array-spec-tests-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-array-spec-tests-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,7 @@
+
+PASS arrayRefToArrayRef
+PASS assignLength
+PASS assignLengthHelper
+PASS buildArrayThenSumIt
+PASS buildArrayThenSumItUsingArrayReference
+
Added: trunk/LayoutTests/webgpu/whlsl-array-spec-tests.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-array-spec-tests.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-array-spec-tests.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,100 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.arrayRefToArrayRef = async () => {
+ let program = `
+ int foo()
+ {
+ int x;
+ thread int[] p = @x;
+ thread int[][] pp = @p;
+ int[]thread[]thread qq = pp;
+ int result = 0;
+ x = 42;
+ p[0] = 76;
+ result += x;
+ pp[0][0] = 39;
+ result += x;
+ qq[0][0] = 83;
+ result += x;
+ return result;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", []), 76 + 39 + 83);
+}
+
+whlslTests.assignLength = async () => {
+ await checkFail(
+ `
+ void foo()
+ {
+ float[754] array;
+ (@array).length = 42;
+ }
+ `);
+
+}
+
+whlslTests.assignLengthHelper = async () => {
+ await checkFail(
+ `
+ void bar(thread float[] array)
+ {
+ array.length = 42;
+ }
+ void foo()
+ {
+ float[754] array;
+ bar(@array);
+ }
+ `);
+}
+
+whlslTests.buildArrayThenSumIt = async () => {
+ let program = `
+ int foo()
+ {
+ int[42] array;
+ for (uint i = 0; i < 42; i = i + 1)
+ array[i] = int(i + 5);
+ int result;
+ for (uint i = 0; i < 42; i = i + 1)
+ result = result + array[i];
+ return result;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", []), 42 * 5 + 42 * 41 / 2);
+}
+
+whlslTests.buildArrayThenSumItUsingArrayReference = async () => {
+ let program = `
+ int bar(thread int[] array)
+ {
+ for (uint i = 0; i < 42; i = i + 1)
+ array[i] = int(i + 5);
+ int result;
+ for (uint i = 0; i < 42; i = i + 1)
+ result = result + array[i];
+ return result;
+ }
+ int foo()
+ {
+ int[42] array;
+ return bar(@array);
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", []), 42 * 5 + 42 * 41 / 2);
+}
+
+runTests(whlslTests);
+</script>
+</html>
Added: trunk/LayoutTests/webgpu/whlsl-enum-spec-tests-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-enum-spec-tests-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-enum-spec-tests-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,9 @@
+
+PASS enumDuplicates
+PASS defaultEnumConstructor
+PASS enumArrayRefBase
+PASS enumFloatBase
+PASS enumPtrBase
+PASS enumStructBase
+PASS enumNoMembers
+
Added: trunk/LayoutTests/webgpu/whlsl-enum-spec-tests.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-enum-spec-tests.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-enum-spec-tests.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,89 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.enumDuplicates = async () => {
+ await checkFail(`
+ enum Foo {
+ War = 42,
+ Famine = 0,
+ Pestilence = 23,
+ Death = 42
+ }
+ `);
+};
+
+whlslTests.defaultEnumConstructor = async () => {
+ const program = `
+ enum Weekday {
+ Monday,
+ Tuesday,
+ Wednesday,
+ Thursday,
+ Pizzaday
+ }
+ int foo()
+ {
+ Weekday x = Weekday();
+ return 42;
+ }
+ `;
+
+ assert_equals(await callIntFunction(program, "foo", []), 42);
+};
+
+whlslTests.enumArrayRefBase = async () => {
+ await checkFail(
+ `
+ enum Foo : thread int[] {
+ Bar
+ }
+ `);
+}
+
+whlslTests.enumFloatBase = async () => {
+ await checkFail(
+ `
+ enum Foo : float {
+ Bar
+ }
+ `);
+}
+
+whlslTests.enumPtrBase = async () => {
+ await checkFail(
+ `
+ enum Foo : thread int* {
+ Bar
+ }
+ `);
+}
+
+whlslTests.enumStructBase = async () => {
+ await checkFail(
+ `
+ struct Thingy { }
+ enum Foo : Thingy {
+ Bar
+ }
+ `);
+};
+
+whlslTests.enumNoMembers = async () => {
+ await checkFail(
+ `
+ enum Foo { }
+ `);
+};
+
+runTests(whlslTests);
+</script>
+</html>
Added: trunk/LayoutTests/webgpu/whlsl-equality-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-equality-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-equality-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,11 @@
+
+PASS equality
+PASS notEquality
+PASS equalityTypeFailure
+PASS equalsWrongArgumentLength
+PASS equalsWrongReturnType
+PASS lessEqualWrongArgumentLength
+PASS lessEqualWrongReturnType
+PASS lessThanWrongArgumentLength
+PASS lessThanWrongReturnType
+
Added: trunk/LayoutTests/webgpu/whlsl-equality.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-equality.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-equality.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,119 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.equality = async () => {
+ let program = "bool foo(uint x, uint y) { return x == y; }";
+ assert_equals(await callBoolFunction(program, "foo", [makeUint(7), makeUint(5)]), false);
+ assert_equals(await callBoolFunction(program, "foo", [makeUint(7), makeUint(7)]), true);
+ program = "bool foo(int x, int y) { return x == y; }";
+ assert_equals(await callBoolFunction(program, "foo", [makeInt(7), makeInt(5)]), false);
+ assert_equals(await callBoolFunction(program, "foo", [makeInt(7), makeInt(7)]), true);
+ program = "bool foo(bool x, bool y) { return x == y; }";
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(false), makeBool(true)]), false);
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(true), makeBool(false)]), false);
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(false), makeBool(false)]), true);
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(true), makeBool(true)]), true);
+}
+
+whlslTests.notEquality = async () => {
+ let program = "bool foo(uint x, uint y) { return x != y; }";
+ assert_equals(await callBoolFunction(program, "foo", [makeUint(7), makeUint(5)]), true);
+ assert_equals(await callBoolFunction(program, "foo", [makeUint(7), makeUint(7)]), false);
+ program = "bool foo(int x, int y) { return x != y; }";
+ assert_equals(await callBoolFunction(program, "foo", [makeInt(7), makeInt(5)]), true);
+ assert_equals(await callBoolFunction(program, "foo", [makeInt(7), makeInt(7)]), false);
+ program = "bool foo(bool x, bool y) { return x != y; }";
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(false), makeBool(true)]), true);
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(true), makeBool(false)]), true);
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(false), makeBool(false)]), false);
+ assert_equals(await callBoolFunction(program, "foo", [makeBool(true), makeBool(true)]), false);
+};
+
+whlslTests.equalityTypeFailure = async () => {
+ await checkFail("bool foo(int x, uint y) { return x == y; }");
+};
+
+whlslTests.equalsWrongArgumentLength = async () => {
+ await checkFail(
+ `
+ bool operator==() { return true; }
+ `);
+
+ await checkFail(
+ `
+ bool operator==(int) { return true; }
+ `);
+
+ await checkFail(
+ `
+ bool operator==(int, int, int) { return true; }
+ `);
+};
+
+whlslTests.equalsWrongReturnType = async () => {
+ await checkFail(
+ `
+ struct Foo { }
+ int operator==(Foo, Foo) { return 42; }
+ `);
+}
+
+whlslTests.lessEqualWrongArgumentLength = async () => {
+ await checkFail(
+ `
+ bool operator<=() { return true; }
+ `);
+ await checkFail(
+ `
+ bool operator<=(int) { return true; }
+ `);
+
+ await checkFail(
+ `
+ bool operator<=(int, int, int) { return true; }
+ `);
+}
+
+whlslTests.lessEqualWrongReturnType = async () => {
+ checkFail(
+ `
+ struct Foo { }
+ int operator<=(Foo, Foo) { return 42; }
+ `);
+}
+
+whlslTests.lessThanWrongArgumentLength = async () => {
+ await checkFail(
+ `
+ bool operator<() { return true; }
+ `);
+ await checkFail(
+ `
+ bool operator<(int) { return true; }
+ `);
+ await checkFail(
+ `
+ bool operator<(int, int, int) { return true; }
+ `);
+}
+
+whlslTests.lessThanWrongReturnType = async () => {
+ await checkFail(
+ `
+ struct Foo { }
+ int operator<(Foo, Foo) { return 42; }
+ `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
Added: trunk/LayoutTests/webgpu/whlsl-matrices-spec-tests-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-matrices-spec-tests-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-matrices-spec-tests-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,4 @@
+
+PASS builtinMatrices
+PASS matrixMultiplication
+
Added: trunk/LayoutTests/webgpu/whlsl-matrices-spec-tests.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-matrices-spec-tests.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-matrices-spec-tests.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,204 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.builtinMatrices = async () => {
+ let program = `
+ float foo()
+ {
+ float2x2 a;
+ a[0][0] = 1;
+ a[0][1] = 2;
+ a[1][0] = 3;
+ a[1][1] = 4;
+ return a[0][0];
+ }
+ float foo2()
+ {
+ float2x3 a;
+ a[0][0] = 1;
+ a[0][1] = 2;
+ a[0][2] = 3;
+ a[1][0] = 4;
+ a[1][1] = 5;
+ a[1][2] = 6;
+ return a[1][2];
+ }
+ float foo3()
+ {
+ float2x2 a;
+ return a[0][0];
+ }
+ bool foo4()
+ {
+ float2x2 a;
+ a[0][0] = 1;
+ a[0][1] = 2;
+ a[1][0] = 3;
+ a[1][1] = 4;
+ float2x2 b;
+ b[0][0] = 5;
+ b[0][1] = 6;
+ b[1][0] = 7;
+ b[1][1] = 8;
+ for (uint i = 0; i < 2; ++i) {
+ for (uint j = 0; j < 2; ++j) {
+ a[i][j] += 4;
+ }
+ }
+ return a == b;
+ }
+ bool foo5()
+ {
+ float2x2 a;
+ a[0] = float2(1, 2);
+ a[1] = float2(3, 4);
+ float2x2 b;
+ b[0][0] = 1;
+ b[0][1] = 2;
+ b[1][0] = 3;
+ b[1][1] = 4;
+ return a == b;
+ }
+ bool foo6()
+ {
+ float2x2 a;
+ a[0][0] = 1;
+ a[0][1] = 2;
+ a[1][0] = 3;
+ a[1][1] = 4;
+ float2x2 b;
+ b[0][0] = 5;
+ b[0][1] = 10;
+ b[1][0] = 18;
+ b[1][1] = 24;
+ a[0] *= 5;
+ a[1] *= 6;
+ return a == b;
+ }
+ float foo7()
+ {
+ float2x3 a = float2x3(float3(3, 4, 5), float3(6, 7, 8));
+ return a[0][2];
+ }
+ `;
+ assert_equals(await callFloatFunction(program, "foo", []), 1);
+ assert_equals(await callFloatFunction(program, "foo2", []), 6);
+ assert_equals(await callFloatFunction(program, "foo3", []), 0);
+ assert_equals(await callBoolFunction(program, "foo4", []), true);
+ assert_equals(await callBoolFunction(program, "foo5", []), true);
+ assert_equals(await callBoolFunction(program, "foo6", []), true);
+ assert_equals(await callFloatFunction(program, "foo7", []), 5);
+};
+
+whlslTests.matrixMultiplication = async () => {
+ let program = `
+ float2x4 multiply(float2x3 x, float3x4 y) {
+ // Copied and pasted from the standard library
+ float2x4 result;
+ result[0][0] = 0;
+ result[0][0] += x[0][0] * y[0][0];
+ result[0][0] += x[0][1] * y[1][0];
+ result[0][0] += x[0][2] * y[2][0];
+ result[0][1] = 0;
+ result[0][1] += x[0][0] * y[0][1];
+ result[0][1] += x[0][1] * y[1][1];
+ result[0][1] += x[0][2] * y[2][1];
+ result[0][2] = 0;
+ result[0][2] += x[0][0] * y[0][2];
+ result[0][2] += x[0][1] * y[1][2];
+ result[0][2] += x[0][2] * y[2][2];
+ result[0][3] = 0;
+ result[0][3] += x[0][0] * y[0][3];
+ result[0][3] += x[0][1] * y[1][3];
+ result[0][3] += x[0][2] * y[2][3];
+ result[1][0] = 0;
+ result[1][0] += x[1][0] * y[0][0];
+ result[1][0] += x[1][1] * y[1][0];
+ result[1][0] += x[1][2] * y[2][0];
+ result[1][1] = 0;
+ result[1][1] += x[1][0] * y[0][1];
+ result[1][1] += x[1][1] * y[1][1];
+ result[1][1] += x[1][2] * y[2][1];
+ result[1][2] = 0;
+ result[1][2] += x[1][0] * y[0][2];
+ result[1][2] += x[1][1] * y[1][2];
+ result[1][2] += x[1][2] * y[2][2];
+ result[1][3] = 0;
+ result[1][3] += x[1][0] * y[0][3];
+ result[1][3] += x[1][1] * y[1][3];
+ result[1][3] += x[1][2] * y[2][3];
+ return result;
+ }
+ float2x3 matrix1() {
+ float2x3 x;
+ x[0][0] = 2;
+ x[0][1] = 3;
+ x[0][2] = 5;
+ x[1][0] = 7;
+ x[1][1] = 11;
+ x[1][2] = 13;
+ return x;
+ }
+ float3x4 matrix2() {
+ float3x4 y;
+ y[0][0] = 17;
+ y[0][1] = 19;
+ y[0][2] = 23;
+ y[0][3] = 29;
+ y[1][0] = 31;
+ y[1][1] = 37;
+ y[1][2] = 41;
+ y[1][3] = 43;
+ y[2][0] = 47;
+ y[2][1] = 53;
+ y[2][2] = 59;
+ y[2][3] = 61;
+ return y;
+ }
+ float foo00() {
+ return multiply(matrix1(), matrix2())[0][0];
+ }
+ float foo01() {
+ return multiply(matrix1(), matrix2())[0][1];
+ }
+ float foo02() {
+ return multiply(matrix1(), matrix2())[0][2];
+ }
+ float foo03() {
+ return multiply(matrix1(), matrix2())[0][3];
+ }
+ float foo10() {
+ return multiply(matrix1(), matrix2())[1][0];
+ }
+ float foo11() {
+ return multiply(matrix1(), matrix2())[1][1];
+ }
+ float foo12() {
+ return multiply(matrix1(), matrix2())[1][2];
+ }
+ float foo13() {
+ return multiply(matrix1(), matrix2())[1][3];
+ }
+ `;
+ assert_equals(await callFloatFunction(program, "foo00", []), 17 * 2 + 31 * 3 + 47 * 5);
+ assert_equals(await callFloatFunction(program, "foo01", []), 19 * 2 + 37 * 3 + 53 * 5);
+ assert_equals(await callFloatFunction(program, "foo02", []), 23 * 2 + 41 * 3 + 59 * 5);
+ assert_equals(await callFloatFunction(program, "foo03", []), 29 * 2 + 43 * 3 + 61 * 5);
+ assert_equals(await callFloatFunction(program, "foo10", []), 17 * 7 + 31 * 11 + 47 * 13);
+ assert_equals(await callFloatFunction(program, "foo11", []), 19 * 7 + 37 * 11 + 53 * 13);
+ assert_equals(await callFloatFunction(program, "foo12", []), 23 * 7 + 41 * 11 + 59 * 13);
+ assert_equals(await callFloatFunction(program, "foo13", []), 29 * 7 + 43 * 11 + 61 * 13);
+};
+
+runTests(whlslTests);
+</script>
+</html>
Added: trunk/LayoutTests/webgpu/whlsl-return-spec-tests-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-return-spec-tests-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-return-spec-tests-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,10 @@
+
+PASS returnIf
+PASS returnReferenceToSameParameter
+PASS returnReferenceToParameterWithDifferentFunctions
+PASS returnReferenceToParameter
+PASS returnReferenceToLocalVariableWithNesting
+PASS returnReferenceToLocalVariable
+PASS returnIntLiteralUint
+PASS returnIntLiteralFloat
+
Added: trunk/LayoutTests/webgpu/whlsl-return-spec-tests.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-return-spec-tests.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-return-spec-tests.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,238 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.returnIf = async () => {
+ await checkFail(
+ `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return y;
+ }
+ }
+ `);
+
+ await checkFail(
+ `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return y;
+ } else {
+ y = 8;
+ }
+ }
+ `);
+
+ await checkFail(
+ `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ y = 8;
+ } else {
+ return y;
+ }
+ }
+ `);
+
+ let program = `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else {
+ return 10;
+ }
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", [makeInt(3)]), 10);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(4)]), 10);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(5)]), 10);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(6)]), 10);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(7)]), 8);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(8)]), 10);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(9)]), 10);
+
+ await checkFail(
+ `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else if (x == 9) {
+ return 10;
+ }
+ }
+ `);
+ program = `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else {
+ y = 9;
+ }
+ return y;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", [makeInt(3)]), 9);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(4)]), 9);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(5)]), 9);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(6)]), 9);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(7)]), 8);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(8)]), 9);
+ assert_equals(await callIntFunction(program, "foo", [makeInt(9)]), 9);
+ await checkFail(
+ `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else {
+ return 10;
+ }
+ return 11;
+ }
+ `);
+
+ program = `
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7)
+ int y = 8;
+ return y;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", [makeInt(7)]), 6);
+};
+
+whlslTests.returnReferenceToSameParameter = async () => {
+ let program = `
+ int foo()
+ {
+ return plus(bar(5), bar(7));
+ }
+
+ int plus(thread int* x, thread int* y)
+ {
+ return *x + *y;
+ }
+
+ thread int* bar(int x)
+ {
+ return &x;
+ }
+ `;
+
+ assert_equals(await callIntFunction(program, "foo", []), 14);
+};
+
+whlslTests.returnReferenceToParameterWithDifferentFunctions = async () => {
+ let program = `
+ int foo()
+ {
+ return *bar(10) + *baz(20);
+ }
+
+ thread int* bar(int x)
+ {
+ return &x;
+ }
+
+ thread int* baz(int y)
+ {
+ return &y;
+ }
+ `;
+
+ assert_equals(await callIntFunction(program, "foo", []), 30);
+};
+
+whlslTests.returnReferenceToParameter = async () => {
+ let program = `
+ int foo(bool condition)
+ {
+ return *bar(condition, 1, 2);
+ }
+
+ thread int* bar(bool condition, int a, int b)
+ {
+ return condition ? &a : &b;
+ }
+ `;
+
+ assert_equals(await callIntFunction(program, "foo", [makeBool(true)]), 1);
+ assert_equals(await callIntFunction(program, "foo", [makeBool(false)]), 2);
+};
+
+whlslTests.returnReferenceToLocalVariableWithNesting = async () => {
+ let program = `
+ int foo()
+ {
+ return *bar() + *baz();
+ }
+
+ thread int* bar()
+ {
+ int a = 20;
+ return &a;
+ }
+
+ thread int* baz()
+ {
+ int a = 22;
+ return &a;
+ }
+ `;
+
+ assert_equals(await callIntFunction(program, "foo", []), 42);
+};
+
+whlslTests.returnReferenceToLocalVariable = async () => {
+ let program = `
+ int foo()
+ {
+ return *bar();
+ }
+
+ thread int* bar()
+ {
+ int a = 42;
+ return &a;
+ }
+ `;
+
+ assert_equals(await callIntFunction(program, "foo", []), 42);
+};
+
+whlslTests.returnIntLiteralUint = async () => {
+ let program = "uint foo() { return 42; }";
+ assert_equals(await callUintFunction(program, "foo", []), 42);
+};
+
+whlslTests.returnIntLiteralFloat = async () => {
+ let program = "float foo() { return 42; }";
+ assert_equals(await callFloatFunction(program, "foo", []), 42);
+};
+
+runTests(whlslTests);
+</script>
+</html>
Added: trunk/LayoutTests/webgpu/whlsl-simple-getter-setter-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-simple-getter-setter-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-simple-getter-setter-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,4 @@
+
+PASS simpleGetter
+PASS simpleSetter
+
Added: trunk/LayoutTests/webgpu/whlsl-simple-getter-setter.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-simple-getter-setter.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-simple-getter-setter.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,58 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.simpleGetter = async () => {
+ let program = `
+ struct Foo {
+ int x;
+ }
+ int operator.y(Foo foo)
+ {
+ return foo.x;
+ }
+ int foo()
+ {
+ Foo foo;
+ foo.x = 7804;
+ return foo.y;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", []), 7804);
+};
+
+whlslTests.simpleSetter = async () => {
+ let program = `
+ struct Foo {
+ int x;
+ }
+ int operator.y(Foo foo)
+ {
+ return foo.x;
+ }
+ Foo operator.y=(Foo foo, int value)
+ {
+ foo.x = value;
+ return foo;
+ }
+ int foo()
+ {
+ Foo foo;
+ foo.y = 7804;
+ return foo.x;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", []), 7804);
+};
+
+runTests(whlslTests);
+</script>
+</html>
Added: trunk/LayoutTests/webgpu/whlsl-simple-while-loop-expected.txt (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-simple-while-loop-expected.txt (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-simple-while-loop-expected.txt 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,3 @@
+
+PASS simpleWhile
+
Added: trunk/LayoutTests/webgpu/whlsl-simple-while-loop.html (0 => 247284)
--- trunk/LayoutTests/webgpu/whlsl-simple-while-loop.html (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl-simple-while-loop.html 2019-07-09 23:05:45 UTC (rev 247284)
@@ -0,0 +1,27 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test the WHLSL test harness.</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+const whlslTests = {};
+
+whlslTests.simpleWhile = async () => {
+ let program = `
+ int foo(int x)
+ {
+ while (x < 13)
+ x = x * 2;
+ return x;
+ }
+ `;
+ assert_equals(await callIntFunction(program, "foo", [makeInt(1)]), 16);
+}
+
+runTests(whlslTests);
+</script>
+</html>