- (* If the call has optional args, fold them all together. We cannot
- * test partial optional args yet.
- *)
- let style =
- let ret, args, optargs = style in
- ret, args@optargs in
-
- if List.length (snd style) <> List.length args then
- failwithf "%s: in test, wrong number of args given to %s"
- test_name name;
+ (* Match up the arguments strings and argument types. *)
+ let args, optargs =
+ let rec loop argts args =
+ match argts, args with
+ | (t::ts), (s::ss) ->
+ let args, rest = loop ts ss in
+ ((t, s) :: args), rest
+ | [], ss -> [], ss
+ | ts, [] ->
+ failwithf "%s: in test, too few args given to function %s"
+ test_name name
+ in
+ let args, optargs = loop style_args args in
+ let optargs, rest = loop style_optargs optargs in
+ if rest <> [] then
+ failwithf "%s: in test, too many args given to function %s"
+ test_name name;
+ args, optargs in