summaryrefslogtreecommitdiffstats
path: root/tests/front-end
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-02-27 10:32:14 -0800
committerGitHub <noreply@github.com>2025-02-27 10:32:14 -0800
commit6cf15f4ea1fe044d8227440dcc30ac712334568e (patch)
tree668f3ef00fd0b144dd3221ee4ab8d344397649d8 /tests/front-end
parent2ebf9555a54c00f45b1cd0bdd7f6c163120bb845 (diff)
Allow `.member` syntax on vector and scalars. (#6424)
* Allow `.member` syntax on vector and scalars. * Fix. * fix. * Fix. * update comment. * Fix tests. * Fix warning. * Add more tests.
Diffstat (limited to 'tests/front-end')
-rw-r--r--tests/front-end/matrix-member.slang17
-rw-r--r--tests/front-end/scalar-member.slang17
-rw-r--r--tests/front-end/vector-member.slang17
3 files changed, 51 insertions, 0 deletions
diff --git a/tests/front-end/matrix-member.slang b/tests/front-end/matrix-member.slang
new file mode 100644
index 000000000..447fe715f
--- /dev/null
+++ b/tests/front-end/matrix-member.slang
@@ -0,0 +1,17 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-output-using-type
+
+extension float2x2
+{
+ float sum() { return this[0][0] + this[1][1]; }
+}
+
+//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride = 4)
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ float2x2 v = {1,2,3,4};
+ // CHECK: 5
+ outputBuffer[0] = v.sum();
+} \ No newline at end of file
diff --git a/tests/front-end/scalar-member.slang b/tests/front-end/scalar-member.slang
new file mode 100644
index 000000000..b85b8772c
--- /dev/null
+++ b/tests/front-end/scalar-member.slang
@@ -0,0 +1,17 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-output-using-type
+
+extension float
+{
+ float sum() { return this + 1; }
+}
+
+//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride = 4)
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ float v = 10.0;
+ // CHECK: 11
+ outputBuffer[0] = v.sum();
+} \ No newline at end of file
diff --git a/tests/front-end/vector-member.slang b/tests/front-end/vector-member.slang
new file mode 100644
index 000000000..adced39e4
--- /dev/null
+++ b/tests/front-end/vector-member.slang
@@ -0,0 +1,17 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-output-using-type
+
+extension float3
+{
+ float sum() { return this.x + this.y + this.z; }
+}
+
+//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride = 4)
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ float3 v = { 1, 2, 3 };
+ // CHECK: 6
+ outputBuffer[0] = v.sum();
+} \ No newline at end of file