-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathounit_ffi_error_debug_test.ml
78 lines (63 loc) · 2.11 KB
/
ounit_ffi_error_debug_test.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
let (//) = Filename.concat
let ((>::),
(>:::)) = OUnit.((>::),(>:::))
let (=~) = OUnit.assert_equal
let bsc_eval = Ounit_cmd_util.bsc_check_eval
let debug_output = Ounit_cmd_util.debug_output
let suites =
__FILE__
>::: [
__LOC__ >:: begin fun _ ->
let output = bsc_eval {|
external err :
hi_should_error:([`a of int | `b of string ] [@bs.string]) ->
unit -> _ = "" [@@bs.obj]
|} in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring output.stderr "hi_should_error")
end;
__LOC__ >:: begin fun _ ->
let output = bsc_eval {|
external err :
?hi_should_error:([`a of int | `b of string ] [@bs.string]) ->
unit -> _ = "" [@@bs.obj]
|} in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring output.stderr "hi_should_error")
end;
__LOC__ >:: begin fun _ ->
let output = bsc_eval {|
external err :
?hi_should_error:([`a of int | `b of string ] [@bs.string]) ->
unit -> unit = "err" [@@bs.val]
|} in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring output.stderr "hi_should_error")
end;
__LOC__ >:: begin fun _ ->
(**
Each [@bs.unwrap] variant constructor requires an argument
*)
let output =
bsc_eval {|
external err :
?hi_should_error:([`a of int | `b] [@bs.unwrap]) -> unit -> unit = "err" [@@bs.val]
|}
in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring output.stderr "bs.unwrap")
end;
__LOC__ >:: begin fun _ ->
(**
[@bs.unwrap] args are not supported in [@@bs.obj] functions
*)
let output =
bsc_eval {|
external err :
?hi_should_error:([`a of int] [@bs.unwrap]) -> unit -> _ = "" [@@bs.obj]
|}
in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring output.stderr "hi_should_error")
end
]