summaryrefslogtreecommitdiff
path: root/tests/preprocessor
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-06-26 13:47:08 -0700
committerGitHub <noreply@github.com>2017-06-26 13:47:08 -0700
commit0259ddb0a72d3b12278404847f6e30b63e97cfc3 (patch)
treed73c230a8b2ddc06e0fa978945aa8a838b189236 /tests/preprocessor
parent3f316dcbd9274efc74f817cf36f17a511ff2e21e (diff)
parentf6cb66feab3439f41ca87cb307f69b49654883ab (diff)
Merge pull request #43 from tfoleyNV/import-macros
Add support for `#import`
Diffstat (limited to 'tests/preprocessor')
-rw-r--r--tests/preprocessor/import.hlsl18
-rw-r--r--tests/preprocessor/import.slang.h12
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/preprocessor/import.hlsl b/tests/preprocessor/import.hlsl
new file mode 100644
index 000000000..486023678
--- /dev/null
+++ b/tests/preprocessor/import.hlsl
@@ -0,0 +1,18 @@
+//TEST:SIMPLE:-profile vs_5_0
+
+// Confirm that `#import` interacts with preprocessor as expected
+
+// Here is a macro that flows from parent to child file
+#define FOO float
+
+// Here we import the child file
+#import "import.slang.h"
+
+// Here we use a macro that flows the other way (child->parent)
+BAR g( FOO x ) { return f(x); }
+
+// Here we confirm that importing the file again is a no-op
+#import "import.slang.h"
+
+void main()
+{}
diff --git a/tests/preprocessor/import.slang.h b/tests/preprocessor/import.slang.h
new file mode 100644
index 000000000..a97a199f0
--- /dev/null
+++ b/tests/preprocessor/import.slang.h
@@ -0,0 +1,12 @@
+// Confirm that `#import` interacts with preprocessor as expected
+
+// We add a guard to ensure that this file isn't imported more than once
+#ifdef BAR
+#error File imported more than one!
+#endif
+
+// Here we use a macro from the parent file
+FOO f( FOO y ) { return y; }
+
+// Here is a macro that flows from child to parent
+#define BAR float