[OCaml] Fix dead code generation in overloaded function wrappers
The OCaml module was generating dead code in the wrappers for overloaded functions. Only the generated dispatch function needs to allocate an array for the passed arguments. In addition, add overload_extend, overload_rename and overload_subtype runtime tests.
This commit is contained in:
parent
00fbf09137
commit
fa1a0a378c
4 changed files with 26 additions and 11 deletions
11
Examples/test-suite/ocaml/overload_extend_runme.ml
Normal file
11
Examples/test-suite/ocaml/overload_extend_runme.ml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
open Swig
|
||||
open Overload_extend
|
||||
|
||||
let _ =
|
||||
let f = new_Foo '() in
|
||||
assert (f -> test () as int = 0);
|
||||
assert (f -> test (3) as int = 1);
|
||||
assert (f -> test ("hello") as int = 2);
|
||||
assert (f -> test (3., 2.) as float = 5.);
|
||||
assert (f -> test (3.) as float = 1003.)
|
||||
;;
|
||||
7
Examples/test-suite/ocaml/overload_rename_runme.ml
Normal file
7
Examples/test-suite/ocaml/overload_rename_runme.ml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
open Swig
|
||||
open Overload_rename
|
||||
|
||||
let _ = new_Foo (C_float 1.)
|
||||
let _ = new_Foo (C_list [ C_float 1. ; C_float 1. ])
|
||||
let _ = new_Foo_int (C_list [ C_float 1. ; C_int 1 ])
|
||||
let _ = new_Foo_int (C_list [ C_float 1. ; C_int 1 ; C_float 1. ])
|
||||
8
Examples/test-suite/ocaml/overload_subtype_runme.ml
Normal file
8
Examples/test-suite/ocaml/overload_subtype_runme.ml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
open Swig
|
||||
open Overload_subtype
|
||||
|
||||
let _ =
|
||||
let f = new_Foo '() and b = new_Bar '() in
|
||||
assert (_spam (f) as int = 1);
|
||||
assert (_spam (b) as int = 2)
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue