-- tests virtual function call class A { who() : String { "A" }; }; class B inherits A { who() : String { "B" }; }; class C inherits A { who() : String { "C" }; }; class D inherits B { who() : String { "D" }; }; class Test1 inherits IO { run() : SELF_TYPE { { out_string("Testing virtual method dispatch\n"); let a : A <- new A, b : A <- new B, c : A <- new C, d : A <- new D in if not (a.who() = "A") then { out_string("Failed on a.\n"); self; } else if not (b.who() = "B") then { out_string("Failed on b.\n"); self; } else if not (c.who() = "C") then { out_string("Failed on c.\n"); self; } else if not (d.who() = "D") then { out_string("Failed on d.\n"); self; } else { out_string("Passed!\n"); self; } fi fi fi fi; } }; }; class Main { main() : Object { let test1 : Test1 <- new Test1 in test1.run() }; };