Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 649

Show
Ignore:
Timestamp:
08/29/10 08:36:42 (14 years ago)
Author:
braddr
Message:

Updates to the test suite based on changes to dmd. Primarily 'auto' -> 'scope'.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/compilable/extra-files/header.di

    r624 r649  
    11// D import file generated from 'compilable/header.d' 
    22module foo.bar; 
    3 private  
    4 
    5     import std.stdio; 
    6 
     3private import std.stdio; 
     4 
    75pragma (lib, "test"); 
    86pragma (msg, "Hello World"); 
    97typedef double mydbl = 10; 
    108int main() 
    119in 
    1210{ 
    1311assert(1 + (2 + 3) == -(1 - 2 * 3)); 
    1412} 
    1513out(result) 
    1614{ 
    1715assert(result == 0); 
    1816} 
    1917body 
    2018{ 
    2119float f = (float).infinity; 
    2220int i = cast(int)f; 
    2321writeln((i , 1),2); 
    2422writeln(cast(int)(float).max); 
    2523assert(i == cast(int)(float).max); 
    2624assert(i == -2147483648u); 
     
    243241} 
    244242    alias A!(uint) getHUint; 
    245243    alias A!(int) getHInt; 
    246244    alias A!(float) getHFloat; 
    247245    alias A!(ulong) getHUlong; 
    248246    alias A!(long) getHLong; 
    249247    alias A!(double) getHDouble; 
    250248    alias A!(byte) getHByte; 
    251249    alias A!(ubyte) getHUbyte; 
    252250    alias A!(short) getHShort; 
    253251    alias A!(ushort) getHUShort; 
    254252    alias A!(real) getHReal; 
    255253} 
    256254template templ(T) 
    257255{ 
    258256void templ(T val) 
    259257{ 
    260258pragma (msg, "Invalid destination type."); 
    261259} 
    262260} 
    263 static  
    264 
    265     char[] charArray = ['"','\'']; 
    266 
     261static char[] charArray = ['"','\'']; 
     262 
    267263class Point 
    268264{ 
    269265    auto x = 10; 
    270266    uint y = 20; 
    271267} 
    272268template Foo2(bool bar) 
    273269{ 
    274270void test() 
    275271{ 
    276272static if(bar) 
    277273{ 
    278274int i; 
    279275} 
    280276else 
    281277{ 
    282278} 
    283279 
    284280static if(!bar) 
    285281{ 
    286282} 
  • trunk/test/compilable/extra-files/xheader.di

    r624 r649  
    88void bar(in void* p) 
    99{ 
    1010} 
    1111void f(void function() f2); 
    1212class C2; 
    1313void foo2(const C2 c); 
    1414struct Foo3 
    1515{ 
    1616    int k; 
    1717    ~this() 
    1818{ 
    1919k = 1; 
    2020} 
    2121    this(this) 
    2222{ 
    2323k = 2; 
    2424} 
    2525} 
    2626class C3 
    2727{ 
    28     @property  
    29 
    30     int get() 
     28    @property int get() 
    3129{ 
    3230return 0; 
    3331} 
    3432} 
    35 } 
  • trunk/test/runnable/auto1.d

    r574 r649  
    11 
    22import std.c.stdio; 
    33 
    44/******************************************/ 
    55 
    6 auto class Foo 
     6scope class Foo 
    77{ 
    88    static int x; 
    99 
    1010    ~this() 
    1111    { 
    1212    printf("Foo.~this()\n"); 
    1313    x++; 
    1414    } 
    1515} 
    1616 
    1717int test1x() 
    1818{ 
    19     auto Foo f = new Foo(); 
     19    scope Foo f = new Foo(); 
    2020    return 6; 
    2121} 
    2222 
    2323 
    2424void test1() 
    2525{ 
    2626    { 
    27     auto Foo f = new Foo(); 
     27    scope Foo f = new Foo(); 
    2828    } 
    2929    int c; 
    3030 
    3131    assert(Foo.x == 1); 
    3232    c = test1x(); 
    3333    assert(c == 6); 
    3434    assert(Foo.x == 2); 
    3535 
    3636    if (c != 6) 
    37     auto Foo h = new Foo(); 
     37    scope Foo h = new Foo(); 
    3838    assert(Foo.x == 2); 
    3939 
    4040    if (c == 6) 
    41     auto Foo j = new Foo(); 
     41    scope Foo j = new Foo(); 
    4242    assert(Foo.x == 3); 
    4343 
    4444    { 
    45     auto Foo g = null, k = new Foo(); 
     45    scope Foo g = null, k = new Foo(); 
    4646    assert(Foo.x == 3); 
    4747    } 
    4848    assert(Foo.x == 4); 
    4949} 
    5050 
    5151/******************************************/ 
    5252 
    5353int ax; 
    5454 
    55 auto class A2 
     55scope class A2 
    5656{ 
    5757  this() 
    5858  { 
    5959    printf("A2.this()\n"); 
    6060    ax += 1; 
    6161  } 
    6262 
    6363  ~this() 
    6464  { 
    6565    printf("A2.~this()\n"); 
    6666    ax += 1000; 
    6767  } 
    6868}; 
    6969 
    7070 
    7171void test2() 
    7272{ 
    7373  { 
    74     auto A2 a = new A2(); 
     74    scope A2 a = new A2(); 
    7575    printf("Hello world.\n"); 
    7676  } 
    7777  assert(ax == 1001); 
    7878} 
    7979 
    8080 
    8181 
    8282/******************************************/ 
    8383 
    8484int status3; 
    8585 
    86 auto class Parent3 
     86scope class Parent3 
    8787{ 
    8888} 
    8989 
    90 auto class Child3 : Parent3 
     90scope class Child3 : Parent3 
    9191{ 
    9292    this(){ 
    9393        assert(status3==0); 
    9494        status3=1; 
    9595    }     
    9696 
    9797    ~this(){ 
    9898        assert(status3==1); 
    9999        status3=2; 
    100100    } 
    101101} 
    102102 
    103103void foo3() 
    104104{ 
    105     auto Parent3 o = new Child3(); 
     105    scope Parent3 o = new Child3(); 
    106106    assert(status3==1); 
    107107} 
    108108 
    109109void test3() 
    110110{ 
    111111    foo3(); 
    112112    assert(status3==2); 
    113113} 
    114114 
    115115/******************************************/ 
    116116 
    117117int main() 
    118118{ 
    119119    test1(); 
    120120    test2(); 
    121121    test3(); 
    122122 
    123123    printf("Success\n"); 
    124124    return 0; 
    125125} 
  • trunk/test/runnable/bug5.d

    r539 r649  
    11// REQUIRED_ARGS: -w 
    22 
    33class F { } 
    44 
    55int test1() { 
    6     auto F f = new F(); // comment out and warning goes away 
     6    scope F f = new F(); // comment out and warning goes away 
    77    return 0; 
    88} 
    99 
    1010int test2() { // no return at end of function 
    1111    try { 
    1212        return 0; 
    1313    } finally { } 
    1414} 
    1515 
    1616void main() 
    1717{ 
    1818    test1(); 
    1919    test2(); 
    2020} 
  • trunk/test/runnable/interface.d

    r551 r649  
    3232    IO io = new IO(); 
    3333    printf("io = %p\n", io); 
    3434    foo(io, io); 
    3535    delete io; 
    3636} 
    3737 
    3838/*******************************************/ 
    3939 
    4040interface I { } 
    4141class C : I 
    4242{ 
    4343    ~this() { printf("~C()\n"); } 
    4444} 
    4545 
    4646void test2() 
    4747{ 
    4848    I i = new C(); 
    4949    delete i; 
    5050 
    5151  { 
    52     auto I j = new C(); 
     52    scope I j = new C(); 
    5353  } 
    5454} 
    5555 
    5656/*******************************************/ 
    5757 
    5858int main() 
    5959{ 
    6060    test1(); 
    6161    test2(); 
    6262 
    6363    printf("Success\n"); 
    6464    return 0; 
    6565} 
  • trunk/test/runnable/test20.d

    r553 r649  
    195195 
    196196/*****************************************/ 
    197197 
    198198struct Foo10 { 
    199199  const bool opEquals(const ref Foo10 x) { 
    200200    return this.normalize is x.normalize; 
    201201  } 
    202202  const Foo10 normalize() { 
    203203    Foo10 res; 
    204204    return res; 
    205205  } 
    206206} 
    207207 
    208208void test10() 
    209209{ 
    210210} 
    211211 
    212212 
    213213/*****************************************/ 
    214214 
    215 auto class T11 
     215scope class T11 
    216216{ 
    217217    this(){} 
    218218    ~this(){} 
    219219} 
    220220 
    221221void test11() 
    222222{ 
    223     auto T11 t=new T11(); 
     223    scope T11 t=new T11(); 
    224224    int i=1; 
    225225    switch(i) 
    226226    { 
    227227    case 1: 
    228228        break; 
    229229 
    230230    default: 
    231231        break; 
    232232    } 
    233233} 
    234234 
    235235/*****************************************/ 
    236236 
    237237void test12() 
    238238{ 
    239239        char[] s; 
    240240        char[] t; 
    241241 
    242242        if (true) 
    243243            s = null; 
  • trunk/test/runnable/test23.d

    r553 r649  
    719719 
    720720    new (size_t sz, int i) 
    721721    { 
    722722    void* p = std.c.stdlib.malloc(sz); 
    723723    printf("new(sz = %d) = %p\n", sz, p); 
    724724    ps = p; 
    725725        return p; 
    726726    } 
    727727 
    728728    delete(void* p) 
    729729    { 
    730730    printf("delete(p = %p)\n", p); 
    731731    assert(p == ps); 
    732732        if (p) std.c.stdlib.free(p); 
    733733    del += 1; 
    734734    } 
    735735} 
    736736 
    737737void foo33() 
    738738{ 
    739     auto Foo33 f = new(3) Foo33; 
     739    scope Foo33 f = new(3) Foo33; 
    740740} 
    741741 
    742742void test33() 
    743743{ 
    744744    foo33(); 
    745745    assert(Foo33.del == 1); 
    746746} 
    747747 
    748748/*******************************************/ 
    749749 
    750750struct o_O { int a; } 
    751751union  O_O { int a; } 
    752752class  O_o { int a; } 
    753753 
    754754struct Foo34 
    755755{ 
    756756    int ok; 
    757757    o_O foo; 
    758758    O_O bar; 
    759759    O_o baz; 
  • trunk/test/runnable/test8.d

    r551 r649  
    875875    real y1,x1; 
    876876 
    877877    C = x1 + y1*1i + Cj; 
    878878    C = 1i*y1 + x1 + Cj; 
    879879    C = Cj + 1i*y1 + x1; 
    880880    C = y1*1i + Cj + x1; 
    881881    C = 1i*y1 + Cj; 
    882882    C = Cj + 1i*y1; 
    883883} 
    884884 
    885885/***********************************/ 
    886886 
    887887int x44; 
    888888 
    889889class A44 { 
    890890     this() { printf("A44 ctor\n"); x44 += 1; } 
    891891     ~this() { printf("A44 dtor\n"); x44 += 0x100; } 
    892892} 
    893893class B44 : A44 { } 
    894894 
    895 void foo44() { auto B44 b = new B44; } 
     895void foo44() { scope B44 b = new B44; } 
    896896 
    897897void test44() 
    898898{ 
    899899     printf("foo44...\n"); 
    900900     foo44(); 
    901901     printf("...foo44\n"); 
    902902     assert(x44 == 0x101); 
    903903} 
    904904 
    905905/***********************************/ 
    906906 
    907907/* 
    908908import std.stdarg; 
    909909import std.utf; 
    910910 
    911911int unFormat( bool delegate( out dchar ) getc, 
    912912    bool delegate( dchar ) ungetc, 
    913913    TypeInfo[] arguments, 
    914914    void* argptr ) 
    915915{ 
  • trunk/test/runnable/testdstress.d

    r575 r649  
    432432 
    433433/* ================================ */ 
    434434 
    435435class C21(T1){ 
    436436    alias T1 type1; 
    437437} 
    438438 
    439439class C21(T1, T2){ 
    440440    alias T1 type1; 
    441441    alias .C21!(T2) type2; 
    442442} 
    443443 
    444444void test21() 
    445445{ 
    446446    alias C21!(int,long) CT; 
    447447    CT c = new CT(); 
    448448} 
    449449 
    450450/* ================================ */ 
    451451 
    452 auto class AutoClass{ 
     452scope class AutoClass{ 
    453453} 
    454454 
    455455void test22() 
    456456{ 
    457     auto AutoClass ac = new AutoClass(); 
     457    scope AutoClass ac = new AutoClass(); 
    458458 
    459459    with(ac){ 
    460460    } 
    461461} 
    462462 
    463463/* ================================ */ 
    464464 
    465465int status23; 
    466466 
    467 auto class C23{ 
     467scope class C23{ 
    468468    ~this(){ 
    469469        assert(status23==0); 
    470470        status23--; 
    471471        throw new Exception("error msg"); 
    472472    } 
    473473} 
    474474 
    475475void foo23(){ 
    476476    assert(status23==0); 
    477     auto C23 ac = new C23(); 
     477    scope C23 ac = new C23(); 
    478478} 
    479479 
    480480void test23() 
    481481{ 
    482482    try{ 
    483483        foo23(); 
    484484    }catch{ 
    485485    } 
    486486    assert(status23==-1); 
    487487} 
    488488 
    489489/* ================================ */ 
    490490 
    491491int status24; 
    492492 
    493 auto class C24{ 
     493scope class C24{ 
    494494    this(){ 
    495495        assert(status24==0); 
    496496        status24+=2; 
    497497    } 
    498498    ~this(){ 
    499499        assert(status24==2); 
    500500        status24--; 
    501501        throw new Exception("error msg"); 
    502502    } 
    503503} 
    504504 
    505505void check24(){ 
    506     auto C24 ac = new C24(); 
     506    scope C24 ac = new C24(); 
    507507    throw new Exception("check error"); 
    508508} 
    509509 
    510510void test24() 
    511511{ 
    512512    assert(status24==0); 
    513513    try{ 
    514514        check24(); 
    515515    }catch{ 
    516516        assert(status24==1); 
    517517        status24-=5; 
    518518    } 
    519519    assert(status24==-4); 
    520520} 
    521521 
    522522/* ================================ */ 
    523523 
    524524struct S25{ 
    525525    S25 opSub(int i) { S25 s; return s; } 
    526526} 
     
    621621 
    622622/* ================================ */ 
    623623 
    624624int status30; 
    625625 
    626626class C30 
    627627{ 
    628628    this(){ 
    629629        status30++; 
    630630    } 
    631631     
    632632    ~this(){ 
    633633        status30--; 
    634634        throw new Exception("E2"); 
    635635    } 
    636636} 
    637637 
    638638void test30() 
    639639{ 
    640640    try{ 
    641         auto C30 m = new C30(); 
     641        scope C30 m = new C30(); 
    642642        assert(status30 == 1); 
    643643        delete m; 
    644644    }catch(Error e){ 
    645645        assert(status30 == 0); 
    646646        status30--; 
    647647    } 
    648648     
    649649    assert(status30 == -1); 
    650650} 
    651651 
    652652/* ================================ */ 
    653653 
    654654void test31() 
    655655{ 
    656656    string str = x"F0 9D 83 93"; // utf-8 for U+1D0D3 
    657657 
    658658    int count=0; 
    659659    dchar tmp; 
    660660    foreach(dchar value ; str){ 
    661661        tmp=value; 
  • trunk/test/runnable/testmmfile.d

    r575 r649  
    11// PERMUTE_ARGS: 
    22// REQUIRED_ARGS: -d 
    33 
    44import std.file; 
    55import std.mmfile; 
    66 
    77int main() 
    88{ 
    99    static string name = "test.tmp"; 
    1010    static string s = "abcd"; 
    1111 
    1212    write(name, s); 
    1313 
    14     {   auto MmFile mmf = new MmFile(name); 
     14    {   scope MmFile mmf = new MmFile(name); 
    1515    string p; 
    1616 
    1717    assert(mmf[0] == 'a'); 
    1818    p = cast(string)mmf[]; 
    1919    //printf("p.length = %d\n", p.length); 
    2020    assert(p[1] == 'b'); 
    2121    p = cast(string)mmf[0 .. 4]; 
    2222    assert(p[2] == 'c'); 
    2323    } 
    2424 
    25     {   auto MmFile mmf = new MmFile(name, MmFile.Mode.Read, 0, null); 
     25    {   scope MmFile mmf = new MmFile(name, MmFile.Mode.Read, 0, null); 
    2626    string p; 
    2727 
    2828    assert(mmf[0] == 'a'); 
    2929    p = cast(string)mmf[]; 
    3030    //printf("p.length = %d\n", p.length); 
    3131    assert(mmf.length == 4); 
    3232    assert(p[1] == 'b'); 
    3333    p = cast(string)mmf[0 .. 4]; 
    3434    assert(p[2] == 'c'); 
    3535    } 
    3636 
    3737    remove(name); 
    3838 
    39     {   auto MmFile mmf = new MmFile(name, MmFile.Mode.ReadWriteNew, 4, null); 
     39    {   scope MmFile mmf = new MmFile(name, MmFile.Mode.ReadWriteNew, 4, null); 
    4040    char[] p; 
    4141 
    4242    p = cast(char[])mmf[]; 
    4343    p[] = "1234"; 
    4444    mmf[3] = '5'; 
    4545    assert(mmf[2] == '3'); 
    4646    assert(mmf[3] == '5'); 
    4747    } 
    4848 
    4949    {   string p = cast(string)read(name); 
    5050 
    5151    assert(p[] == "1235"); 
    5252    } 
    5353 
    54     {   auto MmFile mmf = new MmFile(name, MmFile.Mode.ReadWriteNew, 4, null); 
     54    {   scope MmFile mmf = new MmFile(name, MmFile.Mode.ReadWriteNew, 4, null); 
    5555    char[] p; 
    5656 
    5757    p = cast(char[])mmf[]; 
    5858    p[] = "5678"; 
    5959    mmf[3] = '5'; 
    6060    assert(mmf[2] == '7'); 
    6161    assert(mmf[3] == '5'); 
    6262    assert(cast(string)mmf[] == "5675"); 
    6363    } 
    6464 
    6565    {   string p = cast(string)read(name); 
    6666 
    6767    assert(p[] == "5675"); 
    6868    } 
    6969 
    70     {   auto MmFile mmf = new MmFile(name, MmFile.Mode.ReadWrite, 4, null); 
     70    {   scope MmFile mmf = new MmFile(name, MmFile.Mode.ReadWrite, 4, null); 
    7171    char[] p; 
    7272 
    7373    p = cast(char[])mmf[]; 
    7474    assert(cast(char[])mmf[] == "5675"); 
    7575    p[] = "9102"; 
    7676    mmf[2] = '5'; 
    7777    assert(cast(string)mmf[] == "9152"); 
    7878    } 
    7979 
    8080    {   string p = cast(string)read(name); 
    8181 
    8282    assert(p[] == "9152"); 
    8383    } 
    8484 
    8585    remove(name); 
    8686 
    87     {   auto MmFile mmf = new MmFile(name, MmFile.Mode.ReadWrite, 4, null); 
     87    {   scope MmFile mmf = new MmFile(name, MmFile.Mode.ReadWrite, 4, null); 
    8888    char[] p; 
    8989 
    9090    p = cast(char[])mmf[]; 
    9191    p[] = "abcd"; 
    9292    mmf[2] = '5'; 
    9393    assert(cast(string)mmf[] == "ab5d"); 
    9494    } 
    9595 
    9696    {   string p = cast(string)read(name); 
    9797 
    9898    assert(p[] == "ab5d"); 
    9999    } 
    100100 
    101     {   auto MmFile mmf = new MmFile(name, MmFile.Mode.ReadCopyOnWrite, 4, null); 
     101    {   scope MmFile mmf = new MmFile(name, MmFile.Mode.ReadCopyOnWrite, 4, null); 
    102102    char[] p; 
    103103 
    104104    p = cast(char[])mmf[]; 
    105105    assert(cast(string)mmf[] == "ab5d"); 
    106106    p[] = "9102"; 
    107107    mmf[2] = '5'; 
    108108    assert(cast(string)mmf[] == "9152"); 
    109109    } 
    110110 
    111111    {   string p = cast(string)read(name); 
    112112 
    113113    assert(p[] == "ab5d"); 
    114114    } 
    115115 
    116116    remove(name); 
    117117 
    118118    return 0; 
    119119} 
  • trunk/test/runnable/testscope.d

    r549 r649  
    1919 
    2020    this() 
    2121    { 
    2222    assert(x == 0); 
    2323    x++; 
    2424    printf("Foo.this()\n"); 
    2525    throw new Eh(); 
    2626    assert(0); 
    2727    } 
    2828 
    2929    ~this() 
    3030    { 
    3131    printf("Foo.~this()\n"); 
    3232    } 
    3333} 
    3434 
    3535void test1() 
    3636{ 
    3737    try 
    3838    { 
    39     auto Foo f = new Foo(); 
     39    scope Foo f = new Foo(); 
    4040    assert(0); 
    4141    } 
    4242    catch (Eh) 
    4343    { 
    4444    assert(Foo.x == 1); 
    4545    Foo.x++; 
    4646    } 
    4747    finally 
    4848    { 
    4949    assert(Foo.x == 2); 
    5050    Foo.x++; 
    5151    } 
    5252    assert(Foo.x == 3); 
    5353} 
    5454 
    5555/********************************************/ 
    5656 
    5757void test2() 
    5858{ 
    5959    int x; 
  • trunk/test/runnable/warning1.d

    r549 r649  
    11// REQUIRED_ARGS: -w 
    22// PERMUTE_ARGS: 
    33 
    44extern(C) int printf(const char*, ...); 
    55 
    66class F { } 
    77int foo() 
    88{ 
    9     auto F f = new F(); // comment out and warning goes away 
     9    scope F f = new F(); // comment out and warning goes away 
    1010    return 0; 
    1111} 
    1212 
    1313int foo2() 
    1414{ 
    1515    try { 
    1616    return 0; 
    1717    } finally { } 
    1818} 
    1919 
    2020private int getNthInt(A...)(uint index, A args) 
    2121{ 
    2222    foreach (i, arg; args) 
    2323    { 
    2424        static if (is(typeof(arg) : long) || is(typeof(arg) : ulong)) 
    2525        { 
    2626            if (i != index) continue; 
    2727            return cast(int)(arg); 
    2828        } 
    2929        else