]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/runnable/test7452.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / runnable / test7452.d
1 import core.stdc.stdio : printf;
2
3 //------------------------------------------------------------------------------
4
5 T enforce7452(T, string file = __FILE__, size_t line = __LINE__)
6 (T value, lazy const(char)[] msg = null) @safe pure
7 {
8 if (!value)
9 throw new Exception(msg ? msg.idup : "Enforcement failed", file, line);
10 return value;
11 }
12
13 int f7452()(int x)
14 {
15 enforce7452(x > 0);
16 return x;
17 }
18 void g7452() @safe pure
19 {
20 assert(4 == f7452(4));
21 }
22
23 //------------------------------------------------------------------------------
24
25 void e7452b(int, lazy int) pure nothrow @safe {}
26 int f7452b()(int x)
27 {
28 e7452b(x, 0);
29 return x;
30 }
31 void g7452b() pure nothrow @safe
32 {
33 assert(4 == f7452b(4));
34 }
35
36 //------------------------------------------------------------------------------
37
38 int f7452c()(int x)
39 {
40 auto y = function int() { return 0; };
41 return x;
42 }
43 void g7452c() pure nothrow @safe
44 {
45 assert(4 == f7452c(4));
46 }
47
48 //------------------------------------------------------------------------------
49
50 auto f6332a()() { return 1; }
51 int f6332b()() { return 1; }
52
53 alias f6332a!() F6332a;
54
55 void g6332() pure nothrow @safe
56 {
57 auto x = f6332b();
58 auto y = f6332a();
59 assert(x == y);
60 }
61
62 //------------------------------------------------------------------------------
63
64 int main()
65 {
66 g7452();
67 g7452b();
68 g7452c();
69 g6332();
70
71 printf("Success\n");
72 return 0;
73 }
74
75