Files
functional-programming-snake/fsharp/tests/M09Helpers.fs
T

20 lines
665 B
FSharp

/// Test helpers shared by the m09, m10 and m11 suites.
module Snake.Tests.M09Helpers
open Snake
open Snake.View
open Snake.IO
open Snake.Stream
/// The m09 program built from classicActions (ticks every 150 ms). The shipped `main` switches to speedActions in m10.
let classicMain () : IO<Stream<IO<unit>>> =
IO.randomSeed () |> IO.map (fun seed -> App.states seed App.classicActions |> Stream.map App.render)
/// The shapes an IO draws, in order (interpreted by `IO.trace`).
let drawn (io: IO<unit>) : Shape list =
(IO.trace 0u io).Ops
|> List.choose (fun op ->
match op with
| Draw shape -> Some shape
| RandomSeed -> None)