Created
March 17, 2010 15:57
-
-
Save szastupov/335377 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open OUnit | |
class printable_point x_init = | |
object (s) | |
val mutable x = x_init | |
method get_x = x | |
method move d = x <- x + d | |
method print = string_of_int s#get_x | |
end | |
class printable_colored_point y c = | |
object (self) | |
val c = c | |
method color = c | |
inherit printable_point y as super | |
method move1 n = | |
super#move n (* self#move works *) | |
method print = | |
super#print ^ self#color | |
end | |
let tests = "Oo_super" >:: begin fun () -> | |
let p= new printable_colored_point 5 "red" in | |
p#move1 10; | |
assert_equal p#print "15red" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment