Skip to content

Commit ce218cf

Browse files
authored
Merge pull request #5049 from rescript-lang/add_one_more_test
add one more test case
2 parents 1487bbb + e2e348e commit ce218cf

File tree

2 files changed

+112
-90
lines changed

2 files changed

+112
-90
lines changed

jscomp/ounit_tests/ounit_cmd_tests.ml

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let suites =
4343
ok (v_output.exit_code = 0) v_output
4444
end;
4545
__LOC__ >:: begin fun _ ->
46-
let v_output = perform_bsc [|"-bs-eval"; {|type 'a arra = 'a array
46+
let v_output = perform_bsc [|"-bs-eval"; {|type 'a arra = 'a array
4747
external
4848
f :
4949
int -> int -> int arra -> unit
@@ -52,8 +52,8 @@ let suites =
5252
[@@bs.splice]|}|] in
5353
OUnit.assert_bool __LOC__ (Ext_string.contain_substring v_output.stderr "variadic")
5454
end;
55-
__LOC__ >:: begin fun _ ->
56-
let v_output = perform_bsc [|"-bs-eval"; {|external
55+
__LOC__ >:: begin fun _ ->
56+
let v_output = perform_bsc [|"-bs-eval"; {|external
5757
f2 :
5858
int -> int -> ?y:int array -> unit
5959
= ""
@@ -69,13 +69,13 @@ let suites =
6969
OUnit.assert_bool __LOC__ (Ext_string.contain_substring
7070
should_be_warning.stderr "Unused")
7171
end;
72-
__LOC__ >:: begin fun _ ->
72+
__LOC__ >:: begin fun _ ->
7373
let should_be_warning =
7474
bsc_check_eval {| external mk : int -> ([`a|`b [@bs.string]]) = "mk" [@@bs.val] |} in
75-
OUnit.assert_bool __LOC__
75+
OUnit.assert_bool __LOC__
7676
(Ext_string.contain_substring
77-
should_be_warning.stderr "Unused")
78-
end;
77+
should_be_warning.stderr "Unused")
78+
end;
7979
__LOC__ >:: begin fun _ ->
8080
let should_err = bsc_check_eval {|
8181
external ff :
@@ -178,12 +178,12 @@ external ff :
178178
end;
179179

180180
(* __LOC__ >:: begin fun _ ->
181-
let should_err = bsc_check_eval {|
182-
external f : string -> unit -> unit = "x.y" [@@bs.send]
183-
|} in
184-
OUnit.assert_bool __LOC__
181+
let should_err = bsc_check_eval {|
182+
external f : string -> unit -> unit = "x.y" [@@bs.send]
183+
|} in
184+
OUnit.assert_bool __LOC__
185185
(Ext_string.contain_substring should_err.stderr "Not a valid method name")
186-
end; *)
186+
end; *)
187187

188188

189189
__LOC__ >:: begin fun _ ->
@@ -193,7 +193,7 @@ type t10 = A of t10 [@@ocaml.unboxed];;
193193
let rec x = A x;;
194194
|} in
195195
OUnit.assert_bool __LOC__
196-
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
196+
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
197197
end;
198198

199199
__LOC__ >:: begin fun _ ->
@@ -202,15 +202,15 @@ let rec x = A x;;
202202
let rec x = {x = y} and y = 3L;;
203203
|} in
204204
OUnit.assert_bool __LOC__
205-
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
205+
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
206206
end;
207207
__LOC__ >:: begin fun _ ->
208208
let should_err = bsc_check_eval {|
209209
type r = A of r [@@unboxed];;
210210
let rec y = A y;;
211211
|} in
212212
OUnit.assert_bool __LOC__
213-
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
213+
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
214214
end;
215215

216216
__LOC__ >:: begin fun _ ->
@@ -253,60 +253,71 @@ let rec y = A y;;
253253

254254
end;
255255
__LOC__ >:: begin fun _ ->
256-
let should_err = bsc_check_eval {|
256+
let should_err = bsc_check_eval {|
257257
external foo_bar :
258258
(_ [@bs.as "foo"]) ->
259259
string ->
260260
string = "bar"
261261
[@@bs.send]
262262
|} in
263-
OUnit.assert_bool __LOC__
264-
(Ext_string.contain_substring should_err.stderr "Ill defined attribute")
265-
end;
263+
OUnit.assert_bool __LOC__
264+
(Ext_string.contain_substring should_err.stderr "Ill defined attribute")
265+
end;
266266
__LOC__ >:: begin fun _ ->
267-
let should_err = bsc_check_eval {|
267+
let should_err = bsc_check_eval {|
268268
let bla4 foo x y = foo##(method1 x y [@bs])
269269
|} in
270-
(* Ounit_cmd_util.debug_output should_err ; *)
271-
OUnit.assert_bool __LOC__
272-
(Ext_string.contain_substring should_err.stderr
273-
"Unused")
274-
end;
270+
(* Ounit_cmd_util.debug_output should_err ; *)
271+
OUnit.assert_bool __LOC__
272+
(Ext_string.contain_substring should_err.stderr
273+
"Unused")
274+
end;
275275
__LOC__ >:: begin fun _ ->
276-
let should_err = bsc_check_eval {|
276+
let should_err = bsc_check_eval {|
277277
external mk : int ->
278278
(
279279
[`a|`b]
280280
[@bs.string]
281281
) = "mk" [@@bs.val]
282282
|} in
283-
(* Ounit_cmd_util.debug_output should_err ; *)
284-
OUnit.assert_bool __LOC__
285-
(Ext_string.contain_substring should_err.stderr
286-
"Unused")
287-
end;
288-
__LOC__ >:: begin fun _ ->
289-
let should_err = bsc_check_eval {|
283+
(* Ounit_cmd_util.debug_output should_err ; *)
284+
OUnit.assert_bool __LOC__
285+
(Ext_string.contain_substring should_err.stderr
286+
"Unused")
287+
end;
288+
__LOC__ >:: begin fun _ ->
289+
let should_err = bsc_check_eval {|
290290
type -'a t = {k : 'a } [@@bs.deriving abstract]
291291
|} in
292-
OUnit.assert_bool __LOC__
293-
(Ext_string.contain_substring should_err.stderr "contravariant")
294-
end;
295-
__LOC__ >:: begin fun _ ->
296-
let should_err = bsc_check_eval {|
292+
OUnit.assert_bool __LOC__
293+
(Ext_string.contain_substring should_err.stderr "contravariant")
294+
end;
295+
__LOC__ >:: begin fun _ ->
296+
let should_err = bsc_check_eval {|
297297
let u = [||]
298298
|} in
299-
OUnit.assert_bool __LOC__
300-
(Ext_string.contain_substring should_err.stderr "cannot be generalized")
301-
end
299+
OUnit.assert_bool __LOC__
300+
(Ext_string.contain_substring should_err.stderr "cannot be generalized")
301+
end;
302+
__LOC__ >:: begin fun _ ->
303+
let should_err = bsc_check_eval {|
304+
external push : 'a array -> 'a -> unit = "push" [@@send]
305+
let a = [||]
306+
let () =
307+
push a 3 |. ignore ;
308+
push a "3" |. ignore
309+
|} in
310+
OUnit.assert_bool __LOC__
311+
(Ext_string.contain_substring should_err.stderr "has type string")
312+
end
302313
(* __LOC__ >:: begin fun _ -> *)
303314
(* let should_infer = perform_bsc [| "-i"; "-bs-eval"|] {| *)
304-
(* let f = fun [@bs] x -> let (a,b) = x in a + b *)
305-
(* |} in *)
315+
(* let f = fun [@bs] x -> let (a,b) = x in a + b *)
316+
(* |} in *)
306317
(* let infer_type = bsc_eval (Printf.sprintf {| *)
307318

308-
(* let f : %s = fun [@bs] x -> let (a,b) = x in a + b *)
309-
(* |} should_infer.stdout ) in *)
319+
(* let f : %s = fun [@bs] x -> let (a,b) = x in a + b *)
320+
(* |} should_infer.stdout ) in *)
310321
(* begin *)
311322
(* Ounit_cmd_util.debug_output should_infer ; *)
312323
(* Ounit_cmd_util.debug_output infer_type ; *)

lib/4.06.1/unstable/all_ounit_tests.ml

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8126,7 +8126,7 @@ let suites =
81268126
ok (v_output.exit_code = 0) v_output
81278127
end;
81288128
__LOC__ >:: begin fun _ ->
8129-
let v_output = perform_bsc [|"-bs-eval"; {|type 'a arra = 'a array
8129+
let v_output = perform_bsc [|"-bs-eval"; {|type 'a arra = 'a array
81308130
external
81318131
f :
81328132
int -> int -> int arra -> unit
@@ -8135,8 +8135,8 @@ let suites =
81358135
[@@bs.splice]|}|] in
81368136
OUnit.assert_bool __LOC__ (Ext_string.contain_substring v_output.stderr "variadic")
81378137
end;
8138-
__LOC__ >:: begin fun _ ->
8139-
let v_output = perform_bsc [|"-bs-eval"; {|external
8138+
__LOC__ >:: begin fun _ ->
8139+
let v_output = perform_bsc [|"-bs-eval"; {|external
81408140
f2 :
81418141
int -> int -> ?y:int array -> unit
81428142
= ""
@@ -8152,13 +8152,13 @@ let suites =
81528152
OUnit.assert_bool __LOC__ (Ext_string.contain_substring
81538153
should_be_warning.stderr "Unused")
81548154
end;
8155-
__LOC__ >:: begin fun _ ->
8155+
__LOC__ >:: begin fun _ ->
81568156
let should_be_warning =
81578157
bsc_check_eval {| external mk : int -> ([`a|`b [@bs.string]]) = "mk" [@@bs.val] |} in
8158-
OUnit.assert_bool __LOC__
8158+
OUnit.assert_bool __LOC__
81598159
(Ext_string.contain_substring
8160-
should_be_warning.stderr "Unused")
8161-
end;
8160+
should_be_warning.stderr "Unused")
8161+
end;
81628162
__LOC__ >:: begin fun _ ->
81638163
let should_err = bsc_check_eval {|
81648164
external ff :
@@ -8261,12 +8261,12 @@ external ff :
82618261
end;
82628262

82638263
(* __LOC__ >:: begin fun _ ->
8264-
let should_err = bsc_check_eval {|
8265-
external f : string -> unit -> unit = "x.y" [@@bs.send]
8266-
|} in
8267-
OUnit.assert_bool __LOC__
8264+
let should_err = bsc_check_eval {|
8265+
external f : string -> unit -> unit = "x.y" [@@bs.send]
8266+
|} in
8267+
OUnit.assert_bool __LOC__
82688268
(Ext_string.contain_substring should_err.stderr "Not a valid method name")
8269-
end; *)
8269+
end; *)
82708270

82718271

82728272
__LOC__ >:: begin fun _ ->
@@ -8276,7 +8276,7 @@ type t10 = A of t10 [@@ocaml.unboxed];;
82768276
let rec x = A x;;
82778277
|} in
82788278
OUnit.assert_bool __LOC__
8279-
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
8279+
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
82808280
end;
82818281

82828282
__LOC__ >:: begin fun _ ->
@@ -8285,15 +8285,15 @@ let rec x = A x;;
82858285
let rec x = {x = y} and y = 3L;;
82868286
|} in
82878287
OUnit.assert_bool __LOC__
8288-
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
8288+
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
82898289
end;
82908290
__LOC__ >:: begin fun _ ->
82918291
let should_err = bsc_check_eval {|
82928292
type r = A of r [@@unboxed];;
82938293
let rec y = A y;;
82948294
|} in
82958295
OUnit.assert_bool __LOC__
8296-
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
8296+
(Ext_string.contain_substring should_err.stderr "This kind of expression is not allowed")
82978297
end;
82988298

82998299
__LOC__ >:: begin fun _ ->
@@ -8336,60 +8336,71 @@ let rec y = A y;;
83368336

83378337
end;
83388338
__LOC__ >:: begin fun _ ->
8339-
let should_err = bsc_check_eval {|
8339+
let should_err = bsc_check_eval {|
83408340
external foo_bar :
83418341
(_ [@bs.as "foo"]) ->
83428342
string ->
83438343
string = "bar"
83448344
[@@bs.send]
83458345
|} in
8346-
OUnit.assert_bool __LOC__
8347-
(Ext_string.contain_substring should_err.stderr "Ill defined attribute")
8348-
end;
8346+
OUnit.assert_bool __LOC__
8347+
(Ext_string.contain_substring should_err.stderr "Ill defined attribute")
8348+
end;
83498349
__LOC__ >:: begin fun _ ->
8350-
let should_err = bsc_check_eval {|
8350+
let should_err = bsc_check_eval {|
83518351
let bla4 foo x y = foo##(method1 x y [@bs])
83528352
|} in
8353-
(* Ounit_cmd_util.debug_output should_err ; *)
8354-
OUnit.assert_bool __LOC__
8355-
(Ext_string.contain_substring should_err.stderr
8356-
"Unused")
8357-
end;
8353+
(* Ounit_cmd_util.debug_output should_err ; *)
8354+
OUnit.assert_bool __LOC__
8355+
(Ext_string.contain_substring should_err.stderr
8356+
"Unused")
8357+
end;
83588358
__LOC__ >:: begin fun _ ->
8359-
let should_err = bsc_check_eval {|
8359+
let should_err = bsc_check_eval {|
83608360
external mk : int ->
83618361
(
83628362
[`a|`b]
83638363
[@bs.string]
83648364
) = "mk" [@@bs.val]
83658365
|} in
8366-
(* Ounit_cmd_util.debug_output should_err ; *)
8367-
OUnit.assert_bool __LOC__
8368-
(Ext_string.contain_substring should_err.stderr
8369-
"Unused")
8370-
end;
8371-
__LOC__ >:: begin fun _ ->
8372-
let should_err = bsc_check_eval {|
8366+
(* Ounit_cmd_util.debug_output should_err ; *)
8367+
OUnit.assert_bool __LOC__
8368+
(Ext_string.contain_substring should_err.stderr
8369+
"Unused")
8370+
end;
8371+
__LOC__ >:: begin fun _ ->
8372+
let should_err = bsc_check_eval {|
83738373
type -'a t = {k : 'a } [@@bs.deriving abstract]
83748374
|} in
8375-
OUnit.assert_bool __LOC__
8376-
(Ext_string.contain_substring should_err.stderr "contravariant")
8377-
end;
8378-
__LOC__ >:: begin fun _ ->
8379-
let should_err = bsc_check_eval {|
8375+
OUnit.assert_bool __LOC__
8376+
(Ext_string.contain_substring should_err.stderr "contravariant")
8377+
end;
8378+
__LOC__ >:: begin fun _ ->
8379+
let should_err = bsc_check_eval {|
83808380
let u = [||]
83818381
|} in
8382-
OUnit.assert_bool __LOC__
8383-
(Ext_string.contain_substring should_err.stderr "cannot be generalized")
8384-
end
8382+
OUnit.assert_bool __LOC__
8383+
(Ext_string.contain_substring should_err.stderr "cannot be generalized")
8384+
end;
8385+
__LOC__ >:: begin fun _ ->
8386+
let should_err = bsc_check_eval {|
8387+
external push : 'a array -> 'a -> unit = "push" [@@send]
8388+
let a = [||]
8389+
let () =
8390+
push a 3 |. ignore ;
8391+
push a "3" |. ignore
8392+
|} in
8393+
OUnit.assert_bool __LOC__
8394+
(Ext_string.contain_substring should_err.stderr "has type string")
8395+
end
83858396
(* __LOC__ >:: begin fun _ -> *)
83868397
(* let should_infer = perform_bsc [| "-i"; "-bs-eval"|] {| *)
8387-
(* let f = fun [@bs] x -> let (a,b) = x in a + b *)
8388-
(* |} in *)
8398+
(* let f = fun [@bs] x -> let (a,b) = x in a + b *)
8399+
(* |} in *)
83898400
(* let infer_type = bsc_eval (Printf.sprintf {| *)
83908401

8391-
(* let f : %s = fun [@bs] x -> let (a,b) = x in a + b *)
8392-
(* |} should_infer.stdout ) in *)
8402+
(* let f : %s = fun [@bs] x -> let (a,b) = x in a + b *)
8403+
(* |} should_infer.stdout ) in *)
83938404
(* begin *)
83948405
(* Ounit_cmd_util.debug_output should_infer ; *)
83958406
(* Ounit_cmd_util.debug_output infer_type ; *)

0 commit comments

Comments
 (0)