summaryrefslogtreecommitdiffstats
path: root/test cases/d/16 code generation
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test cases/d/16 code generation/exe.d9
-rw-r--r--test cases/d/16 code generation/generator.d13
-rw-r--r--test cases/d/16 code generation/input.txt1
-rw-r--r--test cases/d/16 code generation/meson.build18
4 files changed, 41 insertions, 0 deletions
diff --git a/test cases/d/16 code generation/exe.d b/test cases/d/16 code generation/exe.d
new file mode 100644
index 0000000..0e24d6d
--- /dev/null
+++ b/test cases/d/16 code generation/exe.d
@@ -0,0 +1,9 @@
+module exe;
+
+import generated;
+import std.stdio;
+
+int main()
+{
+ return generatedString() == "Some text to be returned by generated code" ? 0 : 1;
+}
diff --git a/test cases/d/16 code generation/generator.d b/test cases/d/16 code generation/generator.d
new file mode 100644
index 0000000..f944dd3
--- /dev/null
+++ b/test cases/d/16 code generation/generator.d
@@ -0,0 +1,13 @@
+module generator;
+
+import std.file;
+import std.stdio;
+import std.string;
+
+void main(string[] args)
+{
+ const text = cast(string)read(args[1]);
+
+ writeln("module generated;");
+ writefln!`string generatedString() { return "%s"; }`(text.strip());
+}
diff --git a/test cases/d/16 code generation/input.txt b/test cases/d/16 code generation/input.txt
new file mode 100644
index 0000000..aebcda8
--- /dev/null
+++ b/test cases/d/16 code generation/input.txt
@@ -0,0 +1 @@
+Some text to be returned by generated code
diff --git a/test cases/d/16 code generation/meson.build b/test cases/d/16 code generation/meson.build
new file mode 100644
index 0000000..2418aca
--- /dev/null
+++ b/test cases/d/16 code generation/meson.build
@@ -0,0 +1,18 @@
+project('meson-dep-test', 'd')
+
+generator = executable('generator', 'generator.d')
+
+generated = custom_target('generated',
+ capture: true,
+ output: 'generated.d',
+ input: 'input.txt',
+ command: [
+ generator, '@INPUT@'
+ ]
+)
+
+exe = executable('exe', generated, 'exe.d',
+ include_directories: include_directories('.'),
+)
+
+test('test exe', exe)