2 people like it.

Minimal coding kata setup

Minimal coding kata setup that I use in my trainings - the aim is to use as simple F# syntax as possible and to have a nice way for specifying placeholders that attendees are required to fill.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
// Minimal setup for coding katas (I usually put this in "setup.fsx")
let __<'T> : 'T = failwith "Placeholder '__' was not filled!"
let shouldEqual a b = 
  if not (a = b) then 
    failwithf "Values are not equal!\n  Expected: %A\n  Received: %A" a b

// Sample tasks with placeholders and equality tests (#loads "setup.fsx")
let nums = 40 + __
shouldEqual nums 42
val failwith : message:string -> 'T

Full name: Microsoft.FSharp.Core.Operators.failwith
val shouldEqual : a:'a -> b:'a -> unit (requires equality)

Full name: Script.shouldEqual
val a : 'a (requires equality)
val b : 'a (requires equality)
val not : value:bool -> bool

Full name: Microsoft.FSharp.Core.Operators.not
val failwithf : format:Printf.StringFormat<'T,'Result> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.failwithf
val nums : int

Full name: Script.nums
val __<'T> : 'T

Full name: Script.__
Raw view Test code New version

More information

Link:http://fssnip.net/t5
Posted:8 years ago
Author:Tomas Petricek
Tags: kata , teaching