PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/ocaml/minherit_runme.ml

#
OCaml | 131 lines | 106 code | 23 blank | 2 comment | 36 complexity | a46cb247e68e90326a1af6006107927c MD5 | raw file
  1(* Stolen from the python tests *)
  2open Swig
  3open Minherit
  4
  5let a = new_Foo C_void
  6let b = new_Bar C_void 
  7let c = new_FooBar C_void
  8let d = new_Spam C_void
  9
 10let soci x = (string_of_int (get_int x))
 11
 12let _ =
 13  if (invoke a) "xget" C_void <> (C_int 1) then
 14    raise (Failure "Bad attribute value (a.xget)")
 15
 16let _ =
 17  if (invoke b) "yget" C_void <> (C_int 2) then
 18    raise (Failure "Bad attribute value (b.yget)")
 19
 20let _ =
 21  if   (invoke c) "xget" C_void <> (C_int 1)
 22    || (invoke c) "yget" C_void <> (C_int 2)
 23    || (invoke c) "zget" C_void <> (C_int 3) then
 24      raise (Failure "Bad attribute value c")
 25	
 26let _ =
 27  if   (invoke d) "xget" C_void <> (C_int 1)
 28    || (invoke d) "yget" C_void <> (C_int 2)
 29    || (invoke d) "zget" C_void <> (C_int 3)
 30    || (invoke d) "wget" C_void <> (C_int 4) then
 31      raise (Failure "Bad attribute value d")
 32
 33let xga = _xget a
 34let _ =
 35  if xga <> (C_int 1) then
 36    raise (Failure ("Bad attribute value (xget a): " ^ (soci xga)))
 37
 38let ygb = _yget b
 39let _ =
 40  if ygb <> (C_int 2) then
 41    raise (Failure ("Bad attribute value (yget b): " ^
 42		    (string_of_int (get_int ygb))))
 43
 44let xgc = _xget c and ygc = _yget c and zgc = _zget c
 45let _ =
 46  if xgc <> (C_int 1) || ygc <> (C_int 2) || zgc <> (C_int 3) then
 47    raise (Failure ("Bad attribute value (xgc=" ^ (soci xgc) ^
 48		    " (sb 1) ygc=" ^ (soci ygc) ^
 49		    " (sb 2) zgc=" ^ (soci zgc) ^
 50		    " (sb 3))"))
 51
 52let xgd = _xget d and ygd = _yget d and zgd = _zget d and wgd = _wget d
 53let _ =
 54  if   xgd <> (C_int 1) || ygd <> (C_int 2) 
 55    || zgd <> (C_int 3) || wgd <> (C_int 4) then
 56      raise (Failure ("Bad attribute value (xgd=" ^ (soci xgd) ^
 57		      " (sb 1) ygd=" ^ (soci ygd) ^
 58		      " (sb 2) zgd=" ^ (soci zgd) ^
 59		      " (sb 3)"))
 60
 61(* Cleanse all of the pointers and see what happens *)
 62
 63let aa = _toFooPtr a
 64let bb = _toBarPtr b
 65let cc = _toFooBarPtr c
 66let dd = _toSpamPtr d
 67
 68let xgaa = (invoke aa) "xget" C_void
 69let _ =
 70  if xgaa <> (C_int 1) then
 71    raise (Failure ("Bad attribute value xgaa " ^ (soci xgaa)))
 72      
 73let ygbb = (invoke bb) "yget" C_void
 74let _ =
 75  if ygbb <> (C_int 2) then
 76    raise (Failure ("Bad attribute value ygbb " ^ (soci ygbb)))
 77      
 78let xgcc = (invoke cc) "xget" C_void
 79and ygcc = (invoke cc) "yget" C_void
 80and zgcc = (invoke cc) "zget" C_void
 81	     
 82let _ =
 83  if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then
 84    raise (Failure ("Bad attribute value (" ^
 85		    (soci xgcc) ^ " (sb 1) " ^
 86		    (soci ygcc) ^ " (sb 2) " ^
 87		    (soci zgcc) ^ " (sb 3))"))
 88
 89let xgdd = (invoke dd) "xget" C_void
 90and ygdd = (invoke dd) "yget" C_void
 91and zgdd = (invoke dd) "zget" C_void
 92and wgdd = (invoke dd) "wget" C_void
 93
 94let _ =
 95  if   xgdd <> (C_int 1) || ygdd <> (C_int 2)
 96    || zgdd <> (C_int 3) || wgdd <> (C_int 4) then
 97      raise (Failure ("Bad value: " ^
 98		      "xgdd=" ^ (soci xgdd) ^
 99		      "ygdd=" ^ (soci ygdd) ^
100		      "zgdd=" ^ (soci zgdd) ^
101		      "wgdd=" ^ (soci wgdd)))
102
103let xgaa = _xget aa
104and ygbb = _yget bb
105and xgcc = _xget cc
106and ygcc = _yget cc
107and zgcc = _zget cc
108and xgdd = _xget dd
109and ygdd = _yget dd
110and zgdd = _zget dd
111and wgdd = _wget dd
112
113let _ = 
114  if xgaa <> (C_int 1) then
115    raise (Failure ("Fn xget: xgaa=" ^ (soci xgaa)))
116
117let _ =
118  if ygbb <> (C_int 2) then
119    raise (Failure ("Fn yget: ygbb=" ^ (soci ygbb)))
120
121let _ =
122  if   xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then
123    raise (Failure ("CC with fns: (" ^ 
124		    (soci xgcc) ^ " " ^ (soci ygcc) ^ " " ^ (soci zgcc)))
125
126let _ =
127  if   xgdd <> (C_int 1) || ygdd <> (C_int 2) 
128    || zgdd <> (C_int 3) || wgdd <> (C_int 4) then
129    raise (Failure ("CC with fns: (" ^ 
130		    (soci xgdd) ^ " " ^ (soci ygdd) ^ " " ^ 
131		    (soci zgdd) ^ " " ^ (soci wgdd) ^ ")"))