Created
August 3, 2009 14:37
-
-
Save aslakhellesoy/160587 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to combine this method declaration.... | |
def Given(name: String, body: Function2[Int, String, Unit]): Unit = { | |
body.apply(5, "belly") | |
} | |
// ...and this method declaration to one polymorphic declaration... | |
def Given(name: String, body: Function1[String, Unit]): Unit = { | |
body.apply("bob") | |
} | |
// ...that can be invoked like this... | |
Given("I have (\\d+) cukes in my (.*)", (cukes:Int, where:String) => { | |
println("You have " + cukes + " cukes in your " + where) | |
}) | |
// ...and this | |
Given("my name is (.*)", (name:String) => { | |
println("Your name is " + name) | |
}) | |
// Similar to this Groovy example: http://gist.github.com/160492 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment