summaryrefslogtreecommitdiffstats
path: root/tests/preprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/preprocessor')
-rw-r--r--tests/preprocessor/circular-include/a.slang7
-rw-r--r--tests/preprocessor/circular-include/b.slang1
-rw-r--r--tests/preprocessor/duplicate-include/a.slang13
-rw-r--r--tests/preprocessor/duplicate-include/b.slang3
4 files changed, 24 insertions, 0 deletions
diff --git a/tests/preprocessor/circular-include/a.slang b/tests/preprocessor/circular-include/a.slang
new file mode 100644
index 000000000..fe519dd12
--- /dev/null
+++ b/tests/preprocessor/circular-include/a.slang
@@ -0,0 +1,7 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// Test that we can diagnose an error when there is a circular include.
+
+// CHECK: error 15302: cyclic `#include` of file
+
+#include "b.slang" \ No newline at end of file
diff --git a/tests/preprocessor/circular-include/b.slang b/tests/preprocessor/circular-include/b.slang
new file mode 100644
index 000000000..1f259de9a
--- /dev/null
+++ b/tests/preprocessor/circular-include/b.slang
@@ -0,0 +1 @@
+#include "a.slang" \ No newline at end of file
diff --git a/tests/preprocessor/duplicate-include/a.slang b/tests/preprocessor/duplicate-include/a.slang
new file mode 100644
index 000000000..ce2c22b61
--- /dev/null
+++ b/tests/preprocessor/duplicate-include/a.slang
@@ -0,0 +1,13 @@
+//TEST:INTERPRET(filecheck=CHECK):
+
+// Test that it is OK to include the same file multiple times.
+
+#include "b.slang"
+
+#include "b.slang"
+
+void main()
+{
+ // CHECK: result: 23
+ printf("result: %d\n", foo());
+}
diff --git a/tests/preprocessor/duplicate-include/b.slang b/tests/preprocessor/duplicate-include/b.slang
new file mode 100644
index 000000000..c3769f038
--- /dev/null
+++ b/tests/preprocessor/duplicate-include/b.slang
@@ -0,0 +1,3 @@
+#pragma once
+
+int foo() { return 23; } \ No newline at end of file