diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/enum.slang | 66 | ||||
| -rw-r--r-- | tests/compute/enum.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/diagnostics/static-ref-to-nonstatic-member.slang | 12 | ||||
| -rw-r--r-- | tests/diagnostics/static-ref-to-nonstatic-member.slang.expected | 6 |
4 files changed, 88 insertions, 0 deletions
diff --git a/tests/compute/enum.slang b/tests/compute/enum.slang new file mode 100644 index 000000000..2619d8eb5 --- /dev/null +++ b/tests/compute/enum.slang @@ -0,0 +1,66 @@ +// enum.slang +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +// Confirm that basic `enum` declarations are supported. + +enum Color +{ + Red, + Green = 2, + Blue, +} + + +int test(int val) +{ + Color c = Color.Red; + + if(val > 1) + { + c = Color.Green; + } + + if(c == Color.Red) + { + if(val & 1) + { + c = Color.Blue; + } + } + + switch(c) + { + case Color.Red: + val = 1; + break; + + case Color.Green: + val = 2; + break; + + case Color.Blue: + val = 3; + break; + + default: + val = -1; + break; + } + + return (val << 4) + int(c); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int val = int(tid); + val = test(val); + + outputBuffer[tid] = val; +}
\ No newline at end of file diff --git a/tests/compute/enum.slang.expected.txt b/tests/compute/enum.slang.expected.txt new file mode 100644 index 000000000..946476280 --- /dev/null +++ b/tests/compute/enum.slang.expected.txt @@ -0,0 +1,4 @@ +10 +33 +22 +22 diff --git a/tests/diagnostics/static-ref-to-nonstatic-member.slang b/tests/diagnostics/static-ref-to-nonstatic-member.slang new file mode 100644 index 000000000..485a0ed67 --- /dev/null +++ b/tests/diagnostics/static-ref-to-nonstatic-member.slang @@ -0,0 +1,12 @@ +//TEST:SIMPLE: + + +struct Color +{ + int Red; +} + +void test() +{ + int x = Color.Red; +}
\ No newline at end of file diff --git a/tests/diagnostics/static-ref-to-nonstatic-member.slang.expected b/tests/diagnostics/static-ref-to-nonstatic-member.slang.expected new file mode 100644 index 000000000..76550e4b5 --- /dev/null +++ b/tests/diagnostics/static-ref-to-nonstatic-member.slang.expected @@ -0,0 +1,6 @@ +result code = -1 +standard error = { +tests/diagnostics/static-ref-to-nonstatic-member.slang(11): error 30100: type 'Color' cannot be used to refer to non-static member 'Red' +} +standard output = { +} |
