aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-02-23 00:29:49 -0600
committerJesse Luehrs <doy@tozt.net>2013-02-23 00:29:49 -0600
commit779de1657856ea5bfc4ca6b364669bd4ab10127f (patch)
tree45310a9edb441c14788d11ce6c46c8a8df3c26e9 /src/test
parent2fe79825e81feba3c29a86e0912d9d5598c5975b (diff)
downloadscala-test-more-779de1657856ea5bfc4ca6b364669bd4ab10127f.tar.gz
scala-test-more-779de1657856ea5bfc4ca6b364669bd4ab10127f.zip
integrate with sbt
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/org/perl8/test/TestMoreTest.scala114
-rw-r--r--src/test/scala/org/perl8/test/TestMoreTestMore.scala138
2 files changed, 195 insertions, 57 deletions
diff --git a/src/test/scala/org/perl8/test/TestMoreTest.scala b/src/test/scala/org/perl8/test/TestMoreTest.scala
index e65b3e4..005691e 100644
--- a/src/test/scala/org/perl8/test/TestMoreTest.scala
+++ b/src/test/scala/org/perl8/test/TestMoreTest.scala
@@ -4,60 +4,60 @@ import org.scalatest.FunSuite
import java.io.ByteArrayOutputStream
-object OutputContainer {
- val output = new ByteArrayOutputStream
-}
-
-class MyBasicTest extends TestMore(OutputContainer.output) {
- diag("ok")
- ok(1 == 1, "it works!")
- ok(0 == 1, "it doesn't work!")
- ok(1 == 1)
- ok(0 == 1)
+class TestMoreTest extends FunSuite {
+ private object OutputContainer {
+ val output = new ByteArrayOutputStream
+ }
- diag("is")
- is(1, 1, "it works!")
- is(1, 0, "it doesn't work!")
- is(1, 1)
- is(1, 0)
+ private class MyBasicTest extends TestMore(OutputContainer.output) {
+ diag("ok")
+ ok(1 == 1, "it works!")
+ ok(0 == 1, "it doesn't work!")
+ ok(1 == 1)
+ ok(0 == 1)
- diag("isnt")
- isnt(1, 0, "it works!")
- isnt(1, 1, "it doesn't work!")
- isnt(1, 0)
- isnt(1, 1)
+ diag("is")
+ is(1, 1, "it works!")
+ is(1, 0, "it doesn't work!")
+ is(1, 1)
+ is(1, 0)
- diag("like")
- like("foo", """foo""".r, "it works!")
- like("foo", """bar""".r, "it doesn't work!")
- like("foo", """foo""".r)
- like("foo", """bar""".r)
+ diag("isnt")
+ isnt(1, 0, "it works!")
+ isnt(1, 1, "it doesn't work!")
+ isnt(1, 0)
+ isnt(1, 1)
- subtest("unlikes") {
- diag("unlike")
- unlike("foo", """bar""".r, "it works!")
- unlike("foo", """foo""".r, "it doesn't work!")
- unlike("foo", """bar""".r)
- unlike("foo", """foo""".r)
- }
+ diag("like")
+ like("foo", """foo""".r, "it works!")
+ like("foo", """bar""".r, "it doesn't work!")
+ like("foo", """foo""".r)
+ like("foo", """bar""".r)
- diag("pass")
- pass("it works!")
- pass()
+ subtest("unlikes") {
+ diag("unlike")
+ unlike("foo", """bar""".r, "it works!")
+ unlike("foo", """foo""".r, "it doesn't work!")
+ unlike("foo", """bar""".r)
+ unlike("foo", """foo""".r)
+ }
- skip(2, "don't do this yet") {
- pass("skipped")
+ diag("pass")
+ pass("it works!")
pass()
- }
- todo("not working yet") {
- diag("fail")
- fail("it doesn't work")
- fail()
+ skip(2, "don't do this yet") {
+ pass("skipped")
+ pass()
+ }
+
+ todo("not working yet") {
+ diag("fail")
+ fail("it doesn't work")
+ fail()
+ }
}
-}
-class TestMoreTest extends FunSuite {
test ("basic") {
assert((new MyBasicTest).run == 9)
@@ -66,63 +66,63 @@ class TestMoreTest extends FunSuite {
"ok 1 - it works!\n" +
"not ok 2 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 14.\n" +
+ "# at TestMoreTest.scala line 15.\n" +
"ok 3\n" +
"not ok 4\n" +
- "# Failed test at TestMoreTest.scala line 16.\n" +
+ "# Failed test at TestMoreTest.scala line 17.\n" +
"# is\n" +
"ok 5 - it works!\n" +
"not ok 6 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 20.\n" +
+ "# at TestMoreTest.scala line 21.\n" +
"# got: '1'\n" +
"# expected: '0'\n" +
"ok 7\n" +
"not ok 8\n" +
- "# Failed test at TestMoreTest.scala line 22.\n" +
+ "# Failed test at TestMoreTest.scala line 23.\n" +
"# got: '1'\n" +
"# expected: '0'\n" +
"# isnt\n" +
"ok 9 - it works!\n" +
"not ok 10 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 26.\n" +
+ "# at TestMoreTest.scala line 27.\n" +
"# got: '1'\n" +
"# expected: anything else\n" +
"ok 11\n" +
"not ok 12\n" +
- "# Failed test at TestMoreTest.scala line 28.\n" +
+ "# Failed test at TestMoreTest.scala line 29.\n" +
"# got: '1'\n" +
"# expected: anything else\n" +
"# like\n" +
"ok 13 - it works!\n" +
"not ok 14 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 32.\n" +
+ "# at TestMoreTest.scala line 33.\n" +
"# 'foo'\n" +
"# doesn't match 'bar'\n" +
"ok 15\n" +
"not ok 16\n" +
- "# Failed test at TestMoreTest.scala line 34.\n" +
+ "# Failed test at TestMoreTest.scala line 35.\n" +
"# 'foo'\n" +
"# doesn't match 'bar'\n" +
" # unlike\n" +
" ok 1 - it works!\n" +
" not ok 2 - it doesn't work!\n" +
" # Failed test 'it doesn't work!'\n" +
- " # at TestMoreTest.scala line 39.\n" +
+ " # at TestMoreTest.scala line 40.\n" +
" # 'foo'\n" +
" # matches 'foo'\n" +
" ok 3\n" +
" not ok 4\n" +
- " # Failed test at TestMoreTest.scala line 41.\n" +
+ " # Failed test at TestMoreTest.scala line 42.\n" +
" # 'foo'\n" +
" # matches 'foo'\n" +
" 1..4\n" +
" # Looks like you failed 2 tests of 4.\n" +
"not ok 17 - unlikes\n" +
"# Failed test 'unlikes'\n" +
- "# at TestMoreTest.scala line 36.\n" +
+ "# at TestMoreTest.scala line 37.\n" +
"# pass\n" +
"ok 18 - it works!\n" +
"ok 19\n" +
@@ -131,9 +131,9 @@ class TestMoreTest extends FunSuite {
"# fail\n" +
"not ok 22 - it doesn't work # TODO not working yet\n" +
"# Failed (TODO) test 'it doesn't work'\n" +
- "# at TestMoreTest.scala line 55.\n" +
+ "# at TestMoreTest.scala line 56.\n" +
"not ok 23 # TODO not working yet\n" +
- "# Failed (TODO) test at TestMoreTest.scala line 56.\n" +
+ "# Failed (TODO) test at TestMoreTest.scala line 57.\n" +
"1..23\n" +
"# Looks like you failed 9 tests of 23.\n"
diff --git a/src/test/scala/org/perl8/test/TestMoreTestMore.scala b/src/test/scala/org/perl8/test/TestMoreTestMore.scala
new file mode 100644
index 0000000..36d4037
--- /dev/null
+++ b/src/test/scala/org/perl8/test/TestMoreTestMore.scala
@@ -0,0 +1,138 @@
+package org.perl8.test
+
+import java.io.{OutputStream,ByteArrayOutputStream}
+
+class TestMoreTestMore (out: OutputStream) extends TestMore(out) {
+ private object OutputContainer {
+ val output = new ByteArrayOutputStream
+ }
+
+ private class MyBasicTest extends TestMore(OutputContainer.output) {
+ diag("ok")
+ ok(1 == 1, "it works!")
+ ok(0 == 1, "it doesn't work!")
+ ok(1 == 1)
+ ok(0 == 1)
+
+ diag("is")
+ is(1, 1, "it works!")
+ is(1, 0, "it doesn't work!")
+ is(1, 1)
+ is(1, 0)
+
+ diag("isnt")
+ isnt(1, 0, "it works!")
+ isnt(1, 1, "it doesn't work!")
+ isnt(1, 0)
+ isnt(1, 1)
+
+ diag("like")
+ like("foo", """foo""".r, "it works!")
+ like("foo", """bar""".r, "it doesn't work!")
+ like("foo", """foo""".r)
+ like("foo", """bar""".r)
+
+ subtest("unlikes") {
+ diag("unlike")
+ unlike("foo", """bar""".r, "it works!")
+ unlike("foo", """foo""".r, "it doesn't work!")
+ unlike("foo", """bar""".r)
+ unlike("foo", """foo""".r)
+ }
+
+ diag("pass")
+ pass("it works!")
+ pass()
+
+ skip(2, "don't do this yet") {
+ pass("skipped")
+ pass()
+ }
+
+ todo("not working yet") {
+ diag("fail")
+ fail("it doesn't work")
+ fail()
+ }
+ }
+
+ is((new MyBasicTest).run, 9, "got the right plan")
+
+ val expected =
+ "# ok\n" +
+ "ok 1 - it works!\n" +
+ "not ok 2 - it doesn't work!\n" +
+ "# Failed test 'it doesn't work!'\n" +
+ "# at TestMoreTestMore.scala line 13.\n" +
+ "ok 3\n" +
+ "not ok 4\n" +
+ "# Failed test at TestMoreTestMore.scala line 15.\n" +
+ "# is\n" +
+ "ok 5 - it works!\n" +
+ "not ok 6 - it doesn't work!\n" +
+ "# Failed test 'it doesn't work!'\n" +
+ "# at TestMoreTestMore.scala line 19.\n" +
+ "# got: '1'\n" +
+ "# expected: '0'\n" +
+ "ok 7\n" +
+ "not ok 8\n" +
+ "# Failed test at TestMoreTestMore.scala line 21.\n" +
+ "# got: '1'\n" +
+ "# expected: '0'\n" +
+ "# isnt\n" +
+ "ok 9 - it works!\n" +
+ "not ok 10 - it doesn't work!\n" +
+ "# Failed test 'it doesn't work!'\n" +
+ "# at TestMoreTestMore.scala line 25.\n" +
+ "# got: '1'\n" +
+ "# expected: anything else\n" +
+ "ok 11\n" +
+ "not ok 12\n" +
+ "# Failed test at TestMoreTestMore.scala line 27.\n" +
+ "# got: '1'\n" +
+ "# expected: anything else\n" +
+ "# like\n" +
+ "ok 13 - it works!\n" +
+ "not ok 14 - it doesn't work!\n" +
+ "# Failed test 'it doesn't work!'\n" +
+ "# at TestMoreTestMore.scala line 31.\n" +
+ "# 'foo'\n" +
+ "# doesn't match 'bar'\n" +
+ "ok 15\n" +
+ "not ok 16\n" +
+ "# Failed test at TestMoreTestMore.scala line 33.\n" +
+ "# 'foo'\n" +
+ "# doesn't match 'bar'\n" +
+ " # unlike\n" +
+ " ok 1 - it works!\n" +
+ " not ok 2 - it doesn't work!\n" +
+ " # Failed test 'it doesn't work!'\n" +
+ " # at TestMoreTestMore.scala line 38.\n" +
+ " # 'foo'\n" +
+ " # matches 'foo'\n" +
+ " ok 3\n" +
+ " not ok 4\n" +
+ " # Failed test at TestMoreTestMore.scala line 40.\n" +
+ " # 'foo'\n" +
+ " # matches 'foo'\n" +
+ " 1..4\n" +
+ " # Looks like you failed 2 tests of 4.\n" +
+ "not ok 17 - unlikes\n" +
+ "# Failed test 'unlikes'\n" +
+ "# at TestMoreTestMore.scala line 35.\n" +
+ "# pass\n" +
+ "ok 18 - it works!\n" +
+ "ok 19\n" +
+ "ok 20 # skip don't do this yet\n" +
+ "ok 21 # skip don't do this yet\n" +
+ "# fail\n" +
+ "not ok 22 - it doesn't work # TODO not working yet\n" +
+ "# Failed (TODO) test 'it doesn't work'\n" +
+ "# at TestMoreTestMore.scala line 54.\n" +
+ "not ok 23 # TODO not working yet\n" +
+ "# Failed (TODO) test at TestMoreTestMore.scala line 55.\n" +
+ "1..23\n" +
+ "# Looks like you failed 9 tests of 23.\n"
+
+ is(OutputContainer.output.toString, expected, "correct tap")
+}