Skip to content

Commit

Permalink
Test: Add a regression test for Std.oneof
Browse files Browse the repository at this point in the history
  • Loading branch information
saroupille committed May 3, 2024
1 parent 46049d6 commit 410d3e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/expected/std.ml/std oneof.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 1 2 4 5 5 5 6 7 7 8 9 9 10 103 124 124 134 135 135 160 161 161 175 1461 1913 4545 4684 4968 9349
22 changes: 21 additions & 1 deletion test/std.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,24 @@ let std_int_range_inclusive_bounds () =
if values = expected then Lwt.return_unit
else Test.fail "Did not draw all the integers in the interval"

let register () = std_int_range_inclusive_bounds ()
let std_oneof () =
Regression.register ~__FILE__ ~title:"std oneof" ~tags:["std"; "oneof"]
@@ fun () ->
let values =
Seq.ints 0 |> Seq.take 30
|> Seq.map (fun i ->
let small_gen = Bam.Std.int ~min:0 ~max:10 () in
let medium_gen = Bam.Std.int ~min:100 ~max:200 () in
let large_gen = Bam.Std.int ~min:1000 ~max:10_000 () in
let gen =
Bam.Std.oneof [(3, small_gen); (2, medium_gen); (1, large_gen)]
in
Bam.Gen.run gen (Bam.Gen.Random.make [|i|]) |> Bam.Tree.root )
|> List.of_seq |> List.sort compare
in
let str = values |> List.map string_of_int |> String.concat " " in
Regression.capture str ; Lwt.return_unit

let register () =
std_int_range_inclusive_bounds () ;
std_oneof ()

0 comments on commit 410d3e5

Please sign in to comment.