Changeset 653

Show
Ignore:
Timestamp:
09/01/10 01:51:00 (1 year ago)
Author:
braddr
Message:

Integrate changes from the private test suite into the public one

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/runnable/arrayop.d

    r544 r653  
    417417/************************************************************************/ 
    418418 
     419void test4() 
     420{ 
     421    int[] a, b; 
     422    if (a && b) {} 
     423} 
     424 
     425/************************************************************************/ 
     426 
    419427int main() 
    420428{ 
     
    422430    test2(); 
    423431    test3(); 
     432    test4(); 
    424433 
    425434    printf("Success\n"); 
  • trunk/test/runnable/interface.d

    r649 r653  
    5656/*******************************************/ 
    5757 
     58interface I3 { 
     59    void h(); 
     60} 
     61interface K3 { 
     62    void f(); 
     63} 
     64 
     65interface J3 : I3, K3 {} 
     66 
     67class A3 : J3 { 
     68    void f(){ } 
     69    void h(){ }  
     70} 
     71 
     72void 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 
    5882int main() 
    5983{ 
    6084    test1(); 
    6185    test2(); 
     86    test3(); 
    6287 
    6388    printf("Success\n"); 
  • trunk/test/runnable/nested.d

    r575 r653  
    14651465    auto c = new A; 
    14661466    assert(c.bar(4) == 44); 
     1467} 
     1468/*******************************************/ 
     1469 
     1470void 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    } 
    14671484} 
    14681485 
     
    15251542    test53(); 
    15261543    test54(); 
     1544    test55(); 
    15271545 
    15281546    printf("Success\n"); 
  • trunk/test/runnable/opover.d

    r574 r653  
    882882/**************************************/ 
    883883 
     884// 3983 
     885 
     886struct Fug 
     887{ 
     888    bool opEquals(ref const Fug y) const { 
     889        return false; 
     890    } 
     891} 
     892 
     893struct 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 
     905void test15() 
     906{ 
     907  Fig fx, fy; 
     908  if (fx==2) {} 
     909} 
     910 
     911/**************************************/ 
     912 
    884913int main() 
    885914{ 
     
    898927    test13(); 
    899928    test14(); 
     929    test15(); 
    900930 
    901931    printf("Success\n"); 
  • trunk/test/runnable/sdtor.d

    r575 r653  
    12701270  final switch(0) A51 a; 
    12711271  A51 a; with(a) A51 b; 
     1272} 
     1273 
     1274/**********************************/ 
     1275 
     1276string s52; 
     1277 
     1278struct 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 
     1299void 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 
     1313struct A53 { 
     1314    invariant() {   } 
     1315    ~this() { } 
     1316    void opAssign(A53 a) {} 
     1317    int blah(A53 a) { return 0; } 
    12721318} 
    12731319 
     
    13271373    test50(); 
    13281374    test51(); 
     1375    test52(); 
    13291376 
    13301377    printf("Success\n"); 
  • trunk/test/runnable/template4.d

    r574 r653  
    10191019} 
    10201020 
     1021/*********************************************************/ 
     1022 
     1023void bug4652(U, T...)(long y, T x, U num) {} 
     1024void bug4652default(T) (T value, int x=2) {} 
     1025void bug4652default(T) (T value, int y) {} 
     1026void bug4676(T...)(T args, string str) {} 
     1027void bug4676(T...)(T args) {} 
     1028 
     1029void 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} 
    10211036 
    10221037/*********************************************************/ 
  • trunk/test/runnable/test4.d

    r551 r653  
    13741374        printf("catch %.*s\n", e.msg); 
    13751375        assert(e.msg == "second"); 
     1376        //assert(e.msg == "first"); 
     1377        //assert(e.next.msg == "second"); 
    13761378        assert(status==3); 
    13771379    } 
     
    13921394    { 
    13931395    printf("inner catch %p\n", e); 
     1396    printf("e.msg == %.*s\n", e.msg); 
    13941397    assert(e.msg == "second"); 
     1398    //assert(e.msg == "first"); 
     1399    //assert(e.next.msg == "second"); 
    13951400    } 
    13961401} 
  • trunk/test/runnable/test42.d

    r556 r653  
    699699void test45() 
    700700{ 
    701    version(Windows) 
     701   version (Windows)  // this test fails in -release because asserts will be removed 
    702702   { 
    703703      assert(foo45(0)==2); 
     
    34553455 
    34563456static assert(A196.sizeof == B196.sizeof); 
     3457 
     3458/***************************************************/ 
     3459 
     3460template Compileable(int z) { bool OK;} 
     3461 
     3462struct Bug3569 { 
     3463    int bar() { return 7; } 
     3464} 
     3465 
     3466struct 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 
     3474void test197() 
     3475{ 
     3476} 
     3477 
     3478/***************************************************/ 
     3479 
     3480void 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 
     3492void g199(void delegate(void*, void*) d) { } 
     3493 
     3494struct X199 { 
     3495    void f(void*, void*) {} 
     3496    void n() 
     3497    { 
     3498        g199(&f); 
     3499    } 
     3500} 
     3501 
     3502/***************************************************/ 
     3503// Bugzilla 4443 
     3504 
     3505struct Struct4443 
     3506{ 
     3507    int x; 
     3508    char[5] unused; 
     3509} 
     3510 
     3511void 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 
     3519void test200() 
     3520{ 
     3521    Struct4443[1] a; 
     3522    Struct4443 info; 
     3523    foo4443(&info, a); 
     3524} 
     3525 
     3526/***************************************************/ 
     3527 
     3528// Bugzilla 2931 
     3529 
     3530struct Bug2931 { 
     3531        int val[3][4]; 
     3532} 
     3533 
     3534struct 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 
     3541int bug2931() 
     3542{ 
     3543  Outer2931 v; 
     3544  assert(v.move==3); 
     3545  assert(v.scale == 4); 
     3546  return v.zoom; 
     3547} 
     3548 
     3549int 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 
     3568static assert(bug2931()==2); 
     3569 
     3570void test201() { 
     3571    assert(bug2931()==2); 
     3572    assert(bug2931_2()==2); 
     3573} 
     3574 
     3575 
     3576/***************************************************/ 
     3577 
     3578import std.stdarg; 
     3579 
     3580void 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 
     3589void 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 
     3598void 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 
     3611class A203 
     3612{ 
     3613    char name = 'A'; 
     3614    class B203 
     3615    { 
     3616        char name = 'B'; 
     3617    } 
     3618} 
     3619 
     3620void 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 
     3642struct A204 { B204 b; } 
     3643enum B204 { Z } 
     3644 
     3645/***************************************************/ 
     3646// Bugzilla 4503 
     3647 
     3648class Collection205(T) { } 
     3649ICollection c; 
     3650 
     3651alias Collection205!int ICollection; 
     3652 
     3653/***************************************************/ 
     3654 
     3655enum TaskStatus:int { Building=-1, } 
     3656 
     3657TaskStatus 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 
     3669struct UN {   double dd;    long ll; } 
     3670bool cmp( UN * pU ) {   return pU.dd >= pU.ll ? true : false; } 
     3671 
     3672struct UN2 {  real dd; long ll; } 
     3673bool cmp2( UN2 * pU ) {  return pU.dd >= pU.ll ? true : false; } 
     3674 
     3675struct UN3 {  double dd; int ll; } 
     3676bool cmp3( UN3 * pU ) {  return pU.dd >= pU.ll ? true : false; } 
     3677 
     3678void 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 
     3700template fail4302() { 
     3701    static assert(0); 
     3702} 
     3703template bug4302() { 
     3704   alias fail4302!() bad; 
     3705} 
     3706static if (is(bug4302!())) {} 
     3707 
     3708/***************************************************/ 
     3709 
     3710template 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 
     3723alias 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 
     3736const bar209 = foo209; 
     3737const int * foo209 = null; 
    34573738 
    34583739/***************************************************/ 
     
    36473928    test194(); 
    36483929 
     3930    test198(); 
     3931 
     3932    test200(); 
     3933    test201(); 
     3934    test202(); 
     3935    test203(); 
     3936 
     3937//    test208(); 
     3938 
    36493939    writefln("Success"); 
    36503940    return 0; 
  • trunk/test/runnable/test60.d

    r575 r653  
    1 // PERMUTE_ARGS: 
    2  
    31import std.stdio; 
    42import std.algorithm; 
    53 
    6 void main() 
     4void test1() 
    75{ 
    86    int[] a = [1,2,3,4,5]; 
    97    writeln( remove!("a < 3")(a) ); 
    108} 
     9 
     10void test2() 
     11{ 
     12    auto arr = [1,2,3,4,5]; 
     13    auto m = map!"a + 1"(filter!"a < 4"(arr)); 
     14} 
     15 
     16void main() 
     17{ 
     18    test1(); 
     19    test2(); 
     20 
     21    writeln("Success"); 
     22} 
  • trunk/test/runnable/xtest46.d

    r571 r653  
    19701970static assert(B110.s == "Boo!(double)"); 
    19711971static assert(A110.s == "Boo!(int)"); 
     1972 
     1973/***************************************************/ 
     1974 
     1975// 3716 
     1976void 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 
     1990template foo112() if (__traits(compiles,undefined)) 
     1991{ 
     1992    enum foo112 = false; 
     1993} 
     1994 
     1995template foo112() if (true) 
     1996{ 
     1997    enum foo112 = true; 
     1998} 
     1999 
     2000pragma(msg,__traits(compiles,foo112!())); 
     2001static assert(__traits(compiles,foo112!())); 
     2002 
     2003const bool bar112 = foo112!(); 
     2004 
     2005 
     2006/***************************************************/ 
     2007 
     2008struct 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 
     2030auto filter113(File113.ByLine rs) 
     2031{ 
     2032    struct Filter 
     2033    { 
     2034    this(File113.ByLine r) { } 
     2035    } 
     2036 
     2037    return Filter(rs); 
     2038} 
     2039 
     2040void test113() 
     2041{ 
     2042    auto f = File113(1); 
     2043    auto rx = f.byLine(); 
     2044    auto file = filter113(rx); 
     2045} 
     2046 
     2047/***************************************************/ 
     2048 
     2049template foo114(fun...) 
     2050{ 
     2051    auto foo114(int[] args) 
     2052    { 
     2053    return 1; 
     2054    } 
     2055} 
     2056 
     2057pragma(msg, typeof(foo114!"a + b"([1,2,3]))); 
     2058 
     2059/***************************************************/ 
     2060// Bugzilla 3935 
     2061 
     2062struct Foo115 { 
     2063    void opBinary(string op)(Foo other) { 
     2064        pragma(msg, "op: " ~ op); 
     2065    assert(0); 
     2066    } 
     2067} 
     2068 
     2069void test115() 
     2070{ 
     2071    Foo115 f; 
     2072    f = f; 
     2073} 
     2074 
     2075/***************************************************/ 
     2076// Bugzilla 2477 
     2077 
     2078void foo116(T,)(T t) { T x; } 
     2079 
     2080void 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 
     2094void test117() pure 
     2095{ 
     2096    mixin declareVariable; 
     2097    var = 42; 
     2098    mixin declareFunction; 
     2099    readVar(); 
     2100} 
     2101template declareVariable() { int var; } 
     2102template declareFunction() 
     2103{ 
     2104    int readVar() { return var; } 
     2105} 
     2106 
     2107/***************************************************/ 
     2108// Bugzilla 4177 
     2109 
     2110pure real log118(real x) { 
     2111    if (__ctfe) 
     2112        return 0.0; 
     2113    else 
     2114        return 1.0; 
     2115} 
     2116 
     2117enum x118 = log118(4.0); 
     2118 
     2119void test118() {} 
    19722120 
    19732121/***************************************************/ 
     
    20852233    test109(); 
    20862234 
     2235    test111(); 
     2236 
     2237    test113(); 
     2238 
     2239    test115(); 
     2240    test116(); 
     2241    test117(); 
     2242    test118(); 
     2243 
    20872244    printf("Success\n"); 
    20882245    return 0;