diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-06-17 16:30:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-17 16:30:18 -0700 |
| commit | d1a8cd23d15d0001131b6f01b0c9bc461279f760 (patch) | |
| tree | 65fffcc653624549d82e20a46c081fa795ce1f13 /tests | |
| parent | cd7f01b63a52eaaad00088524801e502bcb0f168 (diff) | |
Add != operator for enum types (#1394)
This was an oversight in the stdlib, and the `!=` definition follows the `==` in a straightforward fashion.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/language-feature/enums/enum-equality.slang | 40 | ||||
| -rw-r--r-- | tests/language-feature/enums/enum-equality.slang.expected.txt | 4 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/language-feature/enums/enum-equality.slang b/tests/language-feature/enums/enum-equality.slang new file mode 100644 index 000000000..0ad39c0f4 --- /dev/null +++ b/tests/language-feature/enums/enum-equality.slang @@ -0,0 +1,40 @@ +// enum-equality.slang + +// Test that equality (and inequality) of `enum` +// types works as expected. + +//TEST(compute):COMPARE_COMPUTE: + +enum Channel +{ + Red, + Green, + Blue, + Alpha, +} + +int test(int val) +{ + Channel channel= Channel(val); + + int result = 0; + if(channel == Channel.Red) result += 1; + if(channel != Channel.Green) result += 16; + if(channel == Channel.Blue) result += 16*16; + if(channel != Channel.Alpha) result += 16*16*16; + + return result; +} + + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +} diff --git a/tests/language-feature/enums/enum-equality.slang.expected.txt b/tests/language-feature/enums/enum-equality.slang.expected.txt new file mode 100644 index 000000000..e42d67682 --- /dev/null +++ b/tests/language-feature/enums/enum-equality.slang.expected.txt @@ -0,0 +1,4 @@ +1011 +1000 +1110 +10 |
