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

Changeset 794

Show
Ignore:
Timestamp:
12/08/10 08:47:24 (14 years ago)
Author:
braddr
Message:

Submit the test changes from but 3258 now that the dmd portion is fixed.

Files:

Legend:

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

    r749 r794  
    1 // PERMUTE_ARGS: -inline -release -g -unittest 
    21 
    32import std.stdio; 
    43 
    54template Tuple(A...) 
    65{ 
    76    alias A Tuple; 
    87} 
    98 
    109template eval( A... ) 
    1110{ 
    1211    const typeof(A[0]) eval = A[0]; 
    1312} 
    1413 
    1514/************************************************/ 
    1615 
    1716int Foo1(int i) 
    1817{ 
    1918    if (i == 0) 
    2019    return 1; 
    2120    else 
     
    20862085 
    20872086int goodfoo1() 
    20882087{ 
    20892088   int[8] w;    // use static array in CTFE 
    20902089   w[]=7;       // full slice assign 
    20912090   w[$-1]=538;  // use of $ in index assignment 
    20922091   assert(w[6]==7); 
    20932092   return w[7]; 
    20942093} 
    20952094static assert(goodfoo1()==538); 
    20962095 
    20972096int goodfoo2() 
    20982097{ 
    20992098   S[4] w = S(101);  // Block-initialize array of structs 
    21002099   w[$-2].x = 917; // use $ in index member assignment 
    21012100   w[$-2].y = 58; // this must not clobber the prev assignment 
    21022101   return w[2].x; // check we got the correct one 
    21032102} 
    21042103static assert(goodfoo2()==917); 
    21052104 
    2106 int goodfoo3() 
    2107 
     2105static assert(is(typeof(Compileable!( 
     2106()
    21082107   S[4] w = void; // uninitialized array of structs 
    21092108   w[$-2].x = 217; // initialize one member 
    21102109   return w[2].x; 
    2111 } 
    2112 static assert(goodfoo3()==217); 
     2110}()).OK 
     2111))); 
    21132112 
    21142113int goodfoo4() 
    21152114{ 
    21162115   S[4] b = [S(7), S(15), S(56), S(12)]; // assign from array literal 
    21172116   assert(b[3]==S(12)); 
    21182117   return b[2].x-55; 
    21192118} 
    21202119static assert(goodfoo4()==1); 
    21212120 
    21222121int goodfoo5() 
    21232122{ 
    21242123    S[4] b = [S(7), S(15), S(56), S(12)]; 
    21252124    b[0..2] = [S(2),S(6)]; // slice assignment from array literal 
    21262125    assert(b[3]==S(12)); 
    21272126    assert(b[1]==S(6)); 
    21282127    return b[0].x; 
    21292128} 
    21302129static assert(goodfoo5()==2); 
    21312130static assert(goodfoo5()==2); // check for memory corruption 
    21322131