aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/scala/org/perl8/test/tap/Producer.scala
blob: ae42fdcf04369b058396791924ac4b966462e25a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.perl8.test.tap

object Producer {
  import org.perl8.test.Plan

  def result (cond: Boolean, num: Int): String =
    (if (cond) "ok " else "not ok ") + num

  def result (cond: Boolean, num: Int, desc: String): String =
    result(cond, num) + " " + desc

  def todoResult (cond: Boolean, num: Int, todo: String): String =
    result(cond, num) + " # TODO " + todo

  def todoResult (cond: Boolean, num: Int, desc: String, todo: String): String =
    result(cond, num, desc) + " # TODO " + todo

  def skip (num: Int): String =
    "ok " + num + " # skip"

  def skip (num: Int, reason: String): String =
    skip(num) + " " + reason

  def comment (message: String): String =
    message.split("\n").map(m => "# " + m).mkString("\n")

  def plan (plan: Plan): String =
    plan.skipAll.map(m => "1..0 # SKIP " + m).getOrElse("1.." + plan.plan)

  def bailOut: String =
    "Bail out!"

  def bailOut (message: String): String =
    "Bail out!  " + message
}