From 22a7e25c0bca5f08d9d8c9df8793238750d091a3 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 21 Feb 2013 12:15:02 -0600 Subject: move more things around --- src/test/scala/org/perl8/test/TestMoreTest.scala | 142 +++++++++++++++++ .../scala/org/perl8/test/tap/TestBuilderTest.scala | 169 +++++++++++++++++++++ .../org/perl8/test/tests/testbuilder/basic.scala | 167 -------------------- .../org/perl8/test/tests/testmore/basic.scala | 144 ------------------ 4 files changed, 311 insertions(+), 311 deletions(-) create mode 100644 src/test/scala/org/perl8/test/TestMoreTest.scala create mode 100644 src/test/scala/org/perl8/test/tap/TestBuilderTest.scala delete mode 100644 src/test/scala/org/perl8/test/tests/testbuilder/basic.scala delete mode 100644 src/test/scala/org/perl8/test/tests/testmore/basic.scala (limited to 'src/test') diff --git a/src/test/scala/org/perl8/test/TestMoreTest.scala b/src/test/scala/org/perl8/test/TestMoreTest.scala new file mode 100644 index 0000000..e65b3e4 --- /dev/null +++ b/src/test/scala/org/perl8/test/TestMoreTest.scala @@ -0,0 +1,142 @@ +package org.perl8.test + +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) + + 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() + } +} + +class TestMoreTest extends FunSuite { + test ("basic") { + assert((new MyBasicTest).run == 9) + + 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 TestMoreTest.scala line 14.\n" + + "ok 3\n" + + "not ok 4\n" + + "# Failed test at TestMoreTest.scala line 16.\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" + + "# got: '1'\n" + + "# expected: '0'\n" + + "ok 7\n" + + "not ok 8\n" + + "# Failed test at TestMoreTest.scala line 22.\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" + + "# got: '1'\n" + + "# expected: anything else\n" + + "ok 11\n" + + "not ok 12\n" + + "# Failed test at TestMoreTest.scala line 28.\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" + + "# 'foo'\n" + + "# doesn't match 'bar'\n" + + "ok 15\n" + + "not ok 16\n" + + "# Failed test at TestMoreTest.scala line 34.\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" + + " # 'foo'\n" + + " # matches 'foo'\n" + + " ok 3\n" + + " not ok 4\n" + + " # Failed test at TestMoreTest.scala line 41.\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" + + "# 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 TestMoreTest.scala line 55.\n" + + "not ok 23 # TODO not working yet\n" + + "# Failed (TODO) test at TestMoreTest.scala line 56.\n" + + "1..23\n" + + "# Looks like you failed 9 tests of 23.\n" + + assert(OutputContainer.output.toString === expected) + } +} diff --git a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala new file mode 100644 index 0000000..e68cf47 --- /dev/null +++ b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala @@ -0,0 +1,169 @@ +package org.perl8.test + +import org.scalatest.FunSuite +import org.scalatest.BeforeAndAfter + +import org.perl8.test.tap.TestBuilder +import org.perl8.test.BailOutException +import org.perl8.test.SkipAll + +import java.io.ByteArrayOutputStream + +class TestBuilderTest extends FunSuite with BeforeAndAfter { + private val output = new ByteArrayOutputStream + + before { + output.reset + } + + test ("ok") { + val builder = new TestBuilder(4, output) + builder.ok(true, "test succeeded") + builder.ok(false, "test failed") + builder.ok(true) + builder.ok(false) + builder.doneTesting + + val expected = + "1..4\n" + + "ok 1 test succeeded\n" + + "not ok 2 test failed\n" + + "ok 3\n" + + "not ok 4\n" + + "# Looks like you failed 2 tests of 4.\n" + + assert(output.toString === expected) + } + + test ("no plan") { + val builder = new TestBuilder(output) + builder.ok(true, "test succeeded") + builder.ok(false, "test failed") + builder.ok(true) + builder.ok(false) + builder.doneTesting + + val expected = + "ok 1 test succeeded\n" + + "not ok 2 test failed\n" + + "ok 3\n" + + "not ok 4\n" + + "1..4\n" + + "# Looks like you failed 2 tests of 4.\n" + + assert(output.toString === expected) + } + + test ("empty") { + val builder = new TestBuilder(output) + builder.doneTesting + + val expected = + "1..0\n" + + "# No tests run!\n" + + assert(output.toString === expected) + } + + test ("diag") { + val builder = new TestBuilder(output) + + builder.ok(true, "the test passes") + builder.ok(false, "the test passes") + builder.diag("got false, expected true") + builder.ok(true) + builder.diag("ending\nnow") + builder.doneTesting + + val expected = + "ok 1 the test passes\n" + + "not ok 2 the test passes\n" + + "# got false, expected true\n" + + "ok 3\n" + + "# ending\n" + + "# now\n" + + "1..3\n" + + "# Looks like you failed 1 test of 3.\n" + + assert(output.toString === expected) + } + + test ("is passing") { + val builder = new TestBuilder(output) + + assert(!builder.isPassing) + builder.ok(true) + assert(builder.isPassing) + builder.ok(false) + assert(!builder.isPassing) + builder.ok(true) + assert(!builder.isPassing) + } + + test ("bail out") { + val builder = new TestBuilder(output) + + builder.ok(true) + val e = intercept[BailOutException] { + builder.bailOut("oh no!") + } + assert(e.message === "oh no!") + + val expected = + "ok 1\n" + + "Bail out! oh no!\n" + + assert(output.toString === expected) + } + + test ("skip all") { + val builder = new TestBuilder(SkipAll(), output) + + val expected = + "1..0 # SKIP\n" + + assert(output.toString === expected) + } + + test ("skip all with reason") { + val builder = new TestBuilder(SkipAll("foo bar"), output) + + val expected = + "1..0 # SKIP foo bar\n" + + assert(output.toString === expected) + } + + test ("skip") { + val builder = new TestBuilder(output) + + builder.ok(false) + builder.skip("not now") + builder.skip() + builder.doneTesting + + val expected = + "not ok 1\n" + + "ok 2 # skip not now\n" + + "ok 3 # skip\n" + + "1..3\n" + + "# Looks like you failed 1 test of 3.\n" + + assert(output.toString === expected) + } + + test ("todo") { + val builder = new TestBuilder(output) + + builder.ok(false, "do a thing", todo = "not working yet") + builder.ok(true, todo = "is it?") + builder.doneTesting + + val expected = + "not ok 1 do a thing # TODO not working yet\n" + + "ok 2 # TODO is it?\n" + + "1..2\n" + + assert(output.toString === expected) + } +} diff --git a/src/test/scala/org/perl8/test/tests/testbuilder/basic.scala b/src/test/scala/org/perl8/test/tests/testbuilder/basic.scala deleted file mode 100644 index da7cf57..0000000 --- a/src/test/scala/org/perl8/test/tests/testbuilder/basic.scala +++ /dev/null @@ -1,167 +0,0 @@ -package org.perl8.test.tests.testbuilder - -import org.scalatest.FunSuite -import org.scalatest.BeforeAndAfter - -import org.perl8.test._ - -import java.io.ByteArrayOutputStream - -class Basic extends FunSuite with BeforeAndAfter { - private val output = new ByteArrayOutputStream - - before { - output.reset - } - - test ("ok") { - val builder = new TestBuilder(4, output) - builder.ok(true, "test succeeded") - builder.ok(false, "test failed") - builder.ok(true) - builder.ok(false) - builder.doneTesting - - val expected = - "1..4\n" + - "ok 1 test succeeded\n" + - "not ok 2 test failed\n" + - "ok 3\n" + - "not ok 4\n" + - "# Looks like you failed 2 tests of 4.\n" - - assert(output.toString === expected) - } - - test ("no plan") { - val builder = new TestBuilder(output) - builder.ok(true, "test succeeded") - builder.ok(false, "test failed") - builder.ok(true) - builder.ok(false) - builder.doneTesting - - val expected = - "ok 1 test succeeded\n" + - "not ok 2 test failed\n" + - "ok 3\n" + - "not ok 4\n" + - "1..4\n" + - "# Looks like you failed 2 tests of 4.\n" - - assert(output.toString === expected) - } - - test ("empty") { - val builder = new TestBuilder(output) - builder.doneTesting - - val expected = - "1..0\n" + - "# No tests run!\n" - - assert(output.toString === expected) - } - - test ("diag") { - val builder = new TestBuilder(output) - - builder.ok(true, "the test passes") - builder.ok(false, "the test passes") - builder.diag("got false, expected true") - builder.ok(true) - builder.diag("ending\nnow") - builder.doneTesting - - val expected = - "ok 1 the test passes\n" + - "not ok 2 the test passes\n" + - "# got false, expected true\n" + - "ok 3\n" + - "# ending\n" + - "# now\n" + - "1..3\n" + - "# Looks like you failed 1 test of 3.\n" - - assert(output.toString === expected) - } - - test ("is passing") { - val builder = new TestBuilder(output) - - assert(!builder.isPassing) - builder.ok(true) - assert(builder.isPassing) - builder.ok(false) - assert(!builder.isPassing) - builder.ok(true) - assert(!builder.isPassing) - } - - test ("bail out") { - val builder = new TestBuilder(output) - - builder.ok(true) - val e = intercept[BailOutException] { - builder.bailOut("oh no!") - } - assert(e.message === "oh no!") - - val expected = - "ok 1\n" + - "Bail out! oh no!\n" - - assert(output.toString === expected) - } - - test ("skip all") { - val builder = new TestBuilder(SkipAll(), output) - - val expected = - "1..0 # SKIP\n" - - assert(output.toString === expected) - } - - test ("skip all with reason") { - val builder = new TestBuilder(SkipAll("foo bar"), output) - - val expected = - "1..0 # SKIP foo bar\n" - - assert(output.toString === expected) - } - - test ("skip") { - val builder = new TestBuilder(output) - - builder.ok(false) - builder.skip("not now") - builder.skip() - builder.doneTesting - - val expected = - "not ok 1\n" + - "ok 2 # skip not now\n" + - "ok 3 # skip\n" + - "1..3\n" + - "# Looks like you failed 1 test of 3.\n" - - assert(output.toString === expected) - } - - test ("todo") { - val builder = new TestBuilder(output) - - builder.ok(false, "do a thing", todo = "not working yet") - builder.ok(true, todo = "is it?") - builder.doneTesting - - val expected = - "not ok 1 do a thing # TODO not working yet\n" + - "ok 2 # TODO is it?\n" + - "1..2\n" - - assert(output.toString === expected) - } -} diff --git a/src/test/scala/org/perl8/test/tests/testmore/basic.scala b/src/test/scala/org/perl8/test/tests/testmore/basic.scala deleted file mode 100644 index d40a218..0000000 --- a/src/test/scala/org/perl8/test/tests/testmore/basic.scala +++ /dev/null @@ -1,144 +0,0 @@ -package org.perl8.test.tests.testmore - -import org.scalatest.FunSuite - -import org.perl8.test.TestMore - -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) - - 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() - } -} - -class Basic extends FunSuite { - test ("basic") { - assert((new MyBasicTest).run == 9) - - 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 basic.scala line 16.\n" + - "ok 3\n" + - "not ok 4\n" + - "# Failed test at basic.scala line 18.\n" + - "# is\n" + - "ok 5 - it works!\n" + - "not ok 6 - it doesn't work!\n" + - "# Failed test 'it doesn't work!'\n" + - "# at basic.scala line 22.\n" + - "# got: '1'\n" + - "# expected: '0'\n" + - "ok 7\n" + - "not ok 8\n" + - "# Failed test at basic.scala line 24.\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 basic.scala line 28.\n" + - "# got: '1'\n" + - "# expected: anything else\n" + - "ok 11\n" + - "not ok 12\n" + - "# Failed test at basic.scala line 30.\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 basic.scala line 34.\n" + - "# 'foo'\n" + - "# doesn't match 'bar'\n" + - "ok 15\n" + - "not ok 16\n" + - "# Failed test at basic.scala line 36.\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 basic.scala line 41.\n" + - " # 'foo'\n" + - " # matches 'foo'\n" + - " ok 3\n" + - " not ok 4\n" + - " # Failed test at basic.scala line 43.\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 basic.scala line 38.\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 basic.scala line 57.\n" + - "not ok 23 # TODO not working yet\n" + - "# Failed (TODO) test at basic.scala line 58.\n" + - "1..23\n" + - "# Looks like you failed 9 tests of 23.\n" - - assert(OutputContainer.output.toString === expected) - } -} -- cgit v1.2.3-54-g00ecf