Skip to content

Instantly share code, notes, and snippets.

@szastupov
Created March 17, 2010 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szastupov/335377 to your computer and use it in GitHub Desktop.
Save szastupov/335377 to your computer and use it in GitHub Desktop.
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