summaryrefslogtreecommitdiffstats
path: root/test cases/d/15 compiler run checks
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/d/15 compiler run checks')
-rw-r--r--test cases/d/15 compiler run checks/meson.build50
-rw-r--r--test cases/d/15 compiler run checks/test_sizeof.d17
2 files changed, 67 insertions, 0 deletions
diff --git a/test cases/d/15 compiler run checks/meson.build b/test cases/d/15 compiler run checks/meson.build
new file mode 100644
index 0000000..a80e528
--- /dev/null
+++ b/test cases/d/15 compiler run checks/meson.build
@@ -0,0 +1,50 @@
+project('test-d-run-checks', 'd')
+
+dc = meson.get_compiler('d')
+
+run_sizeof = dc.run('int main() { return (void*).sizeof; }')
+if run_sizeof.returncode() == 8
+ run_versions = ['Is64bits']
+elif run_sizeof.returncode() == 4
+ run_versions = ['Is32bits']
+endif
+run_sizeof_exe = executable('run_sizeof', 'test_sizeof.d',
+ d_module_versions: run_versions,
+)
+test('test D compiler run', run_sizeof_exe)
+
+sizeof_sizeof = dc.sizeof('void*')
+if sizeof_sizeof == 8
+ run_versions = ['Is64bits']
+elif sizeof_sizeof == 4
+ run_versions = ['Is32bits']
+endif
+sizeof_sizeof_exe = executable('sizeof_sizeof', 'test_sizeof.d',
+ d_module_versions: run_versions,
+)
+test('test D compiler sizeof', sizeof_sizeof_exe)
+
+if not dc.has_header('std.stdio')
+ error('Could not find std.stdio import')
+endif
+
+if dc.has_header('not_a_d_module')
+ error('has_header inconsistent result')
+endif
+
+# same checks as C/C++ alignments (D has same alignment requirements as C)
+
+# These tests should return the same value on all
+# platforms. If (and when) they don't, fix 'em up.
+if dc.alignment('char') != 1
+error('Alignment of char misdetected.')
+endif
+
+dbl_alignment = dc.alignment('double')
+
+if dbl_alignment == 8 or dbl_alignment == 4
+message('Alignment of double ok.')
+else
+error('Alignment of double misdetected.')
+endif
+
diff --git a/test cases/d/15 compiler run checks/test_sizeof.d b/test cases/d/15 compiler run checks/test_sizeof.d
new file mode 100644
index 0000000..c7099d0
--- /dev/null
+++ b/test cases/d/15 compiler run checks/test_sizeof.d
@@ -0,0 +1,17 @@
+module test_sizeof;
+
+alias voidp = void*;
+
+int main()
+{
+ version(Is64bits) {
+ enum expectedSz = 8;
+ }
+ else version(Is32bits) {
+ enum expectedSz = 4;
+ }
+ else {
+ assert(false, "No version set!");
+ }
+ return expectedSz == voidp.sizeof ? 0 : 1;
+}