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