summaryrefslogtreecommitdiffstats
path: root/tests/preprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/preprocessor')
-rw-r--r--tests/preprocessor/macros/variadic-macro.slang30
-rw-r--r--tests/preprocessor/macros/variadic-macro.slang.expected6
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/preprocessor/macros/variadic-macro.slang b/tests/preprocessor/macros/variadic-macro.slang
new file mode 100644
index 000000000..21e59e148
--- /dev/null
+++ b/tests/preprocessor/macros/variadic-macro.slang
@@ -0,0 +1,30 @@
+// variadic-macro.slang
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// First we text a variadic macro with the default variadic
+// parameter name (`__VA_ARGS__`) and other non-variadic parameter.
+
+#define A(X, ...) (X ; __VA_ARGS__)
+
+A(1, 2, 3)
+
+// Next we test a varadic macro where the variadic parameter
+// has been given an explicit name.
+
+#define B(B_ARGS...) (B_ARGS)
+
+B(4, 5)
+
+// Finally, we test the case where the variadic parameter
+// might have zero arguments passed for it, so that
+// the result produces a trailing comma.
+//
+// TODO: If we add support for deleting trailing commas
+// in these cases to Slang, we can update this case to
+// test that support.
+
+#define C(Y, ARGS...) (Y , ARGS)
+
+C(1)
+C(2, 3)
+C(4, 5, 6)
diff --git a/tests/preprocessor/macros/variadic-macro.slang.expected b/tests/preprocessor/macros/variadic-macro.slang.expected
new file mode 100644
index 000000000..d540d7e25
--- /dev/null
+++ b/tests/preprocessor/macros/variadic-macro.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+( 1 ; 2 , 3 ) ( 4 , 5 ) ( 1 , ) ( 2 , 3 ) ( 4 , 5 , 6 )
+}