summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
diff options
context:
space:
mode:
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang8
-rw-r--r--tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang29
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang
new file mode 100644
index 000000000..7982d8baa
--- /dev/null
+++ b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_lib.slang
@@ -0,0 +1,8 @@
+// Library module containing a public unscoped enum
+
+[UnscopedEnum]
+public enum TestEnum
+{
+ CASE_A,
+ CASE_B
+}; \ No newline at end of file
diff --git a/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang
new file mode 100644
index 000000000..e20f387fb
--- /dev/null
+++ b/tests/language-feature/modules/unscoped-enum-visibility/unscoped_enum_user.slang
@@ -0,0 +1,29 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type
+//
+// Test for public unscoped enum constants visibility across module boundaries
+//
+// This test verifies that unscoped enum constants are visible across module
+// boundaries when the enum is declared as public.
+//
+
+import unscoped_enum_lib;
+
+//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<uint> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // These should all be visible due to the public unscoped enum
+ TestEnum e1 = CASE_A; // Should work - unscoped access
+ TestEnum e2 = TestEnum.CASE_B; // Should work - scoped access
+
+ // CHECK: 0
+ outputBuffer[0] = (uint)e1;
+ // CHECK: 1
+ outputBuffer[1] = (uint)e2;
+ // CHECK: 0
+ outputBuffer[2] = (uint)CASE_A;
+ // CHECK: 1
+ outputBuffer[3] = (uint)CASE_B;
+} \ No newline at end of file