summaryrefslogtreecommitdiff
path: root/ocaml-binary-annot/testsuite/tests/tool-ocaml/t301-object.ml
blob: 6cef9bedc57cee9baef25d618a0a7d9e7bbe3658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(**** file testinterp/t301-object.ml 
   suggested by Jacques Garrigue to Basile Starynkevitch 

   compilable with
ocamlc -nostdlib -I ../../stdlib \
  ../../stdlib/pervasives.cmo ../../stdlib/camlinternalOO.cmo \
  t301-object.ml -o t301-object.byte

***)
(* $Id: t301-object.ml 6363 2004-06-02 09:42:01Z basile $ *)


class c = object (self)
  method pubmet = 1
  method privmet = self#pubmet + 1
  val o = object method a = 3 method m = 4 end
  method dynmet = o#m
end;;

let f () =
  let c = new c in
  (c#pubmet, c#privmet, c#dynmet);;

let (x,y,z) = f () in
  if x <> 1 then raise Not_found;
  if y <> 2 then raise Not_found;
  if z <> 4 then raise Not_found;;

(**** eof $Id: t301-object.ml 6363 2004-06-02 09:42:01Z basile $ *)