Newer
Older
zweic / tests / 4 / term-if.zwei
@ajaggi ajaggi on 26 Dec 2005 909 bytes Added some test cases
// If

class foo {
    Int y;
}

class bar {
    Int h;
}

class bof extends bar {}

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

        bar b = new bar(2);
        bof z = new bof(3);
        
        if(k) {} else {}; // 1/7 failure of clause 1 (nonexistent condition)
        if(n) {} else {}; // 2/7 failure of clause 1 (condition not Int)
        if(t) {gorh g = null;return g} else 2; // 3/7 failure of clause 2 (unknown type)
        if(t) 2 else {gorh g = null;return g }; // 4/7 failure of clause 2 (unknown type)
        if(t) {foo f = new foo(1);return f} else 2;  // 5/7 failure of clause 3 (LUB not found)
        if(t) 2 else {foo f = new foo(2);return f};  // 6/7 failure of clause 3 (LUB not found)
        bof y = if (t) b else z; // 7/7 failure of clause 3 (return type mismatch)
        if(t) 2 else 3; // success
        if(t) b else z; // success
    }
}

1