summaryrefslogtreecommitdiff
path: root/tests/language-feature/constants
diff options
context:
space:
mode:
Diffstat (limited to 'tests/language-feature/constants')
-rw-r--r--tests/language-feature/constants/type-cast-const.slang23
-rw-r--r--tests/language-feature/constants/type-cast-const.slang.expected.txt1
-rw-r--r--tests/language-feature/constants/type-cast-truncate.slang15
-rw-r--r--tests/language-feature/constants/type-cast-truncate.slang.expected.txt2
4 files changed, 41 insertions, 0 deletions
diff --git a/tests/language-feature/constants/type-cast-const.slang b/tests/language-feature/constants/type-cast-const.slang
new file mode 100644
index 000000000..d0291aa7d
--- /dev/null
+++ b/tests/language-feature/constants/type-cast-const.slang
@@ -0,0 +1,23 @@
+//TEST(compute):COMPARE_COMPUTE:
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -profile cs_5_0
+
+int check<let b : bool>(int x)
+{
+ // CHECK: int v{{.*}}[int(2)]
+ int v[((int)b) + 1];
+ for (int i = 0; i < ((int)b) + 1; i++)
+ v[i] = i;
+ return (int)v[x];
+}
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int tid = dispatchThreadID.x;
+ int inVal = tid;
+ int outVal = check<true>(inVal + 1);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/language-feature/constants/type-cast-const.slang.expected.txt b/tests/language-feature/constants/type-cast-const.slang.expected.txt
new file mode 100644
index 000000000..56a6051ca
--- /dev/null
+++ b/tests/language-feature/constants/type-cast-const.slang.expected.txt
@@ -0,0 +1 @@
+1 \ No newline at end of file
diff --git a/tests/language-feature/constants/type-cast-truncate.slang b/tests/language-feature/constants/type-cast-truncate.slang
new file mode 100644
index 000000000..451d982f2
--- /dev/null
+++ b/tests/language-feature/constants/type-cast-truncate.slang
@@ -0,0 +1,15 @@
+//TEST(compute):COMPARE_COMPUTE: -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+static const int c = (int8_t)255;
+
+[numthreads(1, 1, 1)]
+void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int tid = dispatchThreadID.x;
+ int inVal = tid;
+ int outVal = c;
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/language-feature/constants/type-cast-truncate.slang.expected.txt b/tests/language-feature/constants/type-cast-truncate.slang.expected.txt
new file mode 100644
index 000000000..a97ae25ba
--- /dev/null
+++ b/tests/language-feature/constants/type-cast-truncate.slang.expected.txt
@@ -0,0 +1,2 @@
+type: int32_t
+-1 \ No newline at end of file