[OCaml] Fix some of the OCaml examples
Update some of the OCaml examples so that they run successfully with `make check-ocaml-examples` (important for the CI). Some of the examples were written to depend on passed arguments. Temporarily disable the broken std_string example.
This commit is contained in:
parent
539d145b96
commit
1be9f5fec3
5 changed files with 12 additions and 14 deletions
|
|
@ -5,17 +5,8 @@ open Example
|
||||||
|
|
||||||
exception BadReturn
|
exception BadReturn
|
||||||
|
|
||||||
let _ = if Array.length Sys.argv < 3 then
|
let x = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 16
|
||||||
begin
|
let y = if Array.length Sys.argv > 2 then int_of_string Sys.argv.(2) else 12
|
||||||
print_endline
|
|
||||||
("Usage: " ^ Sys.argv.(0) ^ " n1 n2\n" ^
|
|
||||||
" Displays the least factors of the numbers that have the same\n" ^
|
|
||||||
" relationship, 16 12 -> 4 3\n") ;
|
|
||||||
exit 0
|
|
||||||
end
|
|
||||||
|
|
||||||
let x = int_of_string Sys.argv.(1)
|
|
||||||
let y = int_of_string Sys.argv.(2)
|
|
||||||
let (xf,yf) = match _factor '((x to int),(y to int)) with
|
let (xf,yf) = match _factor '((x to int),(y to int)) with
|
||||||
C_list [ C_int a ; C_int b ] -> a,b
|
C_list [ C_int a ; C_int b ] -> a,b
|
||||||
| _ -> raise BadReturn
|
| _ -> raise BadReturn
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# see top-level Makefile.in
|
# see top-level Makefile.in
|
||||||
simple
|
simple
|
||||||
std_string
|
#std_string
|
||||||
std_vector
|
std_vector
|
||||||
stl
|
stl
|
||||||
argout_ref
|
argout_ref
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,9 @@ open Example
|
||||||
let _ = print_endline "This won't throw."
|
let _ = print_endline "This won't throw."
|
||||||
let _ = Printf.printf "Cos 1.0 is %f\n" (_cos '(1.0) as float)
|
let _ = Printf.printf "Cos 1.0 is %f\n" (_cos '(1.0) as float)
|
||||||
let _ = print_endline "This will throw."
|
let _ = print_endline "This will throw."
|
||||||
let _ = Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float)
|
let _ =
|
||||||
|
try
|
||||||
|
Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float)
|
||||||
|
with Failure s ->
|
||||||
|
print_endline s ;
|
||||||
|
print_endline "Exception thrown."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
open Swig
|
open Swig
|
||||||
open Example
|
open Example
|
||||||
|
|
||||||
let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2)
|
let arg = if Array.length Sys.argv > 1 then Sys.argv.(1) else "Tag1"
|
||||||
|
let _ = _f (match arg with "Tag1" -> ``Tag1 | _ -> ``Tag2)
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,5 @@ using std::string;
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%include "std_string.i"
|
||||||
%include example.h
|
%include example.h
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue