summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/properties/property-in-interface.slang47
-rw-r--r--tests/language-feature/properties/property-in-interface.slang.expected.txt4
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/language-feature/properties/property-in-interface.slang b/tests/language-feature/properties/property-in-interface.slang
new file mode 100644
index 000000000..ba6d5eaa9
--- /dev/null
+++ b/tests/language-feature/properties/property-in-interface.slang
@@ -0,0 +1,47 @@
+// property-in-interface.slang
+
+//TEST(compute):COMPARE_COMPUTE:
+
+// Test that interfaces can include property declarations.
+
+interface ICell
+{
+ property value : int { get; set; }
+}
+
+struct MyCell : ICell
+{
+ var _data : int;
+
+ property value : int { get { return _data; } set(newValue) { _data = newValue; } }
+}
+
+struct YourCell : ICell
+{
+ int value;
+}
+
+int helper<C : ICell>(C cell)
+{
+ cell.value = cell.value + 1;
+ return cell.value;
+}
+
+int test(int value)
+{
+ MyCell myCell = { value+1 };
+ YourCell yourCell = { value };
+ return helper(myCell)*16 + helper(yourCell);
+}
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = outputBuffer[tid];
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/language-feature/properties/property-in-interface.slang.expected.txt b/tests/language-feature/properties/property-in-interface.slang.expected.txt
new file mode 100644
index 000000000..ba2ec282d
--- /dev/null
+++ b/tests/language-feature/properties/property-in-interface.slang.expected.txt
@@ -0,0 +1,4 @@
+21
+32
+43
+54