PageRenderTime 58ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. (* Stolen from the python tests *)
  2. open Swig
  3. open Minherit
  4. let a = new_Foo C_void
  5. let b = new_Bar C_void
  6. let c = new_FooBar C_void
  7. let d = new_Spam C_void
  8. let soci x = (string_of_int (get_int x))
  9. let _ =
  10. if (invoke a) "xget" C_void <> (C_int 1) then
  11. raise (Failure "Bad attribute value (a.xget)")
  12. let _ =
  13. if (invoke b) "yget" C_void <> (C_int 2) then
  14. raise (Failure "Bad attribute value (b.yget)")
  15. let _ =
  16. if (invoke c) "xget" C_void <> (C_int 1)
  17. || (invoke c) "yget" C_void <> (C_int 2)
  18. || (invoke c) "zget" C_void <> (C_int 3) then
  19. raise (Failure "Bad attribute value c")
  20. let _ =
  21. if (invoke d) "xget" C_void <> (C_int 1)
  22. || (invoke d) "yget" C_void <> (C_int 2)
  23. || (invoke d) "zget" C_void <> (C_int 3)
  24. || (invoke d) "wget" C_void <> (C_int 4) then
  25. raise (Failure "Bad attribute value d")
  26. let xga = _xget a
  27. let _ =
  28. if xga <> (C_int 1) then
  29. raise (Failure ("Bad attribute value (xget a): " ^ (soci xga)))
  30. let ygb = _yget b
  31. let _ =
  32. if ygb <> (C_int 2) then
  33. raise (Failure ("Bad attribute value (yget b): " ^
  34. (string_of_int (get_int ygb))))
  35. let xgc = _xget c and ygc = _yget c and zgc = _zget c
  36. let _ =
  37. if xgc <> (C_int 1) || ygc <> (C_int 2) || zgc <> (C_int 3) then
  38. raise (Failure ("Bad attribute value (xgc=" ^ (soci xgc) ^
  39. " (sb 1) ygc=" ^ (soci ygc) ^
  40. " (sb 2) zgc=" ^ (soci zgc) ^
  41. " (sb 3))"))
  42. let xgd = _xget d and ygd = _yget d and zgd = _zget d and wgd = _wget d
  43. let _ =
  44. if xgd <> (C_int 1) || ygd <> (C_int 2)
  45. || zgd <> (C_int 3) || wgd <> (C_int 4) then
  46. raise (Failure ("Bad attribute value (xgd=" ^ (soci xgd) ^
  47. " (sb 1) ygd=" ^ (soci ygd) ^
  48. " (sb 2) zgd=" ^ (soci zgd) ^
  49. " (sb 3)"))
  50. (* Cleanse all of the pointers and see what happens *)
  51. let aa = _toFooPtr a
  52. let bb = _toBarPtr b
  53. let cc = _toFooBarPtr c
  54. let dd = _toSpamPtr d
  55. let xgaa = (invoke aa) "xget" C_void
  56. let _ =
  57. if xgaa <> (C_int 1) then
  58. raise (Failure ("Bad attribute value xgaa " ^ (soci xgaa)))
  59. let ygbb = (invoke bb) "yget" C_void
  60. let _ =
  61. if ygbb <> (C_int 2) then
  62. raise (Failure ("Bad attribute value ygbb " ^ (soci ygbb)))
  63. let xgcc = (invoke cc) "xget" C_void
  64. and ygcc = (invoke cc) "yget" C_void
  65. and zgcc = (invoke cc) "zget" C_void
  66. let _ =
  67. if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then
  68. raise (Failure ("Bad attribute value (" ^
  69. (soci xgcc) ^ " (sb 1) " ^
  70. (soci ygcc) ^ " (sb 2) " ^
  71. (soci zgcc) ^ " (sb 3))"))
  72. let xgdd = (invoke dd) "xget" C_void
  73. and ygdd = (invoke dd) "yget" C_void
  74. and zgdd = (invoke dd) "zget" C_void
  75. and wgdd = (invoke dd) "wget" C_void
  76. let _ =
  77. if xgdd <> (C_int 1) || ygdd <> (C_int 2)
  78. || zgdd <> (C_int 3) || wgdd <> (C_int 4) then
  79. raise (Failure ("Bad value: " ^
  80. "xgdd=" ^ (soci xgdd) ^
  81. "ygdd=" ^ (soci ygdd) ^
  82. "zgdd=" ^ (soci zgdd) ^
  83. "wgdd=" ^ (soci wgdd)))
  84. let xgaa = _xget aa
  85. and ygbb = _yget bb
  86. and xgcc = _xget cc
  87. and ygcc = _yget cc
  88. and zgcc = _zget cc
  89. and xgdd = _xget dd
  90. and ygdd = _yget dd
  91. and zgdd = _zget dd
  92. and wgdd = _wget dd
  93. let _ =
  94. if xgaa <> (C_int 1) then
  95. raise (Failure ("Fn xget: xgaa=" ^ (soci xgaa)))
  96. let _ =
  97. if ygbb <> (C_int 2) then
  98. raise (Failure ("Fn yget: ygbb=" ^ (soci ygbb)))
  99. let _ =
  100. if xgcc <> (C_int 1) || ygcc <> (C_int 2) || zgcc <> (C_int 3) then
  101. raise (Failure ("CC with fns: (" ^
  102. (soci xgcc) ^ " " ^ (soci ygcc) ^ " " ^ (soci zgcc)))
  103. let _ =
  104. if xgdd <> (C_int 1) || ygdd <> (C_int 2)
  105. || zgdd <> (C_int 3) || wgdd <> (C_int 4) then
  106. raise (Failure ("CC with fns: (" ^
  107. (soci xgdd) ^ " " ^ (soci ygdd) ^ " " ^
  108. (soci zgdd) ^ " " ^ (soci wgdd) ^ ")"))