summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-04-09 04:15:33 -0400
committerGitHub <noreply@github.com>2021-04-09 01:15:33 -0700
commit5a0d62f302b38e972c99cb5e228d016b5fa041ff (patch)
treea8870f26aa58ff24f85d74291be9fbf185681ebf /tests
parent8a71039475212fb1e1a6dd2fd2911d02769637ef (diff)
Tests showing preprocessor issues (#1790)
* #include an absolute path didn't work - because paths were taken to always be relative. * Tests showing issues with preprocessor behavior. Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/current-bugs/preproc-concat-1.slang14
-rw-r--r--tests/current-bugs/preproc-concat-1.slang.expected6
-rw-r--r--tests/current-bugs/preproc-concat-2.slang17
-rw-r--r--tests/current-bugs/preproc-concat-2.slang.expected6
-rw-r--r--tests/current-bugs/preproc-concat-3.slang18
-rw-r--r--tests/current-bugs/preproc-concat-3.slang.expected6
-rw-r--r--tests/current-bugs/preproc-concat-4.slang30
-rw-r--r--tests/current-bugs/preproc-concat-4.slang.expected6
-rw-r--r--tests/current-bugs/preproc-pound-pound-1.slang10
-rw-r--r--tests/current-bugs/preproc-pound-pound-1.slang.expected6
-rw-r--r--tests/current-bugs/preproc-pound-pound-2.slang13
-rw-r--r--tests/current-bugs/preproc-pound-pound-2.slang.expected6
-rw-r--r--tests/current-bugs/preproc-stringify-1.slang14
-rw-r--r--tests/current-bugs/preproc-stringify-1.slang.expected6
14 files changed, 158 insertions, 0 deletions
diff --git a/tests/current-bugs/preproc-concat-1.slang b/tests/current-bugs/preproc-concat-1.slang
new file mode 100644
index 000000000..d9f205457
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-1.slang
@@ -0,0 +1,14 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+#define CONCAT(a, b) a ## b
+
+// Correct output AB;
+// Slang output
+// ab;
+
+#define A a
+#define B b
+
+CONCAT(A, B);
diff --git a/tests/current-bugs/preproc-concat-1.slang.expected b/tests/current-bugs/preproc-concat-1.slang.expected
new file mode 100644
index 000000000..673d7bc4c
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-1.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+ab ;
+}
diff --git a/tests/current-bugs/preproc-concat-2.slang b/tests/current-bugs/preproc-concat-2.slang
new file mode 100644
index 000000000..f3c4d28ff
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-2.slang
@@ -0,0 +1,17 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+#define CONCAT(a, b) a ## b
+
+#define A a
+#define B b
+
+#define A2 A
+#define B2 B
+
+// Correct output: a A2B2 b;
+// Slang output
+// a ab b ;
+
+CONCAT(A2 A2, B2 B2);
diff --git a/tests/current-bugs/preproc-concat-2.slang.expected b/tests/current-bugs/preproc-concat-2.slang.expected
new file mode 100644
index 000000000..4b30fc7c2
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-2.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+a ab b ;
+}
diff --git a/tests/current-bugs/preproc-concat-3.slang b/tests/current-bugs/preproc-concat-3.slang
new file mode 100644
index 000000000..c4077f75d
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-3.slang
@@ -0,0 +1,18 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+#define CONCAT(a, b) a ## b
+
+#define A a
+#define B b
+
+#define A2 A
+#define B2 B
+
+// Gives error (as trys to concat unexpanded input)
+// <source>:11:1: error: pasting formed ')CONCAT', an invalid preprocessing token
+//
+// Slang output: aabb ;
+
+CONCAT(CONCAT(A2, A2), CONCAT(B2, B2));
diff --git a/tests/current-bugs/preproc-concat-3.slang.expected b/tests/current-bugs/preproc-concat-3.slang.expected
new file mode 100644
index 000000000..8be308266
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-3.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+aabb ;
+}
diff --git a/tests/current-bugs/preproc-concat-4.slang b/tests/current-bugs/preproc-concat-4.slang
new file mode 100644
index 000000000..47b0e1452
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-4.slang
@@ -0,0 +1,30 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+// So the real question here is what happens with pasting and stringifying.
+// As per the spec they have to be performed *before* expansion. If when we do an expansion
+// we add to the stream FunctionArg that holds the 'to be' lazily expanded parameter we have a problem
+//
+// If we move to a new stream *and* the token afterwards, is ##
+
+
+#define CONCAT(a, b) a ## b
+
+#define A a
+#define B b
+
+#define A2 A
+#define B2 B
+
+#define STRINGIFY(x) #x
+
+// Should be
+// CONCAT(a, b) A2B2 CONCAT(a, b)
+// CONCAT is disabled, A2 and B2 are processed on next pass
+// A2 B2 are first and last tokens pre expansion args
+//
+// Slang outputs
+// ab ab ab
+
+CONCAT(CONCAT(A, B) A2, B2 CONCAT(A, B))
diff --git a/tests/current-bugs/preproc-concat-4.slang.expected b/tests/current-bugs/preproc-concat-4.slang.expected
new file mode 100644
index 000000000..82d7225b2
--- /dev/null
+++ b/tests/current-bugs/preproc-concat-4.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+ab ab ab
+}
diff --git a/tests/current-bugs/preproc-pound-pound-1.slang b/tests/current-bugs/preproc-pound-pound-1.slang
new file mode 100644
index 000000000..7f369b861
--- /dev/null
+++ b/tests/current-bugs/preproc-pound-pound-1.slang
@@ -0,0 +1,10 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+// GCC: <source>:1:9: error: '##' cannot appear at either end of a macro expansion.
+// Clang: <source>:1:21: error: '##' cannot appear at start of macro expansion
+// Slang outputs Hello ## There;
+#define POUND_POUND ##
+
+Hello POUND_POUND There;
diff --git a/tests/current-bugs/preproc-pound-pound-1.slang.expected b/tests/current-bugs/preproc-pound-pound-1.slang.expected
new file mode 100644
index 000000000..80a64402a
--- /dev/null
+++ b/tests/current-bugs/preproc-pound-pound-1.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+Hello ## There ;
+}
diff --git a/tests/current-bugs/preproc-pound-pound-2.slang b/tests/current-bugs/preproc-pound-pound-2.slang
new file mode 100644
index 000000000..44181261b
--- /dev/null
+++ b/tests/current-bugs/preproc-pound-pound-2.slang
@@ -0,0 +1,13 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+#define A a
+#define B b
+#define OBJ A ## B
+
+// Should output AB
+// Slang outputs ab
+
+OBJ
+
diff --git a/tests/current-bugs/preproc-pound-pound-2.slang.expected b/tests/current-bugs/preproc-pound-pound-2.slang.expected
new file mode 100644
index 000000000..a818a4683
--- /dev/null
+++ b/tests/current-bugs/preproc-pound-pound-2.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+ab
+}
diff --git a/tests/current-bugs/preproc-stringify-1.slang b/tests/current-bugs/preproc-stringify-1.slang
new file mode 100644
index 000000000..03e8366b5
--- /dev/null
+++ b/tests/current-bugs/preproc-stringify-1.slang
@@ -0,0 +1,14 @@
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// NOTE! This test should *fail*, if preprocessor is working correctly!
+
+#define A a
+#define B b
+
+// Correct output
+// "A B"
+// Slang output
+// # a b ;
+
+#define STRINGIFY(x) #x
+STRINGIFY(A B); \ No newline at end of file
diff --git a/tests/current-bugs/preproc-stringify-1.slang.expected b/tests/current-bugs/preproc-stringify-1.slang.expected
new file mode 100644
index 000000000..53efce117
--- /dev/null
+++ b/tests/current-bugs/preproc-stringify-1.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+# a b ;
+}