aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-02-20 10:24:27 -0600
committerJesse Luehrs <doy@tozt.net>2013-02-20 10:24:27 -0600
commit29b02e36cf3206a0728b44a068717fbbd38d2f20 (patch)
tree71214dcaf4a56d47252baa8d135f679bc7374756 /src
parentf3c81a12abb34203e75e4ca8f4a06072f6be782f (diff)
downloadscala-test-more-29b02e36cf3206a0728b44a068717fbbd38d2f20.tar.gz
scala-test-more-29b02e36cf3206a0728b44a068717fbbd38d2f20.zip
implement todo
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/testbuilder.scala14
-rw-r--r--src/main/scala/testbuilder/tap.scala13
-rw-r--r--src/test/scala/basic.scala16
3 files changed, 38 insertions, 5 deletions
diff --git a/src/main/scala/testbuilder.scala b/src/main/scala/testbuilder.scala
index 940e70a..15951cd 100644
--- a/src/main/scala/testbuilder.scala
+++ b/src/main/scala/testbuilder.scala
@@ -13,13 +13,21 @@ class Builder (plan: Option[Plan], out: OutputStream) {
def this (out: OutputStream = System.out) =
this(None, out)
+ def ok (test: Boolean, description: String, todo: String) {
+ ok(test, Some(description), Some(todo))
+ }
+
def ok (test: Boolean, description: String) {
ok(test, Some(description))
}
- def ok (test: Boolean, description: Option[String] = None) {
- val line = tap.result(test, state.currentTest, description)
- state.ok(test)
+ def ok (
+ test: Boolean,
+ description: Option[String] = None,
+ todo: Option[String] = None
+ ) {
+ val line = tap.result(test, state.currentTest, description, todo)
+ state.ok(test || todo.isDefined)
println(line)
}
diff --git a/src/main/scala/testbuilder/tap.scala b/src/main/scala/testbuilder/tap.scala
index 10e00b3..5ea5b83 100644
--- a/src/main/scala/testbuilder/tap.scala
+++ b/src/main/scala/testbuilder/tap.scala
@@ -3,15 +3,24 @@ package testbuilder
import util._
object tap {
+ def result (cond: Boolean, num: Int, desc: String, todo: String): String =
+ result(cond, num, Some(desc), Some(todo))
+
def result (cond: Boolean, num: Int, desc: String): String =
result(cond, num, Some(desc))
- def result (cond: Boolean, num: Int, desc: Option[String] = None): String =
+ def result (
+ cond: Boolean,
+ num: Int,
+ desc: Option[String] = None,
+ todo: Option[String] = None
+ ): String =
join(
(if (!cond) Some("not") else None),
Some("ok"),
Some(num),
- desc
+ desc,
+ todo.map(t => "# TODO " + t)
)
def skip (num: Int, reason: String): String =
diff --git a/src/test/scala/basic.scala b/src/test/scala/basic.scala
index 81971ed..0294a3a 100644
--- a/src/test/scala/basic.scala
+++ b/src/test/scala/basic.scala
@@ -146,4 +146,20 @@ class Basic extends FunSuite {
assert(output.toString === expected)
}
+
+ test ("todo") {
+ val output = new ByteArrayOutputStream
+ val builder = new Builder(output)
+
+ builder.ok(false, "do a thing", "not working yet")
+ builder.ok(true, "some other thing", "is it?")
+ builder.doneTesting
+
+ val expected =
+ "not ok 1 do a thing # TODO not working yet\n" +
+ "ok 2 some other thing # TODO is it?\n" +
+ "1..2\n"
+
+ assert(output.toString === expected)
+ }
}