summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
diff options
context:
space:
mode:
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/namespaces/using-namespace.slang47
-rw-r--r--tests/language-feature/namespaces/using-namespace.slang.expected.txt4
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/language-feature/namespaces/using-namespace.slang b/tests/language-feature/namespaces/using-namespace.slang
new file mode 100644
index 000000000..b0b301929
--- /dev/null
+++ b/tests/language-feature/namespaces/using-namespace.slang
@@ -0,0 +1,47 @@
+// using-namespace.slang
+
+// Test that `using` can bring declarations from a namespace into scope
+
+//TEST(compute):COMPARE_COMPUTE:
+
+namespace X
+{
+ struct A { int a; }
+}
+
+namespace Y
+{
+ // A `using` that brings one namespace into scope of declarations in another
+ //
+ using X;
+
+ int b(A a) { return a.a; }
+}
+
+// A `using` that brings declarations in a namespace into the global scope
+//
+using Y;
+
+int test(int value)
+{
+ // A `using` that brings declarations into a local scope
+ // (and also uses the optional `namespace` placeholder keyword)
+ //
+ using namespace X;
+
+ A a = { value };
+ return b(a);
+}
+
+//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/namespaces/using-namespace.slang.expected.txt b/tests/language-feature/namespaces/using-namespace.slang.expected.txt
new file mode 100644
index 000000000..bc856dafa
--- /dev/null
+++ b/tests/language-feature/namespaces/using-namespace.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+2
+3