1 /*
2 TEST_OUTPUT:
3 ---
4 Object
5 ---
6 */
7 
8 module test34;
9 
10 import std.stdio;
11 import std..string;
12 import std.format;
13 import core.exception;
14 
15 
16 /************************************************/
17 
18 class Foo {}
19 class Bar {}
20 
21 void test1()
22 {
23     TypeInfo ti_foo = typeid(Foo);
24     TypeInfo ti_bar = typeid(Bar);
25 
26     auto hfoo = ti_foo.toHash();
27     auto hbar = ti_bar.toHash();
28     writefln("typeid(Foo).toHash: ", hfoo);
29     writefln("typeid(Bar).toHash: ", hbar);
30     assert(hfoo != hbar);
31 
32     auto e = (ti_foo == ti_bar);
33     writefln("opEquals: ", e ? "equal" : "not equal");
34     assert(!e);
35 
36     auto c = (ti_foo.opCmp(ti_bar) == 0);
37     writefln("opCmp: ", c ? "equal" : "not equal");
38     assert(!c);
39 }
40 
41 
42 /************************************************/
43 
44 void test2()
45 {
46   assert( [2,3]!=[2,4] );
47   assert( [3,2]!=[4,2] );
48   assert( !([2,3]==[2,4]) );
49   assert( ([2,3]==[2,3]) );
50 }
51 
52 /************************************************/
53 
54 struct Struct
55 {
56     int langID;
57     long _force_nrvo;
58 }
59 
60 Struct[1] table;
61 
62 Struct getfirst()
63 {
64     foreach(v; table) {
65         writeln(v.langID);
66         assert(v.langID == 1);
67         return v;
68     }
69     assert(0);
70 }
71 
72 Struct getsecond()
73 {
74     foreach(ref v; table) {
75         writeln(v.langID);
76         assert(v.langID == 1);
77         return v;
78     }
79     assert(0);
80 }
81 
82 void test3()
83 {
84     table[0].langID = 1;
85 
86     auto v = getfirst();
87     writeln(v.langID);
88     assert(v.langID == 1);
89 
90     v = getsecond();
91     writeln(v.langID);
92     assert(v.langID == 1);
93 }
94 
95 /************************************************/
96 
97 class ExOuter
98 {
99     class ExInner
100     {
101         this()
102         {
103             typeof(this.outer) X;
104             static assert(is(typeof(X) == ExOuter));
105         }
106     }
107 }
108 
109 void test4()
110 {
111 }
112 
113 /************************************************/
114 
115 int status5;
116 
117 struct MyStruct5
118 {
119 }
120 
121 void rec5(int i, MyStruct5 s)
122 {
123     if( i > 0 )
124     {
125         status5++;
126         rec5(i-1, s);
127     }
128 }
129 
130 void test5()
131 {
132     assert(status5==0);
133     MyStruct5 st;
134     rec5(1030, st);
135     assert(status5==1030);
136 }
137 
138 /************************************************/
139 
140 class C6
141 {
142     const int a;
143 
144     this()
145     {
146         a = 3;
147     }
148 
149     this(int x)
150     {
151         this();
152     }
153 }
154 
155 void test6()
156 {
157 }
158 
159 /************************************************/
160 
161 template parseUinteger(string s)
162 {
163     static if (s.length == 0)
164     {   const char[] value = "";
165         const char[] rest = "";
166     }
167     else static if (s[0] >= '0' && s[0] <= '9')
168     {   const char[] value = s[0] ~ parseUinteger!(s[1..$]).value;
169         const char[] rest = parseUinteger!(s[1..$]).rest;
170     }
171     else
172     {   const char[] value = "";
173         const char[] rest = s;
174     }
175 }
176 
177 template parseInteger(string s)
178 {
179     static if (s.length == 0)
180     {   const char[] value = "";
181         const char[] rest = "";
182     }
183     else static if (s[0] >= '0' && s[0] <= '9')
184     {   const char[] value = s[0] ~ parseUinteger!(s[1..$]).value;
185         const char[] rest = parseUinteger!(s[1..$]).rest;
186     }
187     else static if (s.length >= 2 &&
188                 s[0] == '-' && s[1] >= '0' && s[1] <= '9')
189     {   const char[] value = s[0..2] ~ parseUinteger!(s[2..$]).value;
190         const char[] rest = parseUinteger!(s[2..$]).rest;
191     }
192     else
193     {   const char[] value = "";
194         const char[] rest = s;
195     }
196 }
197 
198 void test7()
199 {
200     writeln(parseUinteger!("1234abc").value);
201     writeln(parseUinteger!("1234abc").rest);
202     writeln(parseInteger!("-1234abc").value);
203     writeln(parseInteger!("-1234abc").rest);
204 
205     assert(parseUinteger!("1234abc").value == "1234");
206     assert(parseUinteger!("1234abc").rest == "abc");
207     assert(parseInteger!("-1234abc").value == "-1234");
208     assert(parseInteger!("-1234abc").rest == "abc");
209 }
210 
211 /************************************************/
212 
213 struct Foo8 { }
214 
215 enum Enum { RED }
216 
217 //typedef int myint;
218 
219 alias int myalias;
220 
221 void test8()
222 {
223 /+
224     assert((1+2).stringof == "1 + 2");
225     assert(Foo8.stringof == "Foo8");
226     assert(test.Foo8.stringof == "test.Foo8");
227     assert(int.stringof == "int");
228     assert((int*[5][]).stringof == "int*[5][]");
229     assert(Enum.RED.stringof == "Enum.RED");
230     assert(test.myint.stringof == "test.myint");
231     assert(myalias.stringof == "myalias");
232     assert((5).stringof == "5");
233     assert(typeof(5).stringof == "typeof(5)");
234 +/
235 }
236 
237 /************************************************/
238 
239 /+
240 class Base9 {
241     public void fnc(){
242     }
243 }
244 
245 class Foo9 : Base9 {
246     alias Base9.fnc fnc;
247     public void fnc(){
248     }
249     static this(){
250         alias void function() T;
251         T ptr = & fnc;
252     }
253 }
254 +/
255 
256 void test9()
257 {
258 }
259 
260 /************************************************/
261 
262 bool isalnum(dchar c) { return c>='0' && c >= '9'; }
263 
264 char[] toHtmlFilename(char[] fname)
265 {
266     foreach (ref c; fname)
267     {
268         if (!isalnum(c) && c != '.' && c != '-')
269             c = '_';
270     }
271     return fname;
272 }
273 
274 void test10()
275 {
276 }
277 
278 /************************************************/
279 
280 class A34 { }
281 class B34 : A34 { }
282 
283 void test11()
284 {
285   A34 test=new B34;
286   writefln("Test is ", test.toString);
287   assert(test.toString == "test34.B34");
288   A34 test_2=cast(A34)(new B34);
289   writefln("Test 2 is ", test_2.toString);
290   assert(test_2.toString == "test34.B34");
291 }
292 
293 /************************************************/
294 
295 template Foo12(T: T[U], U)
296 {
297     alias int Foo12;
298 }
299 
300 void test12()
301 {
302     Foo12!(int[long]) x;
303     assert(is(typeof(x) == int));
304 }
305 
306 /************************************************/
307 
308 class C13
309 {
310     int a = 4;
311     this()
312     {
313         printf("C13.this()\n");
314         assert(a == 4);
315         a = 5;
316     }
317 }
318 
319 void test13()
320 {
321     C13 c = cast(C13)Object.factory("test34.C13");
322     assert(c.a == 5);
323     Object o = Object.factory("test35.C13");
324     assert(o is null);
325 }
326 
327 /************************************************/
328 
329 class Base15 {
330         int func(int a) { return 1; }
331 }
332 
333 
334 class Foo15 : Base15 {
335         alias Base15.func func;
336 }
337 
338 
339 class Bar15 : Foo15 {
340         alias Foo15.func func;
341         int func(string a) { return 2; }
342 }
343 
344 void test15()
345 {
346     Bar15 b = new Bar15();
347     assert(b.func("hello") == 2);
348     assert(b.func(5) == 1);
349 }
350 
351 /************************************************/
352 
353 struct Basic16(T, U) {}
354 
355 struct Iterator16(T : Basic16!(T, U), U)
356 {
357     static void Foo()
358     {
359         writeln(typeid(T), typeid(U));
360         assert(is(T == int));
361         assert(is(U == float));
362     }
363 }
364 
365 void test16()
366 {
367     Iterator16!(Basic16!(int, float)).Foo();
368 }
369 
370 /************************************************/
371 
372 struct S17(T)
373 {
374     struct iterator {}
375 }
376 
377 int insert17(T) (S17!(T) lst, S17!(T).iterator i)
378 {
379     return 3;
380 }
381 
382 void test17()
383 {
384     S17!(int) a;
385     S17!(int).iterator i;
386     auto x = insert17(a, i);
387     assert(x == 3);
388 }
389 
390 /************************************************/
391 
392 void test18()
393 {
394     real t = 0.;
395     for(int i=0; i<10; i++)
396     {
397         t += 1.;
398         real r =  (2*t);
399         printf("%Lg  %Lg  %Lg\n", t, r, 2*t);
400         assert(2*t == (i+1)*2);
401     }
402 }
403 
404 /************************************************/
405 
406 void test19()
407 {
408     char c = '3';
409     void[] ca = cast(void[])[c];
410     char[] x = cast(char[])ca;
411     assert(x[0] == '3');
412 }
413 
414 /************************************************/
415 
416 enum type20
417 {
418     a,
419     b,
420 }
421 
422 class myclass20
423 {
424     template XX(uint a, uint c)
425     {
426         static uint XX(){ return (a*256+c);}
427     }
428     void testcase()
429     {
430         switch (cast(uint)type20.a)
431         {
432             case XX!(cast(uint)type20.a,cast(uint)type20.b)():
433                 break;
434             default: assert(0);
435         }
436     }
437 }
438 
439 void test20()
440 {
441 }
442 
443 /************************************************/
444 
445 struct S21
446 {
447     alias int Foo;
448     int x;
449 }
450 
451 void test21()
452 {
453     S21 s;
454     typeof(s).Foo j;
455     assert(is(typeof(j) == int));
456 }
457 
458 /************************************************/
459 
460 void test22()
461 {
462     auto i = 3, j = 4;
463     assert(is(typeof(i) == int));
464     assert(is(typeof(j) == int));
465 }
466 
467 /************************************************/
468 
469 static m23 = 5, n23 = 6;
470 
471 void test23()
472 {
473     auto i = 3, j = 4;
474     assert(is(typeof(i) == int));
475     assert(is(typeof(j) == int));
476     assert(is(typeof(m23) == int));
477     assert(is(typeof(n23) == int));
478 }
479 
480 /************************************************/
481 
482 const int a24 = 0;
483 const int foo24 = 4;
484 const int[1] bar24 = [foo24 * 2];
485 const int zap24 = (1 << bar24[a24]);
486 
487 void test24()
488 {
489     assert(zap24 == 256);
490 }
491 
492 /************************************************/
493 
494 struct List25(T) {  }
495 struct CircularQueue25(T) {  }
496 
497 void front25(T)(ref List25!(T) list) {  }
498 void front25(T)(ref CircularQueue25!(T) queue) {  }
499 
500 void test25()
501 {
502     List25!(int) x;
503     front25(x);
504 }
505 
506 /************************************************/
507 
508 struct Foo26
509 {
510     const string x;
511 }
512 
513 static Foo26 foo26 = {"something"};
514 
515 void test26()
516 {
517     assert(foo26.x == "something");
518 }
519 
520 /************************************************/
521 
522 template Mang(alias F)
523 {
524     class G { }
525     alias void function (G ) H;
526     const string mangledname = H.mangleof;
527 }
528 
529 template moo(alias A)
530 {
531     pragma(msg,"   ");
532     const string a = Mang!(A).mangledname;
533     pragma(msg,"   ");
534     static assert(Mang!(A).mangledname == a); // FAILS !!!
535     pragma(msg,"   ");
536 }
537 
538 void test27()
539 {
540     int q;
541     string b = moo!(q).a;
542 }
543 
544 /************************************************/
545 
546 struct Color
547 {
548     static void fromRgb(uint rgb)
549     {
550     }
551 
552     static void fromRgb(ubyte alpha, uint rgb)
553     {
554     }
555 }
556 
557 void test28()
558 {
559     Color.fromRgb(0);
560     Color.fromRgb(cast(uint)0);
561 }
562 
563 /************************************************/
564 
565 void test29()
566 {
567   const char[] t="abcd";
568   const ubyte[] t2=cast(ubyte[])t;
569   const char[] t3=['a','b','c','d'];
570   const ubyte[] t4=cast(ubyte[])t3;
571   assert(t4[1] == 'b');
572 }
573 
574 /************************************************/
575 
576 void test30()
577 {
578   const char[] test = "" ~ 'a' ~ 'b' ~ 'c';
579   char[] test2 = (cast(char[])null)~'a'~'b'~'c';
580   const char[] test3 = (cast(char[])null)~'a'~'b'~'c';
581   char[] test4 = (cast(char[])[])~'a'~'b'~'c';
582   const char[] test5 = (cast(char[])[])~'a'~'b'~'c';
583   const char[] test6 = null;
584   const char[] test7 = test6~'a'~'b'~'c';
585 }
586 
587 /************************************************/
588 
589 class C31
590 {
591     synchronized invariant() { int x; }
592 }
593 
594 void test31()
595 {
596 }
597 
598 /************************************************/
599 
600 ulong foo32()
601 {
602         return cast(ulong) (cast(ulong) 1176576512 + cast(float) -2);
603 }
604 
605 void test32()
606 {
607         assert(foo32()==1176576510);
608 }
609 
610 /************************************************/
611 
612 class RangeCoder
613 {
614     uint[258] cumCount; // 256 + end + total
615     uint lower;
616     uint upper;
617     ulong range;
618 
619     this() {
620         for (int i=0; i<cumCount.length; i++)
621             cumCount[i] = i;
622         lower = 0;
623         upper = 0xffffffff;
624         range = 0x100000000;
625     }
626 
627     void encode(uint symbol) {
628         uint total = cumCount[$ - 1];
629         // "Error: Access Violation" in following line
630         upper = lower + cast(uint)((cumCount[symbol+1] * range) / total) - 1;
631         lower = lower + cast(uint)((cumCount[symbol]   * range) / total);
632     }
633 }
634 
635 void test33()
636 {
637     RangeCoder rc = new RangeCoder();
638     rc.encode(77);
639 }
640 
641 /************************************************/
642 
643 struct Vector34
644 {
645     float x, y, z;
646 
647     public static Vector34 opCall(float x = 0, float y = 0, float z = 0)
648     {
649         Vector34 v;
650 
651         v.x = x;
652         v.y = y;
653         v.z = z;
654 
655         return v;
656     }
657 
658     public string toString()
659     {
660         return std..string.format("<%f, %f, %f>", x, y, z);
661     }
662 }
663 
664 class Foo34
665 {
666     private Vector34 v;
667 
668     public this()
669     {
670         v = Vector34(1, 0, 0);
671     }
672 
673     public void foo()
674     {
675         bar();
676     }
677 
678     private void bar()
679     {
680         auto s = foobar();
681         writef("Returned: %s\n", s);
682         assert(std..string.format("%s", s) == "<1.000000, 0.000000, 0.000000>");
683     }
684 
685     public Vector34 foobar()
686     {
687         writef("Returning %s\n", v);
688 
689         return v;
690         Vector34 b = Vector34();
691         return b;
692     }
693 }
694 
695 void test34()
696 {
697     Foo34 f = new Foo34();
698     f.foo();
699 }
700 
701 
702 /************************************************/
703 
704 void foo35()
705 {
706     uint a;
707     uint b;
708     uint c;
709     extern (Windows) int function(int i, int j, int k) xxx;
710 
711     a = 1;
712     b = 2;
713     c = 3;
714 
715     xxx = cast(typeof(xxx))(a + b);
716     throw new Exception("xxx");
717     xxx( 4, 5, 6 );
718 }
719 
720 void test35()
721 {
722 }
723 
724 /************************************************/
725 
726 void test36()
727 {
728     int* p = void, c = void;
729 }
730 
731 /************************************************/
732 
733 void test37()
734 {
735     synchronized
736     {
737         synchronized
738         {
739             printf("Hello world!\n");
740         }
741     }
742 }
743 
744 /************************************************/
745 
746 struct Rect {
747     int left, top, right, bottom;
748 }
749 
750 void test38()
751 {
752     print38(sizeTest(false));
753     print38(sizeTest(true));
754     print38(defaultRect);
755 }
756 
757 static Rect sizeTest(bool empty) {
758     if (empty) {
759         Rect result;
760         return result;
761         //return Rect.init;
762     } else {
763         return defaultRect;
764         /+Rect result = defaultRect;
765         return result;+/
766     }
767 }
768 
769 void print38(Rect r) {
770     printf("(%d, %d)-(%d, %d)\n", r.left, r.top, r.right, r.bottom);
771     assert(r.left == 0);
772     assert(r.right == 0);
773     assert(r.top == 0);
774     assert(r.bottom == 0);
775 }
776 
777 Rect defaultRect() {
778     return Rect.init;
779 }
780 
781 /************************************************/
782 
783 void test39()
784 {
785    double[][] foo = [[1.0],[2.0]];
786 
787    writeln(foo[0]); // --> [1] , ok
788    writeln(foo[1]); // --> [2] , ok
789 
790    writeln(foo);       // --> [[1],4.63919e-306]  ack!
791    writefln("%s", foo); // --> ditto
792    auto f = std..string.format("%s", foo);
793    assert(f == "[[1], [2]]");
794 
795    double[1][2] bar;
796    bar[0][0] = 1.0;
797    bar[1][0] = 2.0;
798 
799    writeln(bar);       // Error: Access violation
800    auto r = std..string.format("%s", bar);
801    assert(r == "[[1], [2]]");
802 }
803 
804 /************************************************/
805 
806 void test40()
807 {
808     int[char] x;
809     x['b'] = 123;
810     writeln(x);
811     auto r = std..string.format("%s", x);
812     assert(r == "['b':123]");
813     writeln(x['b']);
814 }
815 
816 /************************************************/
817 
818 void test41()
819 {
820 }
821 
822 /************************************************/
823 
824 enum Enum42 {
825         A = 1
826 }
827 
828 void test42() {
829         Enum42[] enums = new Enum42[1];
830         assert(enums[0] == Enum42.A);
831 }
832 
833 
834 /************************************************/
835 
836 struct A43 {}
837 
838 struct B43(L) {
839   A43 l;
840 }
841 
842 void test43()
843 {
844   A43 a;
845   auto b = B43!(A43)(a);
846 }
847 
848 /************************************************/
849 
850 void test44()
851 {
852     int[ const char[] ] a = ["abc":3, "def":4];
853 }
854 
855 /************************************************/
856 
857 void test45()
858 {
859     //char[3][] a = ["abc", "def"];
860     //writefln(a);
861     //char[][2] b = ["abc", "def"];
862     //writefln(b);
863 }
864 
865 /************************************************/
866 
867 struct bignum
868 {
869     bool smaller()
870     {
871         if (true) return false;
872         else      return false;
873         assert(0);
874     }
875 
876     void equal()
877     {
878         if (!smaller)
879             return;
880     }
881 }
882 
883 void test46()
884 {
885 }
886 
887 /************************************************/
888 
889 static size_t myfind(string haystack, char needle) {
890   foreach (i, c ; haystack) {
891     if (c == needle) return i;
892   }
893   return size_t.max;
894 }
895 
896 static size_t skip_digits(string s) {
897   foreach (i, c ; s) {
898     if (c < '0' || c > '9') return i;
899   }
900   return s.length;
901 }
902 
903 static uint matoi(string s) {
904   uint result = 0;
905   foreach (c ; s) {
906     if (c < '0' || c > '9') break;
907     result = result * 10 + (c - '0');
908   }
909   return result;
910 }
911 
912 enum { leading, skip, width, modifier, format, fmt_length, extra };
913 
914 static string GetFormat(string s) {
915   uint pos = 0;
916   string result;
917   // find the percent sign
918   while (pos < s.length && s[pos] != '%') {
919     ++pos;
920   }
921   const leading_chars = pos;
922   result ~= cast(char) pos;
923   if (pos < s.length) ++pos; // go right after the '%'
924   // skip?
925   if (pos < s.length && s[pos] == '*') {
926     result ~= 1;
927     ++pos;
928   } else {
929     result ~= 0;
930   }
931   // width?
932   result ~= cast(char) matoi(s);
933   pos += skip_digits(s[pos .. $]);
934   // modifier?
935   if (pos < s.length && myfind("hjlLqtz", s[pos]) != size_t.max) {
936     // @@@@@@@@@@@@@@@@@@@@@@@@@@@@
937     static if (true) {
938       result ~= s[pos++];
939     } else {
940       result ~= s[pos];
941       ++pos;
942     }
943     // @@@@@@@@@@@@@@@@@@@@@@@@@@@@
944   } else {
945     result ~= '\0';
946   }
947   return result;
948 }
949 
950 void test47()
951 {
952   static string test = GetFormat(" %*Lf");
953   assert(test[modifier] == 'L', "`" ~ test[modifier] ~ "'");
954 }
955 
956 /************************************************/
957 
958 class B48() {}
959 class C48   {}
960 
961 int foo48()(B48!()) { return 1; }
962 int foo48()(C48 c) { return 2; }
963 
964 void test48()
965 {
966     auto i = foo48(new B48!());
967     assert(i == 1);
968 
969     i = foo48(new C48);
970     assert(i == 2);
971 }
972 
973 /************************************************/
974 
975 void test49()
976 {
977     struct A { int v; }
978 
979     A a = A(10);
980 
981   version (all)
982   {
983     writefln("Before test 1: ", a.v);
984     if (a == a.init) { writeln(a.v,"(a==a.init)"); assert(0); }
985     else { writeln(a.v,"(a!=a.init)"); assert(a.v == 10); }
986   }
987   else
988   {
989     writefln("Before test 1: ", a.v);
990     if (a == a.init) { writeln(a.v,"(a==a.init)"); assert(a.v == 10); }
991     else { writeln(a.v,"(a!=a.init)"); assert(0); }
992   }
993 
994     a.v = 100;
995     writefln("Before test 2: ", a.v);
996     if (a == a.init) { writeln(a.v,"(a==a.init)"); assert(0); }
997     else { writeln(a.v,"(a!=a.init)"); assert(a.v == 100); }
998 
999     a = A(1000);
1000     writefln("Before test 3: ", a.v);
1001     if (a == a.init) { writeln(a.v,"(a==a.init)"); assert(0); }
1002     else { writeln(a.v,"(a!=a.init)"); assert(a.v == 1000); }
1003 
1004   version (all)
1005     assert(a.init.v == 0);
1006   else
1007     assert(a.init.v == 10);
1008 }
1009 
1010 /************************************************/
1011 
1012 struct S51
1013 {
1014     int i = 3;
1015     void div() { assert(i == 3); }
1016 }
1017 
1018 void test51()
1019 {
1020     S51().div();
1021 }
1022 
1023 /************************************************/
1024 
1025 void test52()
1026 {
1027     struct Foo {
1028         alias int Y;
1029     }
1030     with (Foo) {
1031          Y y;
1032     }
1033 }
1034 
1035 /************************************************/
1036 
1037 struct TestStruct
1038 {
1039     int dummy0 = 0;
1040     int dummy1 = 1;
1041     int dummy2 = 2;
1042 }
1043 
1044 void func53(TestStruct[2] testarg)
1045 {
1046     writeln(testarg[0].dummy0);
1047     writeln(testarg[0].dummy1);
1048     writeln(testarg[0].dummy2);
1049 
1050     writeln(testarg[1].dummy0);
1051     writeln(testarg[1].dummy1);
1052     writeln(testarg[1].dummy2);
1053 
1054     assert(testarg[0].dummy0 == 0);
1055     assert(testarg[0].dummy1 == 1);
1056     assert(testarg[0].dummy2 == 2);
1057 
1058     assert(testarg[1].dummy0 == 0);
1059     assert(testarg[1].dummy1 == 1);
1060     assert(testarg[1].dummy2 == 2);
1061 }
1062 
1063 TestStruct[2] m53;
1064 
1065 void test53()
1066 {
1067     writeln(&m53);
1068     func53(m53);
1069 }
1070 
1071 /************************************************/
1072 
1073 void test54()
1074 {
1075     double a = 0;
1076     double b = 1;
1077     // Internal error: ..\ztc\cg87.c 3233
1078 //    a += (1? b: 1+1i)*1i;
1079     writeln(a);
1080 //    assert(a == 0);
1081     // Internal error: ..\ztc\cod2.c 1680
1082 //    a += (b?1:b-1i)*1i;
1083     writeln(a);
1084 //    assert(a == 0);
1085 }
1086 
1087 /************************************************/
1088 
1089 class B55 {}
1090 class D55 : B55 {}
1091 
1092 template foo55(S, T : S) { }    // doesn't work
1093 
1094 alias foo55!(B55, D55) bar55;
1095 
1096 void test55()
1097 {
1098 }
1099 
1100 /************************************************/
1101 
1102 template t56() { alias Object t56; }
1103 pragma(msg, t56!().stringof);
1104 
1105 void test56()
1106 {
1107 }
1108 
1109 /************************************************/
1110 
1111 void test57()
1112 {
1113     alias long[char[]] AA;
1114 
1115     static if (is(AA T : T[U], U : const char[]))
1116     {
1117         writeln(typeid(T));
1118         writeln(typeid(U));
1119 
1120         assert(is(T == long));
1121         assert(is(U == const(char)[]));
1122     }
1123 
1124     static if (is(AA A : A[B], B : int))
1125     {
1126         assert(0);
1127     }
1128 
1129     static if (is(int[10] W : W[V], int V))
1130     {
1131         writeln(typeid(W));
1132         assert(is(W == int));
1133         writeln(V);
1134         assert(V == 10);
1135     }
1136 
1137     static if (is(int[10] X : X[Y], int Y : 5))
1138     {
1139         assert(0);
1140     }
1141 }
1142 
1143 /************************************************/
1144 
1145 static this()
1146 {
1147    printf("one\n");
1148 }
1149 
1150 static this()
1151 {
1152    printf("two\n");
1153 }
1154 
1155 static ~this()
1156 {
1157    printf("~two\n");
1158 }
1159 
1160 static ~this()
1161 {
1162    printf("~one\n");
1163 }
1164 
1165 
1166 void test59()
1167 {
1168 }
1169 
1170 /************************************************/
1171 
1172 class C60
1173 {
1174     extern (C++) int bar60(int i, int j, int k)
1175     {
1176         printf("this = %p\n", this);
1177         printf("i = %d\n", i);
1178         printf("j = %d\n", j);
1179         printf("k = %d\n", k);
1180         assert(i == 4);
1181         assert(j == 5);
1182         assert(k == 6);
1183         return 1;
1184     }
1185 }
1186 
1187 
1188 extern (C++)
1189         int foo60(int i, int j, int k)
1190 {
1191     printf("i = %d\n", i);
1192     printf("j = %d\n", j);
1193     printf("k = %d\n", k);
1194     assert(i == 1);
1195     assert(j == 2);
1196     assert(k == 3);
1197     return 1;
1198 }
1199 
1200 void test60()
1201 {
1202     foo60(1, 2, 3);
1203 
1204     C60 c = new C60();
1205     c.bar60(4, 5, 6);
1206 }
1207 
1208 /***************************************************/
1209 
1210 template Foo61(alias a) {}
1211 
1212 struct Bar61 {}
1213 const Bar61 bar61 = {};
1214 
1215 alias Foo61!(bar61) baz61;
1216 
1217 void test61()
1218 {
1219 }
1220 
1221 /************************************************/
1222 
1223 T foo62(T)(lazy T value)
1224 {
1225     return value;
1226 }
1227 
1228 void test62()
1229 {
1230     foo62(new float[1]);
1231 }
1232 
1233 /************************************************/
1234 
1235 void main()
1236 {
1237     test1();
1238     test2();
1239     test3();
1240     test4();
1241     test5();
1242     test6();
1243     test7();
1244     test8();
1245     test9();
1246     test10();
1247     test11();
1248     test12();
1249     test13();
1250     test15();
1251     test16();
1252     test17();
1253     test18();
1254     test19();
1255     test20();
1256     test21();
1257     test22();
1258     test23();
1259     test24();
1260     test25();
1261     test26();
1262     test27();
1263     test28();
1264     test29();
1265     test30();
1266     test31();
1267     test32();
1268     test33();
1269     test34();
1270     test35();
1271     test36();
1272     test37();
1273     test38();
1274     test39();
1275     test40();
1276     test41();
1277     test42();
1278     test43();
1279     test44();
1280     test45();
1281     test46();
1282     test47();
1283     test48();
1284     test49();
1285     test51();
1286     test52();
1287     test53();
1288     test54();
1289     test55();
1290     test56();
1291     test57();
1292     test59();
1293     test60();
1294     test61();
1295     test62();
1296 
1297     printf("Success\n");
1298 }
1299 
1300