Newer
Older
zweic / tests / 4 / term-block.zwei
@ajaggi ajaggi on 26 Dec 2005 652 bytes Added some test cases
// Block

// Select
class bar {
    Int h;
}

class bof extends bar {}

class IfTest {
    Null foo() {
        Int t = 0;

        bar b = new bar(2);
        bar z = new bof(3);

        bar y = if (t) b else z; // 7/7 failure of clause 3 (return type mismatch)
    }
}

class BlockTest {
    Null foo() {
        {
            Int x = null; // 1/2 failure of clause 1 (incorrectly typed statement in block)
            return x
        };
        {
            Int x = 2;
            return y // 2/2 failure of clause 2 (expression not in block scope)
        };
        {
            Int x = 2;
            return x // success
        };
    }
}

0