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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package com.iinteractive.test.tap
/** Contains functions for producing individual lines of TAP. */
object Producer {
import com.iinteractive.test.Plan
/** Returns a test result.
*
* @example `ok 4`
*/
def result (cond: Boolean, num: Int): String =
(if (cond) "ok " else "not ok ") + num
/** Returns a test result that contains a description.
*
* @example `ok 28 - our test succeeded`
*/
def result (cond: Boolean, num: Int, desc: String): String =
result(cond, num) + " " + desc
/** Returns a todo test result.
*
* @example `not ok 1 # TODO this doesn't work yet`
*/
def todoResult (cond: Boolean, num: Int, todo: String): String =
result(cond, num) + " # TODO " + todo
/** Returns a todo test result that contains a description.
*
* @example `not ok 18 - test the feature # TODO can't figure this out`
*/
def todoResult (cond: Boolean, num: Int, desc: String, todo: String): String =
result(cond, num, desc) + " # TODO " + todo
/** Returns a skipped test result with a reason.
*
* @example `ok 4 # skip this test won't run here`
*/
def skip (num: Int, reason: String): String =
"ok " + num + " # skip " + reason
/** Returns a comment.
*
* @example `# this is a comment`
*/
def comment (message: String): String =
message.split("\n").map(m => "# " + m).mkString("\n")
/** Returns a test plan.
*
* @example `1..5` ([[com.iinteractive.test.NumericPlan NumericPlan]])
* @example `1..0 # SKIP don't run this test` ([[com.iinteractive.test.SkipAll SkipAll]])
*/
def plan (plan: Plan): String =
plan.skipAll.map(m => "1..0 # SKIP " + m).getOrElse("1.." + plan.plan)
/** Returns a bail out with a reason.
*
* @example `Bail out! Not supported on this platform.`
*/
def bailOut (message: String): String =
"Bail out! " + message
}
|