[WHLSL] Import all tests that pass without compiler changes from the JS reference...
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 00:59:10 +0000 (00:59 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jul 2019 00:59:10 +0000 (00:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199595

Rubber stamped by Robin Morisset.

* webgpu/whlsl-argument-evaluation-order-expected.txt: Added.
* webgpu/whlsl-argument-evaluation-order.html: Added.
* webgpu/whlsl-array-length-spec-tests-expected.txt: Added.
* webgpu/whlsl-array-length-spec-tests.html: Added.
* webgpu/whlsl-array-spec-tests-expected.txt:
* webgpu/whlsl-array-spec-tests.html:
* webgpu/whlsl-bad-add-expected.txt: Added.
* webgpu/whlsl-bad-add.html: Added.
* webgpu/whlsl-bools-expected.txt: Added.
* webgpu/whlsl-bools.html: Added.
* webgpu/whlsl-casts-expected.txt: Added.
* webgpu/whlsl-casts.html: Added.
* webgpu/whlsl-comment-parsing-expected.txt: Added.
* webgpu/whlsl-comment-parsing.html: Added.
* webgpu/whlsl-copy-expected.txt: Added.
* webgpu/whlsl-copy.html: Added.
* webgpu/whlsl-dereference-ordering-expected.txt: Added.
* webgpu/whlsl-dereference-ordering.html: Added.
* webgpu/whlsl-double-not-expected.txt: Added.
* webgpu/whlsl-double-not.html: Added.
* webgpu/whlsl-duplicates-expected.txt: Added.
* webgpu/whlsl-duplicates.html: Added.
* webgpu/whlsl-increment-decrement-expected.txt: Added.
* webgpu/whlsl-increment-decrement.html: Added.
* webgpu/whlsl-index-ander-expected.txt: Added.
* webgpu/whlsl-index-ander.html: Added.
* webgpu/whlsl-index-setter-getter-expected.txt: Added.
* webgpu/whlsl-index-setter-getter.html: Added.
* webgpu/whlsl-logical-negation-expected.txt: Added.
* webgpu/whlsl-logical-negation.html: Added.
* webgpu/whlsl-lots-of-local-variables-expected.txt: Added.
* webgpu/whlsl-lots-of-local-variables.html: Added.
* webgpu/whlsl-lvalues-expected.txt: Added.
* webgpu/whlsl-lvalues.html: Added.
* webgpu/whlsl-null-arg-expected.txt: Added.
* webgpu/whlsl-null-arg.html: Added.
* webgpu/whlsl-operator-overload-expected.txt: Added.
* webgpu/whlsl-operator-overload.html: Added.
* webgpu/whlsl-overload-expected.txt: Added.
* webgpu/whlsl-overload.html: Added.
* webgpu/whlsl-setter-spec-tests-expected.txt: Added.
* webgpu/whlsl-setter-spec-tests.html: Added.
* webgpu/whlsl-store-null-expected.txt: Added.
* webgpu/whlsl-store-null.html: Added.
* webgpu/whlsl-struct-expected.txt: Added.
* webgpu/whlsl-struct.html: Added.
* webgpu/whlsl-switch-expected.txt: Added.
* webgpu/whlsl-switch.html: Added.
* webgpu/whlsl-variable-shadowing-expected.txt: Added.
* webgpu/whlsl-variable-shadowing.html: Added.
* webgpu/whlsl-vector-syntax-expected.txt: Added.
* webgpu/whlsl-vector-syntax.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247338 268f45cc-cd09-0410-ab3c-d52691b4dbfc

53 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/whlsl-argument-evaluation-order-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-argument-evaluation-order.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-array-length-spec-tests-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-array-length-spec-tests.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-array-spec-tests-expected.txt
LayoutTests/webgpu/whlsl-array-spec-tests.html
LayoutTests/webgpu/whlsl-bad-add-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-bad-add.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-bools-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-bools.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-casts-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-casts.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-comment-parsing-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-comment-parsing.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-copy-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-copy.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-dereference-ordering-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-dereference-ordering.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-double-not-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-double-not.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-duplicates-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-duplicates.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-increment-decrement-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-increment-decrement.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-index-ander-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-index-ander.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-index-setter-getter-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-index-setter-getter.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-logical-negation-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-logical-negation.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-lots-of-local-variables-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-lots-of-local-variables.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-lvalues-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-lvalues.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-null-arg-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-null-arg.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-operator-overload-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-operator-overload.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-overload-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-overload.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-setter-spec-tests-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-setter-spec-tests.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-store-null-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-store-null.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-struct-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-struct.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-switch-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-switch.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-variable-shadowing-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-variable-shadowing.html [new file with mode: 0644]
LayoutTests/webgpu/whlsl-vector-syntax-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl-vector-syntax.html [new file with mode: 0644]

index 1a406b9..85b07a3 100644 (file)
@@ -1,3 +1,63 @@
+2019-07-10  Saam Barati  <sbarati@apple.com>
+
+        [WHLSL] Import all tests that pass without compiler changes from the JS reference test suite
+        https://bugs.webkit.org/show_bug.cgi?id=199595
+
+        Rubber stamped by Robin Morisset.
+
+        * webgpu/whlsl-argument-evaluation-order-expected.txt: Added.
+        * webgpu/whlsl-argument-evaluation-order.html: Added.
+        * webgpu/whlsl-array-length-spec-tests-expected.txt: Added.
+        * webgpu/whlsl-array-length-spec-tests.html: Added.
+        * webgpu/whlsl-array-spec-tests-expected.txt:
+        * webgpu/whlsl-array-spec-tests.html:
+        * webgpu/whlsl-bad-add-expected.txt: Added.
+        * webgpu/whlsl-bad-add.html: Added.
+        * webgpu/whlsl-bools-expected.txt: Added.
+        * webgpu/whlsl-bools.html: Added.
+        * webgpu/whlsl-casts-expected.txt: Added.
+        * webgpu/whlsl-casts.html: Added.
+        * webgpu/whlsl-comment-parsing-expected.txt: Added.
+        * webgpu/whlsl-comment-parsing.html: Added.
+        * webgpu/whlsl-copy-expected.txt: Added.
+        * webgpu/whlsl-copy.html: Added.
+        * webgpu/whlsl-dereference-ordering-expected.txt: Added.
+        * webgpu/whlsl-dereference-ordering.html: Added.
+        * webgpu/whlsl-double-not-expected.txt: Added.
+        * webgpu/whlsl-double-not.html: Added.
+        * webgpu/whlsl-duplicates-expected.txt: Added.
+        * webgpu/whlsl-duplicates.html: Added.
+        * webgpu/whlsl-increment-decrement-expected.txt: Added.
+        * webgpu/whlsl-increment-decrement.html: Added.
+        * webgpu/whlsl-index-ander-expected.txt: Added.
+        * webgpu/whlsl-index-ander.html: Added.
+        * webgpu/whlsl-index-setter-getter-expected.txt: Added.
+        * webgpu/whlsl-index-setter-getter.html: Added.
+        * webgpu/whlsl-logical-negation-expected.txt: Added.
+        * webgpu/whlsl-logical-negation.html: Added.
+        * webgpu/whlsl-lots-of-local-variables-expected.txt: Added.
+        * webgpu/whlsl-lots-of-local-variables.html: Added.
+        * webgpu/whlsl-lvalues-expected.txt: Added.
+        * webgpu/whlsl-lvalues.html: Added.
+        * webgpu/whlsl-null-arg-expected.txt: Added.
+        * webgpu/whlsl-null-arg.html: Added.
+        * webgpu/whlsl-operator-overload-expected.txt: Added.
+        * webgpu/whlsl-operator-overload.html: Added.
+        * webgpu/whlsl-overload-expected.txt: Added.
+        * webgpu/whlsl-overload.html: Added.
+        * webgpu/whlsl-setter-spec-tests-expected.txt: Added.
+        * webgpu/whlsl-setter-spec-tests.html: Added.
+        * webgpu/whlsl-store-null-expected.txt: Added.
+        * webgpu/whlsl-store-null.html: Added.
+        * webgpu/whlsl-struct-expected.txt: Added.
+        * webgpu/whlsl-struct.html: Added.
+        * webgpu/whlsl-switch-expected.txt: Added.
+        * webgpu/whlsl-switch.html: Added.
+        * webgpu/whlsl-variable-shadowing-expected.txt: Added.
+        * webgpu/whlsl-variable-shadowing.html: Added.
+        * webgpu/whlsl-vector-syntax-expected.txt: Added.
+        * webgpu/whlsl-vector-syntax.html: Added.
+
 2019-07-10  Truitt Savell  <tsavell@apple.com>
 
         Marking webgpu/whlsl-builtin-vectors-2.html as Slow after https://trac.webkit.org/changeset/247319/webkit
diff --git a/LayoutTests/webgpu/whlsl-argument-evaluation-order-expected.txt b/LayoutTests/webgpu/whlsl-argument-evaluation-order-expected.txt
new file mode 100644 (file)
index 0000000..7362c2a
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS evaluationOrderForArguments 
+
diff --git a/LayoutTests/webgpu/whlsl-argument-evaluation-order.html b/LayoutTests/webgpu/whlsl-argument-evaluation-order.html
new file mode 100644 (file)
index 0000000..90ea8d1
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Copying.</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.evaluationOrderForArguments = async () => {
+    const program = `
+        int foo() { return *bar(10) + *bar(20); }
+
+        thread int* bar(int value)
+        {
+            int x = value;
+            return &x;
+        }
+
+        int baz() { return plus(bar(10), bar(20)); }
+
+        int plus(thread int* x, thread int* y)
+        {
+            return *x + *y;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 30);
+    assert_equals(await callIntFunction(program, "baz", []), 40);
+};
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-array-length-spec-tests-expected.txt b/LayoutTests/webgpu/whlsl-array-length-spec-tests-expected.txt
new file mode 100644 (file)
index 0000000..e533e8a
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS nonArrayRefArrayLengthFail 
+PASS nonArrayRefArrayLengthSucceed 
+
diff --git a/LayoutTests/webgpu/whlsl-array-length-spec-tests.html b/LayoutTests/webgpu/whlsl-array-length-spec-tests.html
new file mode 100644 (file)
index 0000000..d77704c
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.nonArrayRefArrayLengthFail = async () =>
+{
+    await checkFail(
+        `
+            thread uint* lengthPtr()
+            {
+                int[42] array;
+                return &(array.length);
+            }
+        `);
+}
+
+whlslTests.nonArrayRefArrayLengthSucceed = async () =>
+{
+    let program = `
+        uint foo()
+        {
+            float[754] array;
+            return array.length;
+        }
+        uint bar()
+        {
+            int[754] array;
+            return array.length;
+        }
+    `;
+    assert_equals(await callUintFunction(program, "foo", []), 754);
+    assert_equals(await callUintFunction(program, "bar", []), 754);
+}
+
+runTests(whlslTests);
+</script>
+</html>
index 7caebb0..5685b1f 100644 (file)
@@ -4,4 +4,5 @@ PASS assignLength
 PASS assignLengthHelper 
 PASS buildArrayThenSumIt 
 PASS buildArrayThenSumItUsingArrayReference 
+PASS passingArrayToFunction 
 
index 2eb112d..442cd4d 100644 (file)
@@ -95,6 +95,28 @@ whlslTests.buildArrayThenSumItUsingArrayReference = async () => {
     assert_equals(await callIntFunction(program, "foo", []), 42 * 5 + 42 * 41 / 2);
 }
 
+whlslTests.passingArrayToFunction = async () =>
+{
+    let program = `
+        int foo()
+        {
+            int[10] arr;
+            for (uint i = 0; i < arr.length; i++)
+                arr[i] = int(i) + 1;
+            return sum(arr);
+        }
+
+        int sum(int[10] xs)
+        {
+            int t = 0;
+            for (uint i = 0; i < xs.length; i++)
+                t = t + xs[i];
+            return t;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 55);
+}
+
 runTests(whlslTests);
 </script>
 </html>
diff --git a/LayoutTests/webgpu/whlsl-bad-add-expected.txt b/LayoutTests/webgpu/whlsl-bad-add-expected.txt
new file mode 100644 (file)
index 0000000..beb452e
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS badAdd 
+
diff --git a/LayoutTests/webgpu/whlsl-bad-add.html b/LayoutTests/webgpu/whlsl-bad-add.html
new file mode 100644 (file)
index 0000000..bae0416
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Bad add.</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.badAdd = async () =>
+{
+    await checkFail(
+        `
+            void foo(int x, uint y)
+            {
+                uint z = x + y;
+            }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-bools-expected.txt b/LayoutTests/webgpu/whlsl-bools-expected.txt
new file mode 100644 (file)
index 0000000..045abb8
--- /dev/null
@@ -0,0 +1,6 @@
+
+PASS booleanMath 
+PASS identityBool 
+PASS literalBool 
+PASS operatorBool 
+
diff --git a/LayoutTests/webgpu/whlsl-bools.html b/LayoutTests/webgpu/whlsl-bools.html
new file mode 100644 (file)
index 0000000..6ef71a4
--- /dev/null
@@ -0,0 +1,124 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Bools.</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.booleanMath = async () =>
+{
+    let program = `
+        bool foo()
+        {
+            return true && true;
+        }
+        bool foo2()
+        {
+            return true && false;
+        }
+        bool foo3()
+        {
+            return false && true;
+        }
+        bool foo4()
+        {
+            return false && false;
+        }
+        bool foo5()
+        {
+            return true || true;
+        }
+        bool foo6()
+        {
+            return true || false;
+        }
+        bool foo7()
+        {
+            return false || true;
+        }
+        bool foo8()
+        {
+            return false || false;
+        }
+    `;
+    assert_equals(await callBoolFunction(program, "foo", []), true);
+    assert_equals(await callBoolFunction(program, "foo2", []), false);
+    assert_equals(await callBoolFunction(program, "foo3", []), false);
+    assert_equals(await callBoolFunction(program, "foo4", []), false);
+    assert_equals(await callBoolFunction(program, "foo5", []), true);
+    assert_equals(await callBoolFunction(program, "foo6", []), true);
+    assert_equals(await callBoolFunction(program, "foo7", []), true);
+    assert_equals(await callBoolFunction(program, "foo8", []), false);
+}
+
+
+whlslTests.identityBool = async () => {
+    let program = "bool foo(bool x) { return x; }";
+    assert_equals(await callBoolFunction(program, "foo", [makeBool(true)]), true);
+    assert_equals(await callBoolFunction(program, "foo", [makeBool(false)]), false);
+}
+
+whlslTests.literalBool = async () => {
+    let program = "bool foo() { return true; }";
+    assert_equals(await callBoolFunction(program, "foo", []), true);
+}
+
+whlslTests.operatorBool = async () =>
+{
+    let program = `
+        bool boolFromUcharFalse() { return bool(uchar(0)); }
+        bool boolFromUcharTrue() { return bool(uchar(1)); }
+
+        bool boolFromUintFalse() { return bool(uint(0)); }
+        bool boolFromUintTrue() { return bool(uint(1)); }
+
+        bool boolFromIntFalse() { return bool(int(0)); }
+        bool boolFromIntTrue() { return bool(int(1)); }
+
+        bool boolFromFloatFalse() { return bool(float(0)); }
+        bool boolFromFloatTrue() { return bool(float(1)); }
+        bool boolFromFloatNaN(float arg) { return bool(arg); }
+    `;
+
+    assert_equals(await callBoolFunction(program, "boolFromUcharFalse", []), false);
+    assert_equals(await callBoolFunction(program, "boolFromUcharTrue", []), true);
+
+    assert_equals(await callBoolFunction(program, "boolFromUintFalse", []), false);
+    assert_equals(await callBoolFunction(program, "boolFromUintTrue", []), true);
+
+    assert_equals(await callBoolFunction(program, "boolFromIntFalse", []), false);
+    assert_equals(await callBoolFunction(program, "boolFromIntTrue", []), true);
+
+    assert_equals(await callBoolFunction(program, "boolFromFloatFalse", []), false);
+    assert_equals(await callBoolFunction(program, "boolFromFloatTrue", []), true);
+    assert_equals(await callBoolFunction(program, "boolFromFloatNaN", [makeFloat(program, NaN)]), true);
+
+    await checkFail(
+        `
+            void foo()
+            {
+                float3 x;
+                bool r = bool(x);
+            }
+        `);
+        
+
+    await checkFail(
+        `
+            void foo()
+            {
+                float3x3 x;
+                bool r = bool(x);
+            }
+        `);
+        
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-casts-expected.txt b/LayoutTests/webgpu/whlsl-casts-expected.txt
new file mode 100644 (file)
index 0000000..5b7ce4c
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS casts 
+PASS selfCasts 
+
diff --git a/LayoutTests/webgpu/whlsl-casts.html b/LayoutTests/webgpu/whlsl-casts.html
new file mode 100644 (file)
index 0000000..09fef42
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Bad add.</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.casts = async () =>
+{
+    let program = `
+        struct Foo {
+            int x;
+        }
+        struct Bar {
+            int y;
+        }
+        operator Bar(Foo foo) {
+            Bar b;
+            b.y = foo.x + 7;
+            return b;
+        }
+        int baz(int z) {
+            Foo foo;
+            foo.x = z;
+            Bar b = Bar(foo);
+            return b.y;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "baz", [makeInt(6)]), 13);
+}
+
+whlslTests.selfCasts = async () =>
+{
+    let program = `
+        struct Foo {
+            int x;
+        }
+        int foo()
+        {
+            Foo foo;
+            foo.x = 21;
+            Foo bar = Foo(foo);
+            bar.x = 42;
+            return foo.x + bar.x;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 21 + 42);
+}
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-comment-parsing-expected.txt b/LayoutTests/webgpu/whlsl-comment-parsing-expected.txt
new file mode 100644 (file)
index 0000000..9cb4091
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS commentParsing 
+
diff --git a/LayoutTests/webgpu/whlsl-comment-parsing.html b/LayoutTests/webgpu/whlsl-comment-parsing.html
new file mode 100644 (file)
index 0000000..d2385fa
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.commentParsing = async () => {
+    let program = `
+        /* this comment
+        runs over multiple lines */
+        bool foo() { return true; }
+    `;
+    assert_equals(await callBoolFunction(program, "foo", []), true);
+
+    await checkFail(
+        `
+        /* this comment
+        runs over multiple lines
+        bool foo() { return true; }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-copy-expected.txt b/LayoutTests/webgpu/whlsl-copy-expected.txt
new file mode 100644 (file)
index 0000000..d6a4bdc
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS copyArray 
+
diff --git a/LayoutTests/webgpu/whlsl-copy.html b/LayoutTests/webgpu/whlsl-copy.html
new file mode 100644 (file)
index 0000000..80c197b
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Copying.</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.copyArray = async () =>
+{
+    let program = `
+        int foo()
+        {
+            int[10] xs;
+            for (uint i = 0; i < xs.length; i++)
+                xs[i] = int(i) + 1;
+            int[10] ys = xs;
+            for (uint i = 0; i < xs.length; i++)
+                xs[i] = 0;
+            int sum = 0;
+            for (uint i = 0; i < ys.length; i++)
+                sum = sum + ys[i];
+            return sum;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 55);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-dereference-ordering-expected.txt b/LayoutTests/webgpu/whlsl-dereference-ordering-expected.txt
new file mode 100644 (file)
index 0000000..f5c617e
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS callArgumentsAreCopiedImmediatelyAfterEvaluation 
+
diff --git a/LayoutTests/webgpu/whlsl-dereference-ordering.html b/LayoutTests/webgpu/whlsl-dereference-ordering.html
new file mode 100644 (file)
index 0000000..234babf
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Dereference ordering.</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.callArgumentsAreCopiedImmediatelyAfterEvaluation = async () => {
+    let program = `
+        int foo()
+        {
+            return *bar(5) + *bar(7);
+        }
+
+        thread int* bar(int value)
+        {
+            int x = value;
+            return &x;
+        }
+    `;
+
+    assert_equals(await callIntFunction(program, "foo", []), 12);
+};
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-double-not-expected.txt b/LayoutTests/webgpu/whlsl-double-not-expected.txt
new file mode 100644 (file)
index 0000000..b274318
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS doubleNot 
+
diff --git a/LayoutTests/webgpu/whlsl-double-not.html b/LayoutTests/webgpu/whlsl-double-not.html
new file mode 100644 (file)
index 0000000..7e9f5bd
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Copying.</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.doubleNot = async () =>
+{
+    let program = `
+        bool foo(bool x)
+        {
+            return !!x;
+        }
+    `;
+    assert_equals(await callBoolFunction(program, "foo", [makeBool(true)]), true);
+    assert_equals(await callBoolFunction(program, "foo", [makeBool(false)]), false);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-duplicates-expected.txt b/LayoutTests/webgpu/whlsl-duplicates-expected.txt
new file mode 100644 (file)
index 0000000..820a4eb
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS duplicateFunctions 
+
diff --git a/LayoutTests/webgpu/whlsl-duplicates.html b/LayoutTests/webgpu/whlsl-duplicates.html
new file mode 100644 (file)
index 0000000..85ed96c
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test prefix/postfix.</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.duplicateFunctions = async () => {
+    await checkFail(`
+        void foo() { }
+        void foo() { }
+    `);
+
+    await checkFail(`
+        void foo(int x) { }
+        typedef A = int;
+        void foo(A x) { }
+    `);
+
+    const program = `
+        int bar() {
+            return 42;
+        }
+        int bar(int x) {
+            return x;
+        }
+        int foo()
+        {
+            return bar();
+        }
+        int baz()
+        {
+            return bar(3);
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 42);
+    assert_equals(await callIntFunction(program, "baz", []), 3);
+
+    await checkFail(`
+        int operator&[](thread int[] a, uint b) {
+            return 4;
+        }
+    `);
+
+    await checkFail(`
+        uint operator.length(thread int[] a) {
+            return 4;
+        }
+    `);
+
+    await checkFail(`
+        bool operator==(thread int[] a, thread int[] b) {
+            return true;
+        }
+    `);
+
+    await checkFail(`
+        bool operator==(thread int* a, thread int* b) {
+            return true;
+        }
+    `);
+};
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-increment-decrement-expected.txt b/LayoutTests/webgpu/whlsl-increment-decrement-expected.txt
new file mode 100644 (file)
index 0000000..b28e50e
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS incrementAndDecrement 
+
diff --git a/LayoutTests/webgpu/whlsl-increment-decrement.html b/LayoutTests/webgpu/whlsl-increment-decrement.html
new file mode 100644 (file)
index 0000000..366659a
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Copying.</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.incrementAndDecrement = async () => {
+    let program = `
+        int foo1() { int x = 0; return x++; }
+        int foo2() { int x = 0; x++; return x; }
+        int foo3() { int x = 0; return ++x; }
+        int foo4() { int x = 0; ++x; return x; }
+        int foo5() { int x = 0; return x--; }
+        int foo6() { int x = 0; x--; return x; }
+        int foo7() { int x = 0; return --x; }
+        int foo8() { int x = 0; --x; return x; }
+    `;
+    assert_equals(await callIntFunction(program, "foo1", []), 0);
+    assert_equals(await callIntFunction(program, "foo2", []), 1);
+    assert_equals(await callIntFunction(program, "foo3", []), 1);
+    assert_equals(await callIntFunction(program, "foo4", []), 1);
+    assert_equals(await callIntFunction(program, "foo5", []), 0);
+    assert_equals(await callIntFunction(program, "foo6", []), -1);
+    assert_equals(await callIntFunction(program, "foo7", []), -1);
+    assert_equals(await callIntFunction(program, "foo8", []), -1);
+};
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-index-ander-expected.txt b/LayoutTests/webgpu/whlsl-index-ander-expected.txt
new file mode 100644 (file)
index 0000000..86cb494
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS indexAnderWithNothingWrong 
+PASS indexAnderWithWrongNumberOfArguments 
+
diff --git a/LayoutTests/webgpu/whlsl-index-ander.html b/LayoutTests/webgpu/whlsl-index-ander.html
new file mode 100644 (file)
index 0000000..4a72878
--- /dev/null
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.indexAnderWithNothingWrong = async () =>
+{
+    let program = `
+        struct Foo {
+            int x;
+        }
+        thread int* operator&[](thread Foo* foo, uint)
+        {
+            return &foo->x;
+        }
+        int foo()
+        {
+            Foo x;
+            x.x = 13;
+            return x[666];
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 13);
+}
+
+whlslTests.indexAnderWithWrongNumberOfArguments = async () =>
+{
+    await checkFail(
+        `
+            thread int* operator&[]()
+            {
+                int x;
+                return &x;
+            }
+        `);
+        
+    await checkFail(
+        `
+            struct Foo {
+                int x;
+            }
+            thread int* operator&[](thread Foo* foo)
+            {
+                return &foo->x;
+            }
+        `);
+        
+    await checkFail(
+        `
+            struct Foo {
+                int x;
+            }
+            thread int* operator&[](thread Foo* foo, uint, uint)
+            {
+                return &foo->x;
+            }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-index-setter-getter-expected.txt b/LayoutTests/webgpu/whlsl-index-setter-getter-expected.txt
new file mode 100644 (file)
index 0000000..b3639d0
--- /dev/null
@@ -0,0 +1,7 @@
+
+PASS indexSetterWithNoGetterOverload 
+PASS indexSetterWithNoGetterOverloadFixed 
+PASS notLoneIndexSetter 
+PASS loneIndexSetter 
+PASS loneIndexSetterPointer 
+
diff --git a/LayoutTests/webgpu/whlsl-index-setter-getter.html b/LayoutTests/webgpu/whlsl-index-setter-getter.html
new file mode 100644 (file)
index 0000000..c8a15aa
--- /dev/null
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.indexSetterWithNoGetterOverload = async () =>
+{
+    await checkFail(
+        `
+            struct Foo { }
+            struct Bar { }
+            int operator[](Foo, uint)
+            {
+                return 534;
+            }
+            Bar operator[]=(Bar, uint, int)
+            {
+                return Bar();
+            }
+        `);
+        
+};
+
+whlslTests.indexSetterWithNoGetterOverloadFixed = async () =>
+{
+    const program = `
+        struct Bar { }
+        int operator[](Bar, uint)
+        {
+            return 534;
+        }
+        Bar operator[]=(Bar, uint, int)
+        {
+            return Bar();
+        }
+        int foo() { return Bar()[0]; }
+        int bar() {
+            Bar b;
+            b[0] = 400;
+            return b[0];
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 534);
+    assert_equals(await callIntFunction(program, "bar", []), 534);
+};
+
+whlslTests.notLoneIndexSetter = async () =>
+{
+    const program = `
+        int operator[](int, uint)
+        {
+            return 65;
+        }
+        int operator[]=(int, uint, int)
+        {
+            return 543;
+        }
+        int foo() {
+            int x;
+            return x[0];
+        }
+        int bar() {
+            int x;
+            x[0] = 42;
+            return x;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 65);
+    assert_equals(await callIntFunction(program, "bar", []), 543);
+};
+
+whlslTests.loneIndexSetter = async () =>
+{
+    await checkFail(
+        `
+            int operator[]=(int, uint, int)
+            {
+                return 543;
+            }
+        `);
+        
+};
+
+whlslTests.loneIndexSetterPointer = async () =>
+{
+    await checkFail(
+        `
+            thread int* operator[]=(thread int* ptr, uint, int)
+            {
+                return ptr;
+            }
+        `);
+        
+};
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-logical-negation-expected.txt b/LayoutTests/webgpu/whlsl-logical-negation-expected.txt
new file mode 100644 (file)
index 0000000..a398140
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS logicalNegation 
+
diff --git a/LayoutTests/webgpu/whlsl-logical-negation.html b/LayoutTests/webgpu/whlsl-logical-negation.html
new file mode 100644 (file)
index 0000000..722145f
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Lvalues.</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.logicalNegation = async () =>
+{
+    let program = "bool foo(bool x) { return !x; }";
+    assert_equals(await callBoolFunction(program, "foo", [makeBool(true)]), false);
+    assert_equals(await callBoolFunction(program, "foo", [makeBool(false)]), true);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-lots-of-local-variables-expected.txt b/LayoutTests/webgpu/whlsl-lots-of-local-variables-expected.txt
new file mode 100644 (file)
index 0000000..3040781
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS lotsOfLocalVariables 
+
diff --git a/LayoutTests/webgpu/whlsl-lots-of-local-variables.html b/LayoutTests/webgpu/whlsl-lots-of-local-variables.html
new file mode 100644 (file)
index 0000000..96104b4
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Lots of local variables.</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.lotsOfLocalVariables = async () =>
+{
+    let src = "int sum() {\n";
+    src += "    int i = 0;\n";
+    let target = 0;
+    const numVars = 50;
+    for (let i = 0; i < numVars; i++) {
+        src += `   i = ${i};\n`;
+        src += `   int V${i} = (i + 3) * (i + 3);\n`;
+        target += (i + 3) * (i + 3);
+    }
+    src += "    int result = 0;\n";
+    for (let i = 0; i < numVars; i++) {
+        src += `    result += V${i};\n`;
+    }
+    src += "    return result;\n";
+    src += "}";
+    let program = src;
+    assert_equals(await callIntFunction(program, "sum", []), target);
+}
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-lvalues-expected.txt b/LayoutTests/webgpu/whlsl-lvalues-expected.txt
new file mode 100644 (file)
index 0000000..ad02231
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS lValues 
+
diff --git a/LayoutTests/webgpu/whlsl-lvalues.html b/LayoutTests/webgpu/whlsl-lvalues.html
new file mode 100644 (file)
index 0000000..ba59737
--- /dev/null
@@ -0,0 +1,106 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Lvalues.</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.lValues = async () => {
+    await checkFail(`
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &(x++);
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &(++x);
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &(x = 3);
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &3;
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int bar(int x) {
+            return x + 1;
+        }
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &bar(3);
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &(7, x);
+            return *y;
+        }
+    `);
+    await checkFail(`
+        enum Days {
+            Monday,
+            Tuesday
+        }
+        int foo()
+        {
+            int x = 0;
+            thread int* y = &(Days.Monday);
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int foo()
+        {
+            thread bool* y = &(true && false);
+            return *y;
+        }
+    `); 
+    await checkFail(`
+        int foo()
+        {
+            thread bool* y = &(!true);
+            return *y;
+        }
+    `); 
+    const program = `
+        int foo()
+        {
+            int x = 3;
+            thread int* y = &x;
+            return *y;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 3);
+};
+
+runTests(whlslTests);
+</script>
+</html>
+
+
diff --git a/LayoutTests/webgpu/whlsl-null-arg-expected.txt b/LayoutTests/webgpu/whlsl-null-arg-expected.txt
new file mode 100644 (file)
index 0000000..82a0cf3
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS passNullToPtrMonomorphic 
+
diff --git a/LayoutTests/webgpu/whlsl-null-arg.html b/LayoutTests/webgpu/whlsl-null-arg.html
new file mode 100644 (file)
index 0000000..21b2eea
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.passNullToPtrMonomorphic = async () =>
+{
+    let program = `
+        int foo(thread int* ptr)
+        {
+            return *ptr;
+        }
+        int bar()
+        {
+            return foo(null);
+        }
+    `;
+    assert_equals(await callIntFunction(program, "bar", []), 0);
+}
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-operator-overload-expected.txt b/LayoutTests/webgpu/whlsl-operator-overload-expected.txt
new file mode 100644 (file)
index 0000000..040f3d1
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS operatorWithoutUninferrableTypeVariable 
+
diff --git a/LayoutTests/webgpu/whlsl-operator-overload.html b/LayoutTests/webgpu/whlsl-operator-overload.html
new file mode 100644 (file)
index 0000000..37fcec6
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Operator+ overload.</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.operatorWithoutUninferrableTypeVariable = async () => {
+    let program = `
+        struct Foo {
+            int x;
+        }
+        Foo operator+(Foo a, Foo b)
+        {
+            Foo result;
+            result.x = a.x + b.x;
+            return result;
+        }
+        int foo()
+        {
+            Foo a;
+            a.x = 645;
+            Foo b;
+            b.x = -35;
+            return (a + b).x;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 645 - 35);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-overload-expected.txt b/LayoutTests/webgpu/whlsl-overload-expected.txt
new file mode 100644 (file)
index 0000000..adb6106
--- /dev/null
@@ -0,0 +1,5 @@
+
+PASS intOverloadResolution 
+PASS intOverloadResolutionReverseOrder 
+PASS notEqualsOverload 
+
diff --git a/LayoutTests/webgpu/whlsl-overload.html b/LayoutTests/webgpu/whlsl-overload.html
new file mode 100644 (file)
index 0000000..3e5472b
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Overload.</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.intOverloadResolution = async () =>
+{
+    let program = `
+        int foo(int) { return 1; }
+        int foo(uint) { return 2; }
+        int foo(float) { return 3; }
+        int bar() { return foo(42); }
+    `;
+    assert_equals(await callIntFunction(program, "bar", []), 1);
+}
+
+whlslTests.intOverloadResolutionReverseOrder = async () =>
+{
+    let program = `
+        int foo(float) { return 3; }
+        int foo(uint) { return 2; }
+        int foo(int) { return 1; }
+        int bar() { return foo(42); }
+    `;
+    assert_equals(await callIntFunction(program, "bar", []), 1);
+}
+
+whlslTests.notEqualsOverload = async () =>
+{
+    await checkFail(
+        `
+            struct Foo { }
+            bool operator!=(Foo, Foo) { return true; }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-setter-spec-tests-expected.txt b/LayoutTests/webgpu/whlsl-setter-spec-tests-expected.txt
new file mode 100644 (file)
index 0000000..d1f2d6c
--- /dev/null
@@ -0,0 +1,8 @@
+
+PASS setterWithMatchedType 
+PASS setterWithNoGetterOverload 
+PASS setterWithNoGetterOverloadFixed 
+PASS recursiveSetters 
+PASS loneSetter 
+PASS loneSetterPointer 
+
diff --git a/LayoutTests/webgpu/whlsl-setter-spec-tests.html b/LayoutTests/webgpu/whlsl-setter-spec-tests.html
new file mode 100644 (file)
index 0000000..8600d6a
--- /dev/null
@@ -0,0 +1,134 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.setterWithMatchedType = async () =>
+{
+    const program = `
+        int operator.foo(int)
+        {
+            return 5;
+        }
+        int operator.foo=(int, int)
+        {
+            return 543;
+        }
+        int foo() {
+            int x;
+            x.foo = 42;
+            return x;
+        }
+        int bar() {
+            int x;
+            return x.foo;
+        }
+    `;
+
+    assert_equals(await callIntFunction(program, "foo", []), 543);
+    //assert_equals(await callIntFunction(program, "bar", []), 5);
+}
+
+whlslTests.setterWithNoGetterOverload = async () =>
+{
+    await checkFail(
+        `
+            struct Foo { }
+            struct Bar { }
+            int operator.foo(Foo)
+            {
+                return 534;
+            }
+            Bar operator.foo=(Bar, int)
+            {
+                return Bar();
+            }
+        `);
+        
+}
+
+whlslTests.setterWithNoGetterOverloadFixed = async () =>
+{
+    const program =`
+        struct Bar { }
+        int operator.foo(Bar)
+        {
+            return 534;
+        }
+        Bar operator.foo=(Bar, int)
+        {
+            return Bar();
+        }
+        int foo() {
+            Bar bar;
+            return bar.foo;
+        }
+        int bar() {
+            Bar bar;
+            bar.foo = 52;
+            return bar.foo;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 534);
+    assert_equals(await callIntFunction(program, "bar", []), 534);
+}
+
+whlslTests.recursiveSetters = async () =>
+{
+    let program = `
+        struct Foo {
+            int x;
+            int y;
+        }
+        struct Bar {
+            int a;
+            int b;
+        }
+        int operator.c(Bar bar) { return bar.a; }
+        Bar operator.bar(Foo foo) { Bar b; b.a = foo.x; b.b = foo.y; return b; }
+        Bar operator.c=(Bar bar, int newval) { bar.a = newval; return bar; }
+        Foo operator.bar=(Foo foo, Bar newval) { foo.x = newval.a; foo.y = newval.b; return foo; }
+        int f() {
+            Foo foo;
+            foo.x = foo.y = 3;
+            foo.bar.c = 8;
+            return foo.x*10 + foo.y;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "f", []), 83);
+}
+
+whlslTests.loneSetter = async () =>
+{
+    await checkFail(
+        `
+            int operator.foo=(int, int)
+            {
+                return 543;
+            }
+        `);
+        
+}
+
+whlslTests.loneSetterPointer = async () =>
+{
+    await checkFail(
+        `
+            thread int* operator.foo=(thread int* ptr, int)
+            {
+                return ptr;
+            }
+        `);
+        
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-store-null-expected.txt b/LayoutTests/webgpu/whlsl-store-null-expected.txt
new file mode 100644 (file)
index 0000000..272c1ca
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS storeNull 
+
diff --git a/LayoutTests/webgpu/whlsl-store-null.html b/LayoutTests/webgpu/whlsl-store-null.html
new file mode 100644 (file)
index 0000000..cf44b32
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.storeNull = async () =>
+{
+    await checkFail(
+        `
+            void foo() { *null = 42; }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
+
diff --git a/LayoutTests/webgpu/whlsl-struct-expected.txt b/LayoutTests/webgpu/whlsl-struct-expected.txt
new file mode 100644 (file)
index 0000000..c620ee1
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS emptyStruct 
+PASS settingAnArrayInsideAStruct 
+
diff --git a/LayoutTests/webgpu/whlsl-struct.html b/LayoutTests/webgpu/whlsl-struct.html
new file mode 100644 (file)
index 0000000..70107c8
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.emptyStruct = async () =>
+{
+    let program = `
+        struct Thingy { }
+        int foo()
+        {
+            Thingy thingy;
+            return 46;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 46);
+};
+
+whlslTests.settingAnArrayInsideAStruct = async () =>
+{
+    let program = `
+        struct Foo {
+            int[1] array;
+        }
+        int foo()
+        {
+            Foo foo;
+            thread Foo* bar = &foo;
+            bar->array[0] = 21;
+            return foo.array[0];
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 21);
+};
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-switch-expected.txt b/LayoutTests/webgpu/whlsl-switch-expected.txt
new file mode 100644 (file)
index 0000000..3f3bf51
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS switchBreak 
+
diff --git a/LayoutTests/webgpu/whlsl-switch.html b/LayoutTests/webgpu/whlsl-switch.html
new file mode 100644 (file)
index 0000000..047061b
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test prefix/postfix.</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.switchBreak = async () =>
+{
+    let program = `
+        int foo(int x)
+        {
+            int result = 0;
+            switch (x) {
+            case 767:
+                result += 27;
+                break;
+            case 69:
+                result += 7624;
+                break;
+            default:
+                result += 49;
+                break;
+            }
+            return result;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", [makeInt(767)]), 27);
+    assert_equals(await callIntFunction(program, "foo", [makeInt(69)]), 7624);
+    assert_equals(await callIntFunction(program, "foo", [makeInt(0)]), 49);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-variable-shadowing-expected.txt b/LayoutTests/webgpu/whlsl-variable-shadowing-expected.txt
new file mode 100644 (file)
index 0000000..1dee5b5
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS variableShadowing 
+
diff --git a/LayoutTests/webgpu/whlsl-variable-shadowing.html b/LayoutTests/webgpu/whlsl-variable-shadowing.html
new file mode 100644 (file)
index 0000000..cec1a43
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test prefix/postfix.</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.variableShadowing = async () =>
+{
+    let program = `
+        int foo()
+        {
+            int y;
+            int x = 7;
+            {
+                int x = 8;
+                y = x;
+            }
+            return y;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 8);
+
+    program = `
+        int foo()
+        {
+            int y;
+            int x = 7;
+            {
+                int x = 8;
+            }
+            y = x;
+            return y;
+        }
+    `;
+    assert_equals(await callIntFunction(program, "foo", []), 7);
+}
+
+runTests(whlslTests);
+</script>
+</html>
diff --git a/LayoutTests/webgpu/whlsl-vector-syntax-expected.txt b/LayoutTests/webgpu/whlsl-vector-syntax-expected.txt
new file mode 100644 (file)
index 0000000..600ed09
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS vectorTypeSyntax 
+
diff --git a/LayoutTests/webgpu/whlsl-vector-syntax.html b/LayoutTests/webgpu/whlsl-vector-syntax.html
new file mode 100644 (file)
index 0000000..3c15f39
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</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.vectorTypeSyntax = async () =>
+{
+    let program = `
+        int foo2()
+        {
+            int2 x;
+            vector<int, 2> z = int2(3, 4);
+            x = z;
+            return x.y;
+        }
+
+        int foo3()
+        {
+            int3 x;
+            vector<int, 3> z = int3(3, 4, 5);
+            x = z;
+            return x.z;
+        }
+
+        int foo4()
+        {
+            int4 x;
+            vector<int,4> z = int4(3, 4, 5, 6);
+            x = z;
+            return x.w;
+        }`;
+
+    assert_equals(await callIntFunction(program, "foo2", []), 4);
+    assert_equals(await callIntFunction(program, "foo3", []), 5);
+    assert_equals(await callIntFunction(program, "foo4", []), 6);
+
+    program = `
+        typedef i = int;
+        int foo2()
+        {
+            int2 x;
+            vector<i, 2> z = int2(3, 4);
+            x = z;
+            return x.y;
+        }`;
+
+    assert_equals(await callIntFunction(program, "foo2", []), 4);
+}
+runTests(whlslTests);
+</script>
+</html>