You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found OUnit 2.2.6 changes the type of foutput option for assert_command. 9345a47
The sequence is created by seq_forever (same as Seq.forever for OCaml 4.14) which returns an infinite sequence.
The end of the sequence is notified by End_of_file exception raised by input_char.
It is different from OUnit 2.2.5 which creates a finite channel by Stream.of_channel.
The difference between "finite" and "infinite" causes us to need to catch End_of_file exception.
We can write as follows in OUnit 2.2.5.
open OUnit2
let test_foo (ctxt : test_ctxt) : unit =
assert_command
~foutput:(fun stream -> Stream.iter (fun ch -> ignore ch) stream)
~ctxt
"echo" ["foo"]
let () =
run_test_tt_main ("foo" >:: test_foo)
We need to rewrite it as follows with OUnit 2.2.6.
It needs try-with addition to modifying from Stream.iter to Seq.iter.
open OUnit2
let test_foo (ctxt : test_ctxt) : unit =
assert_command
~foutput:(fun seq -> try
Seq.iter (fun ch -> ignore ch) seq
with End_of_file ->
())
~ctxt
"echo" ["foo"]
let () =
run_test_tt_main ("foo" >:: test_foo)
I'm not sure why Stream.t is changed to Seq.t.
Even if Seq.t has a good reason,
I think it is better to catch End_of_file exception in OUnit and produce a finite sequence as OUnit 2.2.5.
The text was updated successfully, but these errors were encountered:
I still think that it is better to avoid End_of_file exception for foutput.
I'm happy if I can adapt newer OCaml and OUnit by just changing Stream.iter to Seq.iter without try-with.
I found OUnit 2.2.6 changes the type of foutput option for assert_command.
9345a47
The sequence is created by seq_forever (same as Seq.forever for OCaml 4.14) which returns an infinite sequence.
The end of the sequence is notified by End_of_file exception raised by input_char.
It is different from OUnit 2.2.5 which creates a finite channel by Stream.of_channel.
The difference between "finite" and "infinite" causes us to need to catch End_of_file exception.
We can write as follows in OUnit 2.2.5.
We need to rewrite it as follows with OUnit 2.2.6.
It needs try-with addition to modifying from Stream.iter to Seq.iter.
I'm not sure why Stream.t is changed to Seq.t.
Even if Seq.t has a good reason,
I think it is better to catch End_of_file exception in OUnit and produce a finite sequence as OUnit 2.2.5.
The text was updated successfully, but these errors were encountered: