diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/d/16 code generation | |
parent | Initial commit. (diff) | |
download | meson-upstream.tar.xz meson-upstream.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/d/16 code generation')
-rw-r--r-- | test cases/d/16 code generation/exe.d | 9 | ||||
-rw-r--r-- | test cases/d/16 code generation/generator.d | 13 | ||||
-rw-r--r-- | test cases/d/16 code generation/input.txt | 1 | ||||
-rw-r--r-- | test cases/d/16 code generation/meson.build | 18 |
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) |