From c6453d42ea988dcea657c91a789f4f129152de22 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 1 Mar 2013 17:17:58 -0600 Subject: docs for Consumer --- src/main/scala/org/perl8/test/tap/Producer.scala | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/main/scala/org/perl8/test/tap/Producer.scala') diff --git a/src/main/scala/org/perl8/test/tap/Producer.scala b/src/main/scala/org/perl8/test/tap/Producer.scala index ae42fdc..21997ad 100644 --- a/src/main/scala/org/perl8/test/tap/Producer.scala +++ b/src/main/scala/org/perl8/test/tap/Producer.scala @@ -1,35 +1,78 @@ package org.perl8.test.tap +/** Contains functions for producing individual lines of TAP. + */ object Producer { import org.perl8.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. + * + * @example `ok 4 # skip` + */ def skip (num: Int): String = "ok " + num + " # skip" + /** 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 = skip(num) + " " + 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` ([[org.perl8.test.NumericPlan NumericPlan]]) + * @example `1..0 # SKIP don't run this test` ([[org.perl8.test.SkipAll SkipAll]]) + */ def plan (plan: Plan): String = plan.skipAll.map(m => "1..0 # SKIP " + m).getOrElse("1.." + plan.plan) + /** Returns a bail out. + * + * @example `Bail out!` + */ def bailOut: String = "Bail out!" + /** Returns a bail out with a reason. + * + * @example `Bail out! Not supported on this platform.` + */ def bailOut (message: String): String = "Bail out! " + message } -- cgit v1.2.3-54-g00ecf