I am creating a parallel unit test runner using MailBoxProcessor.
I need to queue print statements for the test, so I can print them after the test completes. I know how to send a string and create a list so that I can print them, but it forces me to use sprintf and pass it to my print function and is not as clean as I would like.
[1..200] |> List.iter (fun i -> sprintf "Test %i" i &&& fun ctx -> ctx.printfn <| sprintf "A guid %A" (ng()) ctx.printfn <| sprintf "I am test %i" i ctx.printfn <| sprintf "A guid %A" (ng()))
Here you can see the full code: https://github.com/lefthandedgoat/prunner/blob/master/Program.fs#L36-L41
And look that ctx is an object with the printfn method that takes a string and sends it to a single mailbox, which queues messages until tests are completed, then crosses them out and prints them.
My goal is to look like this: ctx.printfn
[1..200] |> List.iter (fun i -> sprintf "Test %i" i &&& fun ctx -> ctx.printfn "A guid %A" (ng()) ctx.printfn "I am test %i" i ctx.printfn "A guid %A" (ng()))
source share