From 4e3cfd8f693051047c2c426999fd76ddc70c7805 Mon Sep 17 00:00:00 2001 From: wahtique Date: Tue, 28 Mar 2023 00:31:02 +0200 Subject: [PATCH 1/8] feat(printer): mk printers more easily configurable - add `orElse` combinator for `Printer` for composability - add utility constructor for easier instantiation : user will only pass whatever is actually meaningful to them in most cases, ie. the custom logic to stringify the test values - update `Assertion` to allow users to pass their custom `Printer` without overriding `munitPrint` --- .../src/main/scala/munit/Assertions.scala | 4 +- .../shared/src/main/scala/munit/Printer.scala | 72 ++++++++++ .../test/scala/munit/CustomPrinterSuite.scala | 131 ++++++++++++++++++ 3 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 tests/shared/src/test/scala/munit/CustomPrinterSuite.scala diff --git a/munit/shared/src/main/scala/munit/Assertions.scala b/munit/shared/src/main/scala/munit/Assertions.scala index 24642843..ec3e058b 100644 --- a/munit/shared/src/main/scala/munit/Assertions.scala +++ b/munit/shared/src/main/scala/munit/Assertions.scala @@ -303,10 +303,12 @@ trait Assertions extends MacroCompat.CompileErrorMacro { } def clues(clue: Clue[_]*): Clues = new Clues(clue.toList) + def printer: Printer = EmptyPrinter + def munitPrint(clue: => Any): String = { clue match { case message: String => message - case value => Printers.print(value) + case value => Printers.print(value, printer) } } diff --git a/munit/shared/src/main/scala/munit/Printer.scala b/munit/shared/src/main/scala/munit/Printer.scala index 743abd3f..353ce247 100644 --- a/munit/shared/src/main/scala/munit/Printer.scala +++ b/munit/shared/src/main/scala/munit/Printer.scala @@ -14,6 +14,78 @@ trait Printer { def height: Int = 100 def isMultiline(string: String): Boolean = string.contains('\n') + + /** + * Combine two printers into a single printer. + * + * Order is important : this printer will be tried first, then the other printer. + * The new Printer's height will be the max of the two printers' heights. + * + * Comibining two printers can be useful if you want to customize Printer for + * some types somewhere, but want to add more specialized printers for some tests + * + * {{{ + * trait MySuites extends FunSuite { + * override val printer = Printer { + * case long => s"${l}L" + * } + * } + * + * trait SomeOtherSuites extends MySuites { + * override val printer = Printer { + * case m: SomeCaseClass => m.someCustomToString + * } orElse super.printer + * } + * + * }}} + */ + def orElse(other: Printer): Printer = + new Printer { + def print(value: Any, out: StringBuilder, indent: Int): Boolean = + this.print(value, out, indent) || other.print( + value, + out, + indent + ) + override def height: Int = this.height.max(other.height) + } + + val a = Byte +} + +object Printer { + + def apply(h: Int)(partialPrint: PartialFunction[Any, String]): Printer = + new Printer { + def print(value: Any, out: StringBuilder, indent: Int): Boolean = + value match { + case simpleValue => + partialPrint.lift.apply(simpleValue).fold(false) { string => + out.append(string) + true + } + } + + override def height: Int = h + } + + /** + * Utiliy constructor defining a printer for some types. + * + * This might be useful for some types which default pretty-printers + * do not output helpful diffs. + * + * {{{ + * type ByteArray = Array[Byte] + * val listPrinter = Printer { + * case ll: ByteArray => ll.map(String.format("%02x", b)).mkString(" ") + * } + * val bytes = Array[Byte](1, 5, 8, 24) + * Printers.print(bytes, listPrinter) // "01 05 08 18" + * }}} + */ + def apply(partialPrint: PartialFunction[Any, String]): Printer = + apply(100)(partialPrint) } /** Default printer that does not customize the pretty-printer */ diff --git a/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala b/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala new file mode 100644 index 00000000..214fb9bd --- /dev/null +++ b/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala @@ -0,0 +1,131 @@ +package munit + +import org.scalacheck.Prop.forAll +import munit.internal.console.Printers +import org.scalacheck.Arbitrary.arbitrary +import scala.collection.immutable + +class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { + + private case class Foo(i: Int) + + private case class Bar(is: List[Int]) + + private case class FooBar(foo: Foo, bar: Bar) + + private val genFoo = arbitrary[Int].map(Foo(_)) + + private val genBar = arbitrary[List[Int]].map(Bar(_)) + + private val genFooBar = for { + foo <- genFoo + bar <- genBar + } yield FooBar(foo, bar) + + private val longPrinter = Printer { case l: Long => + s"MoreThanInt($l)" + } + + private val fooPrinter = Printer { case Foo(i) => + s"Foo(INT($i))" + } + + private val listPrinter = Printer { case l: List[_] => + l.mkString("[", ",", "]") + } + + private val intPrinter = Printer { case i: Int => + s"NotNaN($i)" + } + + property("long") { + forAll(arbitrary[Long]) { (l: Long) => + val obtained = Printers.print(l, longPrinter) + val expected = s"MoreThanInt($l)" + assertEquals(obtained, expected) + } + } + + property("list") { + forAll(arbitrary[List[Int]]) { l => + val obtained = Printers.print(l, listPrinter) + val expected = l.mkString("[", ",", "]") + assertEquals(obtained, expected) + } + } + + property("product") { + forAll(arbitrary[Int]) { i => + val input = Foo(i) + val obtained = Printers.print(input, fooPrinter) + val expected = s"Foo(INT($i))" + assertEquals(obtained, expected) + } + } + + property("int in product") { + forAll(arbitrary[Int]) { i => + val input = Foo(i) + val obtained = Printers.print(input, intPrinter) + val expected = s"Foo(\n i = NotNaN($i)\n)" + assertEquals(obtained, expected) + } + } + + property("list in product") { + forAll(arbitrary[List[Int]]) { l => + val input = Bar(l) + val obtained = Printers.print(input, listPrinter) + val expected = s"Bar(\n is = ${l.mkString("[", ",", "]")}\n)" + assertEquals(obtained, expected) + } + } + + property("list and int in product") { + forAll(genFooBar) { foobar => + val obtained = Printers + .print(foobar, listPrinter.orElse(intPrinter)) + .stripMargin + .stripLeading() + .stripTrailing() + val expected = + s"""|FooBar( + | foo = Foo( + | i = NotNaN(${foobar.foo.i}) + | ), + | bar = Bar( + | is = ${foobar.bar.is.mkString("[", ",", "]")} + | ) + |) + |""".stripMargin.stripLeading().stripTrailing() + assertEquals(obtained, expected) + } + } + + property("all ints in product") { + forAll(genFooBar) { foobar => + val obtained = Printers + .print(foobar, intPrinter) + .filterNot(_.isWhitespace) + + val expectedbBarList = foobar.bar.is match { + case Nil => "Nil" + case l => + l.map(i => s"NotNaN($i)").mkString("List(", ",", ")") + } + + val expected = + s"""|FooBar( + | foo = Foo( + | i = NotNaN(${foobar.foo.i}) + | ), + | bar = Bar( + | is = $expectedbBarList + | ) + |) + |""".stripMargin.filterNot(_.isWhitespace) + assertEquals(obtained, expected) + } + } + +} From af1590cb18752ae5cc72f0aa90df6672f1ea37fc Mon Sep 17 00:00:00 2001 From: wahtique Date: Tue, 28 Mar 2023 19:16:09 +0200 Subject: [PATCH 2/8] fix(printer): avoid stack overflow + cleanup the test value --- .../shared/src/main/scala/munit/Printer.scala | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/munit/shared/src/main/scala/munit/Printer.scala b/munit/shared/src/main/scala/munit/Printer.scala index 353ce247..3ac23a39 100644 --- a/munit/shared/src/main/scala/munit/Printer.scala +++ b/munit/shared/src/main/scala/munit/Printer.scala @@ -20,42 +20,47 @@ trait Printer { * * Order is important : this printer will be tried first, then the other printer. * The new Printer's height will be the max of the two printers' heights. - * + * * Comibining two printers can be useful if you want to customize Printer for - * some types somewhere, but want to add more specialized printers for some tests - * + * some types somewhere, but want to add more specialized printers for some tests + * * {{{ - * trait MySuites extends FunSuite { - * override val printer = Printer { + * trait MySuites extends FunSuite { + * override val printer = Printer.apply { * case long => s"${l}L" * } * } - * + * * trait SomeOtherSuites extends MySuites { - * override val printer = Printer { + * override val printer = Printer.apply { * case m: SomeCaseClass => m.someCustomToString * } orElse super.printer * } - * + * * }}} */ - def orElse(other: Printer): Printer = + def orElse(other: Printer): Printer = { + val h = this.height + val p: (Any, StringBuilder, Int) => Boolean = this.print new Printer { def print(value: Any, out: StringBuilder, indent: Int): Boolean = - this.print(value, out, indent) || other.print( + p.apply(value, out, indent) || other.print( value, out, indent ) - override def height: Int = this.height.max(other.height) + override def height: Int = h.max(other.height) } + } - val a = Byte } object Printer { - def apply(h: Int)(partialPrint: PartialFunction[Any, String]): Printer = + def apply( + height: Int + )(partialPrint: PartialFunction[Any, String]): Printer = { + val h = height new Printer { def print(value: Any, out: StringBuilder, indent: Int): Boolean = value match { @@ -68,6 +73,7 @@ object Printer { override def height: Int = h } + } /** * Utiliy constructor defining a printer for some types. @@ -77,7 +83,7 @@ object Printer { * * {{{ * type ByteArray = Array[Byte] - * val listPrinter = Printer { + * val listPrinter = Printer.apply { * case ll: ByteArray => ll.map(String.format("%02x", b)).mkString(" ") * } * val bytes = Array[Byte](1, 5, 8, 24) From 6797ef57d856a53b1aa9025d37e9d4c50eb5bd2f Mon Sep 17 00:00:00 2001 From: wahtique Date: Tue, 28 Mar 2023 19:17:06 +0200 Subject: [PATCH 3/8] fix(custom-printer-suite): do not run product tests for 2.12 copied from [[munit.PrintersSuite]] --- .../test/scala/munit/CustomPrinterSuite.scala | 68 +++++++++++-------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala b/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala index 214fb9bd..4794d96c 100644 --- a/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala +++ b/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala @@ -3,42 +3,55 @@ package munit import org.scalacheck.Prop.forAll import munit.internal.console.Printers import org.scalacheck.Arbitrary.arbitrary -import scala.collection.immutable +import org.scalacheck.Prop class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { private case class Foo(i: Int) - private case class Bar(is: List[Int]) + private case class Bar(l: List[Int]) private case class FooBar(foo: Foo, bar: Bar) private val genFoo = arbitrary[Int].map(Foo(_)) - private val genBar = arbitrary[List[Int]].map(Bar(_)) + // limit size to 10 to have a reasonable number of values + private val genBar = arbitrary[List[Int]].map(l => Bar(l.take(10))) private val genFooBar = for { foo <- genFoo bar <- genBar } yield FooBar(foo, bar) - private val longPrinter = Printer { case l: Long => + private val longPrinter: Printer = Printer.apply { case l: Long => s"MoreThanInt($l)" } - private val fooPrinter = Printer { case Foo(i) => + private val fooPrinter: Printer = Printer.apply { case Foo(i) => s"Foo(INT($i))" } - private val listPrinter = Printer { case l: List[_] => + private val listPrinter: Printer = Printer.apply { case l: List[_] => l.mkString("[", ",", "]") } - private val intPrinter = Printer { case i: Int => + private val intPrinter: Printer = Printer.apply { case i: Int => s"NotNaN($i)" } - property("long") { + private val isScala213: Boolean = BuildInfo.scalaVersion.startsWith("2.13") + + private def checkProp( + options: TestOptions, + isEnabled: Boolean = true + )(p: => Prop): Unit = { + test(options) { + assume(isEnabled, "disabled test") + p + } + } + + checkProp("long") { forAll(arbitrary[Long]) { (l: Long) => val obtained = Printers.print(l, longPrinter) val expected = s"MoreThanInt($l)" @@ -46,7 +59,7 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { } } - property("list") { + checkProp("list") { forAll(arbitrary[List[Int]]) { l => val obtained = Printers.print(l, listPrinter) val expected = l.mkString("[", ",", "]") @@ -54,34 +67,31 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { } } - property("product") { - forAll(arbitrary[Int]) { i => - val input = Foo(i) - val obtained = Printers.print(input, fooPrinter) - val expected = s"Foo(INT($i))" + checkProp("product") { + forAll(genFoo) { foo => + val obtained = Printers.print(foo, fooPrinter) + val expected = s"Foo(INT(${foo.i}))" assertEquals(obtained, expected) } } - property("int in product") { - forAll(arbitrary[Int]) { i => - val input = Foo(i) - val obtained = Printers.print(input, intPrinter) - val expected = s"Foo(\n i = NotNaN($i)\n)" + checkProp("int in product", isEnabled = isScala213) { + forAll(genFoo) { foo => + val obtained = Printers.print(foo, intPrinter) + val expected = s"Foo(\n i = NotNaN(${foo.i})\n)" assertEquals(obtained, expected) } } - property("list in product") { - forAll(arbitrary[List[Int]]) { l => - val input = Bar(l) - val obtained = Printers.print(input, listPrinter) - val expected = s"Bar(\n is = ${l.mkString("[", ",", "]")}\n)" + checkProp("list in product", isEnabled = isScala213) { + forAll(genBar) { bar => + val obtained = Printers.print(bar, listPrinter) + val expected = s"Bar(\n l = ${bar.l.mkString("[", ",", "]")}\n)" assertEquals(obtained, expected) } } - property("list and int in product") { + checkProp("list and int in product", isEnabled = isScala213) { forAll(genFooBar) { foobar => val obtained = Printers .print(foobar, listPrinter.orElse(intPrinter)) @@ -94,7 +104,7 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { | i = NotNaN(${foobar.foo.i}) | ), | bar = Bar( - | is = ${foobar.bar.is.mkString("[", ",", "]")} + | l = ${foobar.bar.l.mkString("[", ",", "]")} | ) |) |""".stripMargin.stripLeading().stripTrailing() @@ -102,13 +112,13 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { } } - property("all ints in product") { + checkProp("all ints in product", isEnabled = isScala213) { forAll(genFooBar) { foobar => val obtained = Printers .print(foobar, intPrinter) .filterNot(_.isWhitespace) - val expectedbBarList = foobar.bar.is match { + val expectedbBarList = foobar.bar.l match { case Nil => "Nil" case l => l.map(i => s"NotNaN($i)").mkString("List(", ",", ")") @@ -120,7 +130,7 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { | i = NotNaN(${foobar.foo.i}) | ), | bar = Bar( - | is = $expectedbBarList + | l = $expectedbBarList | ) |) |""".stripMargin.filterNot(_.isWhitespace) From 282696efd990a9ca32ff05634cb47c70567de1fb Mon Sep 17 00:00:00 2001 From: wahtique Date: Wed, 29 Mar 2023 11:28:52 +0200 Subject: [PATCH 4/8] fix: rm java8 incompatible String methods --- tests/shared/src/test/scala/munit/CustomPrinterSuite.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala b/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala index 4794d96c..610a9d10 100644 --- a/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala +++ b/tests/shared/src/test/scala/munit/CustomPrinterSuite.scala @@ -95,9 +95,7 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { forAll(genFooBar) { foobar => val obtained = Printers .print(foobar, listPrinter.orElse(intPrinter)) - .stripMargin - .stripLeading() - .stripTrailing() + .filterNot(_.isWhitespace) val expected = s"""|FooBar( | foo = Foo( @@ -107,7 +105,7 @@ class CustomPrinterSuite extends FunSuite with ScalaCheckSuite { | l = ${foobar.bar.l.mkString("[", ",", "]")} | ) |) - |""".stripMargin.stripLeading().stripTrailing() + |""".stripMargin.filterNot(_.isWhitespace) assertEquals(obtained, expected) } } From 858aefc698c0cb1c610fc2ba276db714dae625e3 Mon Sep 17 00:00:00 2001 From: wahtique Date: Sat, 1 Apr 2023 21:39:54 +0200 Subject: [PATCH 5/8] refactor(printer): improve code readbility + doc --- .../shared/src/main/scala/munit/Printer.scala | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/munit/shared/src/main/scala/munit/Printer.scala b/munit/shared/src/main/scala/munit/Printer.scala index 3ac23a39..4987d8ef 100644 --- a/munit/shared/src/main/scala/munit/Printer.scala +++ b/munit/shared/src/main/scala/munit/Printer.scala @@ -11,7 +11,7 @@ trait Printer { * Returns true if this value has been printed, false if FunSuite should fallback to the default pretty-printer. */ def print(value: Any, out: StringBuilder, indent: Int): Boolean - def height: Int = 100 + def height: Int = Printer.defaultHeight def isMultiline(string: String): Boolean = string.contains('\n') @@ -21,20 +21,25 @@ trait Printer { * Order is important : this printer will be tried first, then the other printer. * The new Printer's height will be the max of the two printers' heights. * - * Comibining two printers can be useful if you want to customize Printer for - * some types somewhere, but want to add more specialized printers for some tests + * Exampple use case : define some default printers for some types for all tests, + * and override it for some tests only. * * {{{ + * + * case class Person(name: String, age: Int, mail: String) + * * trait MySuites extends FunSuite { * override val printer = Printer.apply { - * case long => s"${l}L" + * case Person(name, age, mail) => s"$name:$age:$mail" + * case m: SomeOtherCaseClass => m.someCustomToString * } * } * - * trait SomeOtherSuites extends MySuites { - * override val printer = Printer.apply { - * case m: SomeCaseClass => m.someCustomToString - * } orElse super.printer + * trait CompareMailsOnly extends MySuites { + * val mailOnlyPrinter = Printer.apply { + * case Person(_, _, mail) => mail + * } + * override val printer = mailOnlyPrinterPrinter orElse super.printer * } * * }}} @@ -57,19 +62,21 @@ trait Printer { object Printer { + val defaultHeight = 100 + def apply( height: Int )(partialPrint: PartialFunction[Any, String]): Printer = { val h = height new Printer { - def print(value: Any, out: StringBuilder, indent: Int): Boolean = - value match { - case simpleValue => - partialPrint.lift.apply(simpleValue).fold(false) { string => - out.append(string) - true - } + def print(value: Any, out: StringBuilder, indent: Int): Boolean = { + partialPrint.lift.apply(value) match { + case Some(string) => + out.append(string) + true + case None => false } + } override def height: Int = h } @@ -78,7 +85,7 @@ object Printer { /** * Utiliy constructor defining a printer for some types. * - * This might be useful for some types which default pretty-printers + * Example use case is overriding the string repr for types which default pretty-printers * do not output helpful diffs. * * {{{ @@ -91,10 +98,11 @@ object Printer { * }}} */ def apply(partialPrint: PartialFunction[Any, String]): Printer = - apply(100)(partialPrint) + apply(defaultHeight)(partialPrint) } /** Default printer that does not customize the pretty-printer */ object EmptyPrinter extends Printer { def print(value: Any, out: StringBuilder, indent: Int): Boolean = false } + \ No newline at end of file From 3360cf6ab417fb97cd653e3aa74332518e21780c Mon Sep 17 00:00:00 2001 From: wahtique Date: Sat, 1 Apr 2023 21:40:20 +0200 Subject: [PATCH 6/8] doc(custom-printer): add doc for custom printers --- docs/tests.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/docs/tests.md b/docs/tests.md index 55e05784..1a397c7d 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -120,6 +120,82 @@ class CustomTimeoutSuite extends munit.FunSuite { > non-async tests. However, starting with MUnit v1.0 (latest milestone release: > @VERSION@), the timeout applies to all tests including non-async tests. +## Customize value printers + +MUnit uses its own `Printer`s to convert any value into a diff-ready string representation. +The resulting string is the actual value being compared, and is also used to generate the clues in case of a failure. + +The default printing behaviour can be overriden for a given type by defining a custom `Printer` and overriding `printer`. + +Override `printer` to customize the comparison of two values : + +```scala mdoc +import java.time.Instant +import munit.FunSuite +import munit.Printer + +class InstantTest extends FunSuite { + override val printer = Printer.apply { + // take only the date part of the Instant + case instant: Instant => instant.toString.takeWhile(_ != 'T') + } + + test("dates only") { + val expected = Instant.parse("2022-02-15T18:35:24.00Z") + val actual = Instant.parse("2022-02-15T18:36:01.00Z") + assertEquals(actual, expected) // true + } +} +``` + +or to customize the printed clue in case of a failure : + +```scala mdoc +import munit.FunSuite +import munit.Printer + +class InstantTest extends munit.FunSuite { + override val printer = Printer.apply { + case l: List[Char] => l.mkString + } + + test("dates only") { + val expected = List('h', 'e', 'l', 'l', 'o') + val actual = List('h', 'e', 'l', 'l', '0') + assertEquals(actual, expected) + } +} +``` + +will yield + +``` +=> Obtained +hell0 +=> Diff (- obtained, + expected) +-hell0 ++hello +``` + +instead of the default + +``` +... +=> Obtained +List( + 'h', + 'e', + 'l', + 'l', + '0' +) +=> Diff (- obtained, + expected) + 'l', +- '0' ++ 'o' +... +``` + ## Run tests in parallel MUnit does not support running individual test cases in parallel. However, sbt @@ -140,7 +216,7 @@ Test / testOptions += Tests.Argument(TestFrameworks.MUnit, "-b") ``` To learn more about sbt test execution, see -https://www.scala-sbt.org/1.x/docs/Testing.html. +. ## Declare tests inside a helper function From 1bf21c906a639dbce1c8edd03f0c93370d46e7fc Mon Sep 17 00:00:00 2001 From: wahtique Date: Wed, 5 Apr 2023 11:34:59 +0200 Subject: [PATCH 7/8] typo --- munit/shared/src/main/scala/munit/Printer.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/munit/shared/src/main/scala/munit/Printer.scala b/munit/shared/src/main/scala/munit/Printer.scala index 4987d8ef..ee94cf53 100644 --- a/munit/shared/src/main/scala/munit/Printer.scala +++ b/munit/shared/src/main/scala/munit/Printer.scala @@ -21,13 +21,13 @@ trait Printer { * Order is important : this printer will be tried first, then the other printer. * The new Printer's height will be the max of the two printers' heights. * - * Exampple use case : define some default printers for some types for all tests, + * Example use case : define some default printers for some types for all tests, * and override it for some tests only. * * {{{ - * + * * case class Person(name: String, age: Int, mail: String) - * + * * trait MySuites extends FunSuite { * override val printer = Printer.apply { * case Person(name, age, mail) => s"$name:$age:$mail" @@ -105,4 +105,3 @@ object Printer { object EmptyPrinter extends Printer { def print(value: Any, out: StringBuilder, indent: Int): Boolean = false } - \ No newline at end of file From 9b5012a0340530bec6ac365e86744c0e21644dda Mon Sep 17 00:00:00 2001 From: wahtique Date: Wed, 5 Apr 2023 11:35:08 +0200 Subject: [PATCH 8/8] doc: fix mdoc gen --- docs/tests.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tests.md b/docs/tests.md index 1a397c7d..eaa2651a 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -134,7 +134,7 @@ import java.time.Instant import munit.FunSuite import munit.Printer -class InstantTest extends FunSuite { +class CompareDatesOnlyTest extends FunSuite { override val printer = Printer.apply { // take only the date part of the Instant case instant: Instant => instant.toString.takeWhile(_ != 'T') @@ -154,12 +154,12 @@ or to customize the printed clue in case of a failure : import munit.FunSuite import munit.Printer -class InstantTest extends munit.FunSuite { +class CustomListOfCharPrinterTest extends FunSuite { override val printer = Printer.apply { case l: List[Char] => l.mkString } - test("dates only") { + test("lists of chars") { val expected = List('h', 'e', 'l', 'l', 'o') val actual = List('h', 'e', 'l', 'l', '0') assertEquals(actual, expected)