38 lines
1.0 KiB
OCaml
38 lines
1.0 KiB
OCaml
let%expect_test _ =
|
|
let print_list print_ele xs =
|
|
let rec iter pre post = function
|
|
| [] -> print_string post
|
|
| x :: xs ->
|
|
print_string pre;
|
|
print_ele x;
|
|
iter ";" "]" xs
|
|
in
|
|
iter "[" "[]" xs
|
|
in
|
|
let print_ints_nl xs = print_list print_int xs; print_newline () in
|
|
|
|
let wh = Wheel.make 4 in
|
|
(* t=0 *)
|
|
Wheel.add wh 1 |> ignore;
|
|
Wheel.add wh 2 |> ignore;
|
|
Wheel.add wh 3 |> ignore;
|
|
(* t=1 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [] |}];
|
|
Wheel.add wh 4 |> ignore;
|
|
Wheel.add wh 5 |> ignore;
|
|
(* t=2 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [] |}];
|
|
Wheel.add wh 6 |> ignore;
|
|
(* t=3 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [] |}];
|
|
(* t=0 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [1;2;3] |}];
|
|
(* t=1 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [4;5] |}];
|
|
(* t=2 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [6] |}];
|
|
(* t=3 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [] |}];
|
|
(* t=0 *)
|
|
print_ints_nl (Wheel.tick wh); [%expect {| [] |}];
|