From 6d4f400455f40561c853393249cda97f832ce61f Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 23 Feb 2013 14:56:12 -0600 Subject: allow extensions to get the correct stack trace better implementation ideas here would be nice --- src/test/scala/org/perl8/test/ExtensionTest.scala | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/test/scala/org/perl8/test/ExtensionTest.scala (limited to 'src/test') diff --git a/src/test/scala/org/perl8/test/ExtensionTest.scala b/src/test/scala/org/perl8/test/ExtensionTest.scala new file mode 100644 index 0000000..e616d3e --- /dev/null +++ b/src/test/scala/org/perl8/test/ExtensionTest.scala @@ -0,0 +1,55 @@ +package org.perl8.test + +import java.io.ByteArrayOutputStream + +trait NumberZero { this: TestMore => + def is_zero (i: Int, desc: String): Boolean = { + withLevel(1) { + is(i, 0, desc) + } + } +} + +trait NumberZeroWrapped extends NumberZero { this: TestMore => + def isZero (i: Int): Boolean = { + withLevel(1) { + is_zero(i, "the number is zero") + } + } +} + +class ExtensionTest extends TestMore { + 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(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 24.\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 26.\n" + + "# got: '1'\n" + + "# expected: '0'\n" + + "1..4\n" + + "# Looks like you failed 2 tests of 4.\n" + + is(out.toString, tap) +} -- cgit v1.2.3-54-g00ecf