blob: ac4a4e03d4c1f8d6376936784007921a0e64dc17 (
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
|
(**** 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
***)
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;;
|