aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/scala/com/iinteractive/test/ExtensionTest.scala
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-03-06 15:32:26 -0600
committerJesse Luehrs <doy@tozt.net>2013-03-06 15:32:26 -0600
commit7efb2caf7d8832a7d3a9d2ac55862e43267a3eb2 (patch)
tree49fcb4d31bec67bcb67c1262abc25c5e5ecb1e51 /src/test/scala/com/iinteractive/test/ExtensionTest.scala
parent66bcf3627a38ef58dabaf90b7e597569b91ea3e8 (diff)
downloadscala-test-more-7efb2caf7d8832a7d3a9d2ac55862e43267a3eb2.tar.gz
scala-test-more-7efb2caf7d8832a7d3a9d2ac55862e43267a3eb2.zip
move the directory structure too
Diffstat (limited to 'src/test/scala/com/iinteractive/test/ExtensionTest.scala')
-rw-r--r--src/test/scala/com/iinteractive/test/ExtensionTest.scala57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/scala/com/iinteractive/test/ExtensionTest.scala b/src/test/scala/com/iinteractive/test/ExtensionTest.scala
new file mode 100644
index 0000000..5c49f21
--- /dev/null
+++ b/src/test/scala/com/iinteractive/test/ExtensionTest.scala
@@ -0,0 +1,57 @@
+package com.iinteractive.test
+
+import java.io.ByteArrayOutputStream
+
+import com.iinteractive.test.tap.Parser
+
+trait NumberZero { this: TestMore =>
+ def is_zero (i: Int, desc: String): Boolean = hideTestMethod {
+ is(i, 0, desc)
+ }
+}
+
+trait NumberZeroWrapped extends NumberZero { this: TestMore =>
+ def isZero (i: Int): Boolean = hideTestMethod {
+ is_zero(i, "the number is zero")
+ }
+}
+
+class ExtensionTest extends TestMore {
+ val lineZero = Thread.currentThread.getStackTrace()(1).getLineNumber + 3
+ def line (offset: Int) = lineZero + offset
+
+ private class ExtensionTestTest extends TestMore with NumberZeroWrapped {
+ is_zero(0, "it's zero")
+ is_zero(1, "it's not zero")
+ isZero(0)
+ isZero(1)
+ }
+
+ val out = new ByteArrayOutputStream
+ val exitCode = Console.withOut(out) {
+ Console.withErr(out) {
+ (new ExtensionTestTest).run
+ }
+ }
+
+ is((new Parser).parse(out).exitCode, 2)
+ is(exitCode, 2)
+
+ val tap =
+ "ok 1 - it's zero\n" +
+ "not ok 2 - it's not zero\n" +
+ "# Failed test 'it's not zero'\n" +
+ "# at ExtensionTest.scala line " + line(2) + ".\n" +
+ "# got: '1'\n" +
+ "# expected: '0'\n" +
+ "ok 3 - the number is zero\n" +
+ "not ok 4 - the number is zero\n" +
+ "# Failed test 'the number is zero'\n" +
+ "# at ExtensionTest.scala line " + line(4) + ".\n" +
+ "# got: '1'\n" +
+ "# expected: '0'\n" +
+ "1..4\n" +
+ "# Looks like you failed 2 tests of 4.\n"
+
+ is(out.toString, tap)
+}