aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-02-28 00:33:28 -0600
committerJesse Luehrs <doy@tozt.net>2013-02-28 00:33:28 -0600
commit561155bc9119c6b3836ea595a45d18a902d90ca2 (patch)
treede0c25540c1702748d2b670d7450901a6cc34dce
parentf6b4d8e24fb2db928697f680020b588c80d86d6a (diff)
downloadscala-test-more-561155bc9119c6b3836ea595a45d18a902d90ca2.tar.gz
scala-test-more-561155bc9119c6b3836ea595a45d18a902d90ca2.zip
make some more things private
-rw-r--r--src/main/scala/org/perl8/test/TestMore.scala8
-rw-r--r--src/main/scala/org/perl8/test/tap/TestBuilder.scala19
-rw-r--r--src/test/scala/org/perl8/test/tap/TestBuilderTest.scala26
3 files changed, 26 insertions, 27 deletions
diff --git a/src/main/scala/org/perl8/test/TestMore.scala b/src/main/scala/org/perl8/test/TestMore.scala
index 86a61d4..dc9c0ef 100644
--- a/src/main/scala/org/perl8/test/TestMore.scala
+++ b/src/main/scala/org/perl8/test/TestMore.scala
@@ -11,7 +11,7 @@ class TestMore (plan: Option[Plan] = None) extends Test with DelayedInit {
def delayedInit (body: => Unit) {
testBody = { terminalInUse =>
todo = NoMessage
- builder = new TestBuilder(plan, "", terminalInUse)
+ builder = new TestBuilder(plan, terminalInUse)
body
}
}
@@ -122,11 +122,7 @@ class TestMore (plan: Option[Plan] = None) extends Test with DelayedInit {
)(body: => Unit): Boolean = {
val oldBuilder = builder
val success = try {
- builder = new TestBuilder(
- plan,
- oldBuilder.indent + " ",
- oldBuilder.terminalInUse
- )
+ builder = oldBuilder.cloneForSubtest(plan)
body
builder.doneTesting
}
diff --git a/src/main/scala/org/perl8/test/tap/TestBuilder.scala b/src/main/scala/org/perl8/test/tap/TestBuilder.scala
index 17edccd..26fb5d6 100644
--- a/src/main/scala/org/perl8/test/tap/TestBuilder.scala
+++ b/src/main/scala/org/perl8/test/tap/TestBuilder.scala
@@ -2,18 +2,21 @@ package org.perl8.test.tap
import org.perl8.test._
-class TestBuilder (
- plan: Option[Plan],
- val indent: String,
- val terminalInUse: Boolean
+class TestBuilder private (
+ plan: Option[Plan],
+ indent: String,
+ terminalInUse: Boolean
) {
plan.foreach(p => outLine(Producer.plan(p)))
- def this (plan: Plan, indent: String = "", terminalInUse: Boolean = false) =
- this(Some(plan), indent, terminalInUse)
+ def this (plan: Option[Plan], terminalInUse: Boolean) =
+ this(plan, "", terminalInUse)
- def this (indent: String = "", terminalInUse: Boolean = false) =
- this(None, indent, terminalInUse)
+ def this (plan: Option[Plan]) =
+ this(plan, "", false)
+
+ def cloneForSubtest (newPlan: Option[Plan]): TestBuilder =
+ new TestBuilder(newPlan, indent + " ", terminalInUse)
def ok (
test: Boolean,
diff --git a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala
index 6aff4a1..56c1a98 100644
--- a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala
+++ b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala
@@ -9,7 +9,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder(4)
+ val builder = new TestBuilder(Some(4))
builder.ok(true, "test succeeded")
builder.ok(false, "test failed")
builder.ok(true)
@@ -33,7 +33,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(true, "test succeeded")
builder.ok(false, "test failed")
builder.ok(true)
@@ -57,7 +57,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.doneTesting
}
}
@@ -73,7 +73,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(true, "the test passes")
builder.ok(false, "the test passes")
builder.diag("got false, expected true")
@@ -104,7 +104,7 @@ class TestBuilderTest extends TestMore {
is(
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.doneTesting
}
},
@@ -114,7 +114,7 @@ class TestBuilderTest extends TestMore {
is(
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(true)
builder.doneTesting
}
@@ -125,7 +125,7 @@ class TestBuilderTest extends TestMore {
is(
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(true)
builder.ok(false)
builder.doneTesting
@@ -137,7 +137,7 @@ class TestBuilderTest extends TestMore {
is(
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(true)
builder.ok(false)
builder.ok(true)
@@ -154,7 +154,7 @@ class TestBuilderTest extends TestMore {
val oldErr = Console.err
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(true)
try {
builder.bailOut("oh no!")
@@ -190,7 +190,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder(SkipAll())
+ val builder = new TestBuilder(Some(SkipAll()))
}
}
@@ -204,7 +204,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder(SkipAll("foo bar"))
+ val builder = new TestBuilder(Some(SkipAll("foo bar")))
}
}
@@ -218,7 +218,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(false)
builder.skip("not now")
builder.skip()
@@ -240,7 +240,7 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
Console.withOut(output) {
Console.withErr(output) {
- val builder = new TestBuilder
+ val builder = new TestBuilder(None)
builder.ok(false, "do a thing", todo = "not working yet")
builder.ok(true, todo = "is it?")
builder.doneTesting