~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to testsuite/tests/tool-ocaml/t301-object.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-04-21 21:35:08 UTC
  • mfrom: (1.1.11 upstream) (12.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110421213508-kg34453aqmb0moha
* Fixes related to -output-obj with g++ (in debian/patches):
  - add Declare-primitive-name-table-as-const-char
  - add Avoid-multiple-declarations-in-generated-.c-files-in
  - fix Embed-bytecode-in-C-object-when-using-custom: the closing
    brace for extern "C" { ... } was missing in some cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(**** file testinterp/t301-object.ml 
 
2
   suggested by Jacques Garrigue to Basile Starynkevitch 
 
3
 
 
4
   compilable with
 
5
ocamlc -nostdlib -I ../../stdlib \
 
6
  ../../stdlib/pervasives.cmo ../../stdlib/camlinternalOO.cmo \
 
7
  t301-object.ml -o t301-object.byte
 
8
 
 
9
***)
 
10
(* $Id: t301-object.ml 6363 2004-06-02 09:42:01Z basile $ *)
 
11
 
 
12
 
 
13
class c = object (self)
 
14
  method pubmet = 1
 
15
  method privmet = self#pubmet + 1
 
16
  val o = object method a = 3 method m = 4 end
 
17
  method dynmet = o#m
 
18
end;;
 
19
 
 
20
let f () =
 
21
  let c = new c in
 
22
  (c#pubmet, c#privmet, c#dynmet);;
 
23
 
 
24
let (x,y,z) = f () in
 
25
  if x <> 1 then raise Not_found;
 
26
  if y <> 2 then raise Not_found;
 
27
  if z <> 4 then raise Not_found;;
 
28
 
 
29
(**** eof $Id: t301-object.ml 6363 2004-06-02 09:42:01Z basile $ *)