1 module foo.bar;
2 
3 import core.vararg;
4 import std.stdio;
5 
6 pragma(lib, "test");
7 pragma(msg, "Hello World");
8 
9 static assert(true, "message");
10 
11 alias double mydbl;
12 
13 int testmain()
14 in
15 {
16     assert(1+(2+3) == -(1 - 2*3));
17 }
18 out (result)
19 {
20     assert(result == 0);
21 }
22 body
23 {
24     float f = float.infinity;
25     int i = cast(int) f;
26     writeln((i,1),2);
27     writeln(cast(int)float.max);
28     assert(i == cast(int)float.max);
29     assert(i == 0x80000000);
30     return 0;
31 }
32 
33 struct S { int m, n; }
34 
35 template Foo(T, int V)
36 {
37     void foo(...)
38     {
39         static if (is(Object _ : X!TL, alias X, TL...)) {}  // Bugzilla 10044
40 
41         auto x = __traits(hasMember, Object, "noMember");
42         auto y = is(Object : X!TL, alias X, TL...);
43         assert(!x && !y, "message");
44 
45         S s = { 1,2 };
46         auto a = [1, 2, 3];
47         auto aa = [1:1, 2:2, 3:3];
48 
49         int n,m;
50     }
51 
52     int bar(double d, int x)
53     {
54     if (d)
55     {   d++;
56     }
57     else
58         d--;
59 
60     asm
61     {	naked ;
62         mov EAX, 3;
63     }
64 
65     for (;;)
66     {
67         d = d + 1;
68     }
69 
70     for (int i = 0; i < 10; i++)
71     {
72         d = i ? d + 1 : 5;
73     }
74 
75     char[] s;
76     foreach (char c; s)
77     {
78         d *= 2;
79         if (d)
80         break;
81         else
82         continue;
83     }
84 
85     switch (V)
86     {
87         case 1:
88         case 2: break;
89         case 3: goto case 1;
90         case 4: goto default;
91         default:
92         d /= 8;
93         break;
94     }
95 
96         enum Label { A, B, C };
97         void fswitch(Label l)
98         {
99             final switch (l)
100             {
101             case A: break;
102             case B: break;
103             case C: break;
104             }
105         }
106 
107     loop:
108     while (x)
109     {
110         x--;
111         if (x)
112         break loop;
113         else
114         continue loop;
115     }
116 
117     do
118     {
119         x++;
120     } while (x < 10);
121 
122     try
123     {
124         bar(1, 2);
125     }
126     catch (Object o)
127     {
128         x++;
129     }
130     finally
131     {
132         x--;
133     }
134 
135     Object o;
136     synchronized (o)
137     {
138         x = ~x;
139     }
140 
141     synchronized
142     {
143         x = x < 3;
144     }
145 
146     with (o)
147     {
148         toString();
149     }
150     }
151 }
152 
153 static this()
154 {
155 }
156 
157 static ~this()
158 {
159 }
160 
161 pure nothrow @safe @nogc static  this() {}
162 pure nothrow @safe @nogc static ~this() {}
163 static  this() pure nothrow @safe @nogc {}
164 static ~this() pure nothrow @safe @nogc {}
165 
166 pure nothrow @safe @nogc shared static  this() {}
167 pure nothrow @safe @nogc shared static ~this() {}
168 shared static  this() pure nothrow @safe @nogc {}
169 shared static ~this() pure nothrow @safe @nogc {}
170 
171 interface iFoo{}
172 class xFoo: iFoo{}
173 
174 interface iFoo2{}
175 class xFoo2: iFoo, iFoo2{}
176 
177 class Foo3
178 {
179     this(int a, ...){}
180     this(int* a){}
181 }
182 
183 alias int myint;
184 
185 static notquit = 1;
186 
187 class Test
188 {
189     void a() {}
190     void b() {}
191     void c() {}
192     void d() {}
193     void e() {}
194     void f() {}
195     void g() {}
196     void h() {}
197     void i() {}
198     void j() {}
199     void k() {}
200     void l() {}
201     void m() {}
202     void n() {}
203     void o() {}
204     void p() {}
205     void q() {}
206     void r() {}
207     void s() {}
208     void t() {}
209     void u() {}
210     void v() {}
211     void w() {}
212     void x() {}
213     void y() {}
214     void z() {}
215 
216     void aa() {}
217     void bb() {}
218     void cc() {}
219     void dd() {}
220     void ee() {} // Try adding or removing some functions here to see the effect.
221 
222     template A(T) { }
223 
224     alias A!(uint) getHUint;
225     alias A!(int) getHInt;
226     alias A!(float) getHFloat;
227     alias A!(ulong) getHUlong;
228     alias A!(long) getHLong;
229     alias A!(double) getHDouble;
230     alias A!(byte) getHByte;
231     alias A!(ubyte) getHUbyte;
232     alias A!(short) getHShort;
233     alias A!(ushort) getHUShort;
234     alias A!(real) getHReal;
235 
236     alias void F();
237 
238     pure nothrow @safe @nogc unittest {}
239     pure nothrow @safe @nogc invariant {}
240 
241     pure nothrow @safe @nogc new (size_t sz) { return null; }
242     pure nothrow @safe @nogc delete (void* p) { }
243 }
244 
245 template templ( T )
246 {
247     void templ( T val )
248     {
249         pragma( msg, "Invalid destination type." );
250     }
251 }
252 
253 static char[] charArray = [ '\"', '\'' ];
254 
255 class Point
256 {
257     auto x = 10;
258     uint y = 20;
259 }
260 
261 template Foo2(bool bar)
262 {
263     void test()
264     {
265     static if(bar)
266     {
267         int i;
268     }
269     else
270     {
271     }
272     static if(!bar)
273     {
274     }
275     else
276     {
277     }
278     }
279 }
280 
281 
282 template Foo4()
283 {
284         void bar()
285         {
286         }
287 }
288 
289 template Foo4x( T... ) {}
290 
291 class Baz4
292 {
293         mixin Foo4 foo;
294         mixin Foo4x!(int, "str") foox;
295 
296         alias foo.bar baz;
297 }
298 
299 int test(T)(T t)
300 {
301         if (auto o = cast(Object)t) return 1;
302         return 0;
303 }
304 
305 enum x6 = 1;
306 
307 bool foo6(int a, int b, int c, int d)
308 {
309     return (a < b) != (c < d);
310 }
311 
312 auto foo7(int x)
313 {
314         return 5;
315 }
316 
317 class D8{}
318 void func8()
319 {
320   scope a= new D8();
321 }
322 
323 T func9(T)() if (true)
324 {
325     T i;
326     scope(exit) i= 1;
327     scope(success) i = 2;
328     scope(failure) i = 3;
329     return i;
330 }
331 
332 template V10(T)
333 {
334     void func()
335     {
336         for(int i,j=4; i<3;i++)
337         {
338         }
339     }
340 }
341 
342 int foo11(int function() fn)
343 {
344     return fn();
345 }
346 
347 int bar11(T)()
348 {
349     return foo11(function int (){ return 0; });
350 }
351 
352 
353 struct S6360
354 {
355     @property long weeks1() const pure nothrow { return 0; }
356 
357     @property const pure nothrow long weeks2() { return 0; }
358 }
359 
360 
361 struct S12
362 {
363     /// postfix storage class and constructor
364     this(int n) nothrow{}
365 
366     /// prefix storage class (==StorageClassDeclaration) and constructor
367     nothrow this(string s){}
368 }
369 
370 /// dummy
371 struct T12
372 {
373     /// postfix storage class and template constructor
374     this()(int args) immutable { }
375 
376     /// prefix storage class (==StorageClassDeclaration) and template constructor
377     immutable this(A...)(A args){ }
378 }
379 
380 
381 // 6591
382 import std.stdio : writeln, F = File;
383 
384 void foo6591()()
385 {
386     import std.stdio : writeln, F = File;
387 }
388 
389 
390 // 8081
391 version(unittest) {
392     pure nothrow unittest {}
393     pure nothrow unittest {}
394 
395     public unittest {}
396     extern(C) unittest {}
397     align unittest {}
398 }
399 
400 
401 // 10334
402 
403 template Foo10334(T) if (Bar10334!()) {}                ///
404 template Foo10334(T) if (Bar10334!100) {}               ///
405 template Foo10334(T) if (Bar10334!3.14) {}              ///
406 template Foo10334(T) if (Bar10334!"str") {}             ///
407 template Foo10334(T) if (Bar10334!1.4i) {}              ///
408 template Foo10334(T) if (Bar10334!null) {}              ///
409 template Foo10334(T) if (Bar10334!true) {}              ///
410 template Foo10334(T) if (Bar10334!false) {}             ///
411 template Foo10334(T) if (Bar10334!'A') {}               ///
412 template Foo10334(T) if (Bar10334!int) {}               ///
413 template Foo10334(T) if (Bar10334!string) {}            ///
414 template Foo10334(T) if (Bar10334!wstring) {}           ///
415 template Foo10334(T) if (Bar10334!dstring) {}           ///
416 template Foo10334(T) if (Bar10334!this) {}              ///
417 template Foo10334(T) if (Bar10334!([1,2,3])) {}         ///
418 template Foo10334(T) if (Bar10334!(Baz10334!())) {}     ///
419 template Foo10334(T) if (Bar10334!(Baz10334!T)) {}      ///
420 template Foo10334(T) if (Bar10334!(Baz10334!100)) {}    ///
421 template Foo10334(T) if (Bar10334!(.foo)) {}            ///
422 template Foo10334(T) if (Bar10334!(const int)) {}       ///
423 template Foo10334(T) if (Bar10334!(shared T)) {}        ///
424 
425 template Test10334(T...) {}     ///
426 mixin Test10334!int a;          ///
427 mixin Test10334!(int,long) b;   ///
428 mixin Test10334!"str" c;        ///
429 
430 // 12266
431 auto clamp12266a(T1, T2, T3)(T1 x, T2 min_val, T3 max_val)
432 {
433     return 0;
434 }
435 pure clamp12266b(T1, T2, T3)(T1 x, T2 min_val, T3 max_val)
436 {
437     return 0;
438 }
439 @disable pure clamp12266c(T1, T2, T3)(T1 x, T2 min_val, T3 max_val)
440 {
441     return 0;
442 }
443 
444 // 13832
445 alias Dg13832 = ref int delegate();