Debian Codegraph @

gcc/testsuite/gdc.test/runnable/test18054.d

raw
1 /+
2 REQUIRED_ARGS: -d
3 RUN_OUTPUT:
4 ---
5 float: 1 == 1
6 double: 1 == 1
7 real: 1 == 1
8 ifloat: 1 == 1
9 idouble: 1 == 1
10 ireal: 1 == 1
11 cfloat: 1 == 1
12 cdouble: 1 == 1
13 creal: 1 == 1
14 ---
15 +/
16
17 import core.stdc.stdio : printf;
18
19 void test(T, string lit)()
20 {
21 T d = mixin(lit);
22 bool runtime = cast(bool) d;
23 bool folded = cast(bool) mixin(lit);
24
25 printf((T.stringof ~ ": %d == %d\n\0").ptr, runtime, folded);
26 }
27
28 void main()
29 {
30 test!(float, "0.5f");
31 test!(double, "0.5" );
32 test!(real, "0.5L");
33
34 test!(ifloat, "0.5i");
35 test!(idouble, "0.5i");
36 test!(ireal, "0.5i");
37
38 test!(cfloat, "0.3 + 0.5i");
39 test!(cdouble, "0.3 + 0.5i");
40 test!(creal, "0.3 + 0.5i");
41 }