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