Skip to content

Instantly share code, notes, and snippets.

@motemen
Forked from cho45/TAP.scala
Created July 8, 2009 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motemen/143011 to your computer and use it in GitHub Desktop.
Save motemen/143011 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:Int) {
TAP.is(self, other, "")
}
def is (other:TestDescription) {
TAP.is(self, other.self, other.description)
}
}
class TestDescription (_self:Any) {
val self : Any = _self
var description : String = ""
def apply (desc:String) = {
description = desc
this
}
}
implicit def testobj (o:Any):TestObject = new TestObject(o)
implicit def testdesc (o:Any):TestDescription = new TestDescription(o)
TAP.plan(1)
TAP.is(1, 1, "foo")
1 is 1 ("Trivial")
TAP.todo("foobar") {
TAP.is(1, 1, "foo")
}
}
Main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment