Changeset 653
- Timestamp:
- 09/01/10 01:51:00 (1 year ago)
- Files:
-
- trunk/test/compilable/imports/test66a.d (added)
- trunk/test/compilable/imports/test67a.d (added)
- trunk/test/compilable/imports/test68a.d (added)
- trunk/test/compilable/test66.d (added)
- trunk/test/compilable/test67.d (added)
- trunk/test/compilable/test68.d (added)
- trunk/test/runnable/arrayop.d (modified) (2 diffs)
- trunk/test/runnable/interface.d (modified) (1 diff)
- trunk/test/runnable/nested.d (modified) (2 diffs)
- trunk/test/runnable/opover.d (modified) (2 diffs)
- trunk/test/runnable/sdtor.d (modified) (2 diffs)
- trunk/test/runnable/template4.d (modified) (1 diff)
- trunk/test/runnable/test4.d (modified) (2 diffs)
- trunk/test/runnable/test42.d (modified) (3 diffs)
- trunk/test/runnable/test60.d (modified) (1 diff)
- trunk/test/runnable/xtest46.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/runnable/arrayop.d
r544 r653 417 417 /************************************************************************/ 418 418 419 void test4() 420 { 421 int[] a, b; 422 if (a && b) {} 423 } 424 425 /************************************************************************/ 426 419 427 int main() 420 428 { … … 422 430 test2(); 423 431 test3(); 432 test4(); 424 433 425 434 printf("Success\n"); trunk/test/runnable/interface.d
r649 r653 56 56 /*******************************************/ 57 57 58 interface I3 { 59 void h(); 60 } 61 interface K3 { 62 void f(); 63 } 64 65 interface J3 : I3, K3 {} 66 67 class A3 : J3 { 68 void f(){ } 69 void h(){ } 70 } 71 72 void test3() 73 { 74 auto a = new A3(); 75 J3 b = a; 76 K3 c = a; 77 assert(&b.f == &c.f); // Bugzilla 3706 78 } 79 80 /*******************************************/ 81 58 82 int main() 59 83 { 60 84 test1(); 61 85 test2(); 86 test3(); 62 87 63 88 printf("Success\n"); trunk/test/runnable/nested.d
r575 r653 1465 1465 auto c = new A; 1466 1466 assert(c.bar(4) == 44); 1467 } 1468 /*******************************************/ 1469 1470 void test55() 1471 { 1472 int localvar = 7; 1473 1474 int inner(int delegate(ref int) dg) { 1475 int k = localvar; 1476 return 0; 1477 } 1478 1479 int a = localvar * localvar; // This modifies the EAX register 1480 1481 foreach (entry; &inner) 1482 { 1483 } 1467 1484 } 1468 1485 … … 1525 1542 test53(); 1526 1543 test54(); 1544 test55(); 1527 1545 1528 1546 printf("Success\n"); trunk/test/runnable/opover.d
r574 r653 882 882 /**************************************/ 883 883 884 // 3983 885 886 struct Fug 887 { 888 bool opEquals(ref const Fug y) const { 889 return false; 890 } 891 } 892 893 struct Fig 894 { 895 Fug f; 896 bool opEquals(Tdummy=void)(ref const Fig y) const { 897 return false; 898 } 899 900 bool opEquals(T: int)(T y) const { 901 return false; 902 } 903 } 904 905 void test15() 906 { 907 Fig fx, fy; 908 if (fx==2) {} 909 } 910 911 /**************************************/ 912 884 913 int main() 885 914 { … … 898 927 test13(); 899 928 test14(); 929 test15(); 900 930 901 931 printf("Success\n"); trunk/test/runnable/sdtor.d
r575 r653 1270 1270 final switch(0) A51 a; 1271 1271 A51 a; with(a) A51 b; 1272 } 1273 1274 /**********************************/ 1275 1276 string s52; 1277 1278 struct A52 1279 { 1280 int m; 1281 this(this) 1282 { 1283 printf("this(this) %p\n", &this); 1284 s52 ~= 'a'; 1285 } 1286 ~this() 1287 { 1288 printf("~this() %p\n", &this); 1289 s52 ~= 'b'; 1290 } 1291 A52 copy() 1292 { 1293 s52 ~= 'c'; 1294 A52 another = this; 1295 return another; 1296 } 1297 } 1298 1299 void test52() 1300 { 1301 { 1302 A52 a; 1303 A52 b = a.copy(); 1304 printf("a: %p, b: %p\n", &a, &b); 1305 } 1306 printf("s = '%.*s'\n", s52); 1307 assert(s52 == "caabbb"); 1308 } 1309 1310 /**********************************/ 1311 // 4339 1312 1313 struct A53 { 1314 invariant() { } 1315 ~this() { } 1316 void opAssign(A53 a) {} 1317 int blah(A53 a) { return 0; } 1272 1318 } 1273 1319 … … 1327 1373 test50(); 1328 1374 test51(); 1375 test52(); 1329 1376 1330 1377 printf("Success\n"); trunk/test/runnable/template4.d
r574 r653 1019 1019 } 1020 1020 1021 /*********************************************************/ 1022 1023 void bug4652(U, T...)(long y, T x, U num) {} 1024 void bug4652default(T) (T value, int x=2) {} 1025 void bug4652default(T) (T value, int y) {} 1026 void bug4676(T...)(T args, string str) {} 1027 void bug4676(T...)(T args) {} 1028 1029 void instantiate4652() 1030 { 1031 bug4652(2, 'c', 27, 'e', 'f',1); // rejects-valid 1032 bug4652(2, 1); // infinite loop on valid code 1033 bug4652default(true); 1034 bug4676(1, 2, 3); 1035 } 1021 1036 1022 1037 /*********************************************************/ trunk/test/runnable/test4.d
r551 r653 1374 1374 printf("catch %.*s\n", e.msg); 1375 1375 assert(e.msg == "second"); 1376 //assert(e.msg == "first"); 1377 //assert(e.next.msg == "second"); 1376 1378 assert(status==3); 1377 1379 } … … 1392 1394 { 1393 1395 printf("inner catch %p\n", e); 1396 printf("e.msg == %.*s\n", e.msg); 1394 1397 assert(e.msg == "second"); 1398 //assert(e.msg == "first"); 1399 //assert(e.next.msg == "second"); 1395 1400 } 1396 1401 } trunk/test/runnable/test42.d
r556 r653 699 699 void test45() 700 700 { 701 version (Windows)701 version (Windows) // this test fails in -release because asserts will be removed 702 702 { 703 703 assert(foo45(0)==2); … … 3455 3455 3456 3456 static assert(A196.sizeof == B196.sizeof); 3457 3458 /***************************************************/ 3459 3460 template Compileable(int z) { bool OK;} 3461 3462 struct Bug3569 { 3463 int bar() { return 7; } 3464 } 3465 3466 struct Bug3569b { 3467 Bug3569 foo; 3468 void crash() { 3469 static assert(!is(typeof(Compileable!(foo.bar())))); 3470 static assert(!is(typeof(Compileable!((foo = Bug3569.init).bar())))); 3471 } 3472 } 3473 3474 void test197() 3475 { 3476 } 3477 3478 /***************************************************/ 3479 3480 void test198() // Bugzilla 4506 3481 { 3482 int c = 1; 3483 for (int k = 0; k < 2; k++) { 3484 assert((k == 0 && c == 1) || (k == 1 && c == -1)); 3485 c *= -1; 3486 } 3487 } 3488 3489 /***************************************************/ 3490 3491 // Bugzilla 4514 3492 void g199(void delegate(void*, void*) d) { } 3493 3494 struct X199 { 3495 void f(void*, void*) {} 3496 void n() 3497 { 3498 g199(&f); 3499 } 3500 } 3501 3502 /***************************************************/ 3503 // Bugzilla 4443 3504 3505 struct Struct4443 3506 { 3507 int x; 3508 char[5] unused; 3509 } 3510 3511 void foo4443(Struct4443 *dest, Struct4443[] arr) 3512 { 3513 int junk = arr[$-1].x; 3514 if (dest || arr[$-1].x) { 3515 *dest = arr[$-1]; 3516 } 3517 } 3518 3519 void test200() 3520 { 3521 Struct4443[1] a; 3522 Struct4443 info; 3523 foo4443(&info, a); 3524 } 3525 3526 /***************************************************/ 3527 3528 // Bugzilla 2931 3529 3530 struct Bug2931 { 3531 int val[3][4]; 3532 } 3533 3534 struct Outer2931 { 3535 Bug2931 p = Bug2931(67); // Applies to struct static initializers too 3536 int zoom = 2; 3537 int move = 3; 3538 int scale = 4; 3539 } 3540 3541 int bug2931() 3542 { 3543 Outer2931 v; 3544 assert(v.move==3); 3545 assert(v.scale == 4); 3546 return v.zoom; 3547 } 3548 3549 int bug2931_2() 3550 { 3551 Outer2931 v; 3552 assert(v.move==3); 3553 for (int i = 0; i < 4; i++) 3554 { for (int j = 0; j < 3; j++) 3555 { 3556 printf("[%d][%d] = %d\n", j, i, v.p.val[j][i]); 3557 if (i == 0 && j == 0) 3558 assert(v.p.val[j][i] == 67); 3559 else 3560 assert(v.p.val[j][i] == 0); 3561 } 3562 } 3563 printf("v.zoom = %d\n", v.zoom); 3564 assert(v.scale == 4); 3565 return v.zoom; 3566 } 3567 3568 static assert(bug2931()==2); 3569 3570 void test201() { 3571 assert(bug2931()==2); 3572 assert(bug2931_2()==2); 3573 } 3574 3575 3576 /***************************************************/ 3577 3578 import std.stdarg; 3579 3580 void foo202(int x, ...) { 3581 printf("%d arguments\n", _arguments.length); 3582 for (int i = 0; i < _arguments.length; i++) { 3583 int j = va_arg!(int)(_argptr); 3584 printf("\t%d\n", j); 3585 assert(j == i + 2); 3586 } 3587 } 3588 3589 void fooRef202(ref int x, ...) { 3590 printf("%d arguments\n", _arguments.length); 3591 for (int i = 0; i < _arguments.length; i++) { 3592 int j = va_arg!(int)(_argptr); 3593 printf("\t%d\n", j); 3594 assert(j == i + 2); 3595 } 3596 } 3597 3598 void test202() 3599 { 3600 foo202(1, 2, 3, 4, 5); 3601 3602 printf("---\n"); 3603 3604 int x = 1; 3605 fooRef202(x, 2, 3, 4, 5); 3606 } 3607 3608 /***************************************************/ 3609 // Bugzilla 1418 3610 3611 class A203 3612 { 3613 char name = 'A'; 3614 class B203 3615 { 3616 char name = 'B'; 3617 } 3618 } 3619 3620 void test203() 3621 { 3622 class C203 3623 { 3624 char name = 'C'; 3625 } 3626 3627 auto a = new A203; 3628 auto b = a.new B203; 3629 auto c = new C203; 3630 3631 writeln(a.tupleof); // prints: A 3632 writeln(b.tupleof); // prints: B main.A 3633 writeln(c.tupleof); // prints: C 0000 3634 assert(a.tupleof.length == 1 && a.tupleof[0] == 'A'); 3635 assert(b.tupleof.length == 1 && b.tupleof[0] == 'B'); 3636 assert(c.tupleof.length == 1 && c.tupleof[0] == 'C'); 3637 } 3638 3639 /***************************************************/ 3640 // Bugzilla 4516 3641 3642 struct A204 { B204 b; } 3643 enum B204 { Z } 3644 3645 /***************************************************/ 3646 // Bugzilla 4503 3647 3648 class Collection205(T) { } 3649 ICollection c; 3650 3651 alias Collection205!int ICollection; 3652 3653 /***************************************************/ 3654 3655 enum TaskStatus:int { Building=-1, } 3656 3657 TaskStatus test206(char[] s){ 3658 char[] t="TaskStatus".dup; 3659 if (s.length>t.length && s[0..t.length]==t){ 3660 long res=0; 3661 if (s[t.length]=='-') res= -res; // <= OPnegass 3662 return cast(TaskStatus)cast(int)res; 3663 } 3664 assert(0); 3665 } 3666 3667 /***************************************************/ 3668 3669 struct UN { double dd; long ll; } 3670 bool cmp( UN * pU ) { return pU.dd >= pU.ll ? true : false; } 3671 3672 struct UN2 { real dd; long ll; } 3673 bool cmp2( UN2 * pU ) { return pU.dd >= pU.ll ? true : false; } 3674 3675 struct UN3 { double dd; int ll; } 3676 bool cmp3( UN3 * pU ) { return pU.dd >= pU.ll ? true : false; } 3677 3678 void test207() 3679 { 3680 static UN u = { 10.50, 10 }; 3681 auto i = cmp(&u); 3682 printf( "%d\n", cmp( &u ) ); 3683 assert(i); 3684 3685 static UN2 u2 = { 10.50, 10 }; 3686 i = cmp2(&u2); 3687 assert(i); 3688 3689 static UN3 u3 = { 10.50, 10 }; 3690 i = cmp3(&u3); 3691 assert(i); 3692 3693 static UN3 u3_1 = { 9.50, 10 }; 3694 i = cmp3(&u3_1); 3695 assert(!i); 3696 } 3697 3698 /***************************************************/ 3699 3700 template fail4302() { 3701 static assert(0); 3702 } 3703 template bug4302() { 3704 alias fail4302!() bad; 3705 } 3706 static if (is(bug4302!())) {} 3707 3708 /***************************************************/ 3709 3710 template tough4302() 3711 { 3712 template bar() 3713 { 3714 template far() 3715 { 3716 static assert(0); 3717 } 3718 alias far!() par; 3719 } 3720 static if (is(bar!())) {} 3721 } 3722 3723 alias tough4302!() tougher; 3724 3725 /***************************************************/ 3726 3727 // Bugzilla 190 3728 3729 //typedef int avocado; 3730 //void test208(avocado x208 = .x208) { } 3731 //avocado x208; 3732 3733 /***************************************************/ 3734 // Bugzilla 3493 3735 3736 const bar209 = foo209; 3737 const int * foo209 = null; 3457 3738 3458 3739 /***************************************************/ … … 3647 3928 test194(); 3648 3929 3930 test198(); 3931 3932 test200(); 3933 test201(); 3934 test202(); 3935 test203(); 3936 3937 // test208(); 3938 3649 3939 writefln("Success"); 3650 3940 return 0; trunk/test/runnable/test60.d
r575 r653 1 // PERMUTE_ARGS:2 3 1 import std.stdio; 4 2 import std.algorithm; 5 3 6 void main()4 void test1() 7 5 { 8 6 int[] a = [1,2,3,4,5]; 9 7 writeln( remove!("a < 3")(a) ); 10 8 } 9 10 void test2() 11 { 12 auto arr = [1,2,3,4,5]; 13 auto m = map!"a + 1"(filter!"a < 4"(arr)); 14 } 15 16 void main() 17 { 18 test1(); 19 test2(); 20 21 writeln("Success"); 22 } trunk/test/runnable/xtest46.d
r571 r653 1970 1970 static assert(B110.s == "Boo!(double)"); 1971 1971 static assert(A110.s == "Boo!(int)"); 1972 1973 /***************************************************/ 1974 1975 // 3716 1976 void test111() 1977 { 1978 auto k1 = true ? [1,2] : []; // OK 1979 auto k2 = true ? [[1,2]] : [[]]; 1980 auto k3 = true ? [] : [[1,2]]; 1981 auto k4 = true ? [[[]]] : [[[1,2]]]; 1982 auto k5 = true ? [[[1,2]]] : [[[]]]; 1983 auto k6 = true ? [] : [[[]]]; 1984 static assert(!is(typeof(true ? [[[]]] : [[1,2]]))); // Must fail 1985 } 1986 1987 /***************************************************/ 1988 // 4303 1989 1990 template foo112() if (__traits(compiles,undefined)) 1991 { 1992 enum foo112 = false; 1993 } 1994 1995 template foo112() if (true) 1996 { 1997 enum foo112 = true; 1998 } 1999 2000 pragma(msg,__traits(compiles,foo112!())); 2001 static assert(__traits(compiles,foo112!())); 2002 2003 const bool bar112 = foo112!(); 2004 2005 2006 /***************************************************/ 2007 2008 struct File113 2009 { 2010 this(int name) { } 2011 2012 ~this() { } 2013 2014 void opAssign(File113 rhs) { } 2015 2016 struct ByLine 2017 { 2018 File113 file; 2019 2020 this(int) { } 2021 2022 } 2023 2024 ByLine byLine() 2025 { 2026 return ByLine(1); 2027 } 2028 } 2029 2030 auto filter113(File113.ByLine rs) 2031 { 2032 struct Filter 2033 { 2034 this(File113.ByLine r) { } 2035 } 2036 2037 return Filter(rs); 2038 } 2039 2040 void test113() 2041 { 2042 auto f = File113(1); 2043 auto rx = f.byLine(); 2044 auto file = filter113(rx); 2045 } 2046 2047 /***************************************************/ 2048 2049 template foo114(fun...) 2050 { 2051 auto foo114(int[] args) 2052 { 2053 return 1; 2054 } 2055 } 2056 2057 pragma(msg, typeof(foo114!"a + b"([1,2,3]))); 2058 2059 /***************************************************/ 2060 // Bugzilla 3935 2061 2062 struct Foo115 { 2063 void opBinary(string op)(Foo other) { 2064 pragma(msg, "op: " ~ op); 2065 assert(0); 2066 } 2067 } 2068 2069 void test115() 2070 { 2071 Foo115 f; 2072 f = f; 2073 } 2074 2075 /***************************************************/ 2076 // Bugzilla 2477 2077 2078 void foo116(T,)(T t) { T x; } 2079 2080 void test116() 2081 { 2082 int[] data = [1,2,3,]; // OK 2083 2084 data = [ 1,2,3, ]; // fails 2085 auto i = data[1,]; 2086 foo116!(int)(3); 2087 foo116!(int,)(3); 2088 foo116!(int,)(3,); 2089 } 2090 2091 /***************************************************/ 2092 // Bugzilla 4291 2093 2094 void test117() pure 2095 { 2096 mixin declareVariable; 2097 var = 42; 2098 mixin declareFunction; 2099 readVar(); 2100 } 2101 template declareVariable() { int var; } 2102 template declareFunction() 2103 { 2104 int readVar() { return var; } 2105 } 2106 2107 /***************************************************/ 2108 // Bugzilla 4177 2109 2110 pure real log118(real x) { 2111 if (__ctfe) 2112 return 0.0; 2113 else 2114 return 1.0; 2115 } 2116 2117 enum x118 = log118(4.0); 2118 2119 void test118() {} 1972 2120 1973 2121 /***************************************************/ … … 2085 2233 test109(); 2086 2234 2235 test111(); 2236 2237 test113(); 2238 2239 test115(); 2240 test116(); 2241 test117(); 2242 test118(); 2243 2087 2244 printf("Success\n"); 2088 2245 return 0;
