Skip to content

Instantly share code, notes, and snippets.

@cho45
Created July 8, 2009 17:28
Show Gist options
  • Save cho45/142992 to your computer and use it in GitHub Desktop.
Save cho45/142992 to your computer and use it in GitHub Desktop.
object Main extends Application {
object TAP {
var number:Int = 1
var directive = ""
def plan (planNum:Int) {
println(
"1.." + planNum
)
}
def skip (desc:String)(block:() => Unit) {
directive = "SKIP " + desc
block()
directive = ""
}
def todo (desc:String)(block:() => Unit) {
directive = "TODO " + desc
block()
directive = ""
}
def ok (bool:Boolean, desc:String) {
println(
(if (bool) "ok" else "not ok") + " " + number +
(if (desc.isEmpty) "" else " - " + desc) +
(if (directive.isEmpty) "" else " # " + directive)
)
number += 1
}
def is (self:Any, other:Any, desc:String) {
ok(self == other, desc)
}
}
class TestObject (self:Any) {
def is (other:Any) {
TAP.is(self, other, "")
}
}
implicit def testobj (o:Any):TestObject = new TestObject(o)
TAP.plan(1)
TAP.is(1, 1, "foo")
1 is 1
TAP.todo("foobar") { () =>
TAP.is(1, 1, "foo")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment