From 43b8ee6e41a02ea110b3349dfb1db4d59574db35 Mon Sep 17 00:00:00 2001 From: Georgi Krastev Date: Sat, 14 Apr 2018 22:58:56 +0200 Subject: Remove explicit Show.gen imports from tests These imports were changing the priority of implicits which means the tests were not accurate. --- tests/src/main/scala/tests.scala | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/src/main/scala/tests.scala b/tests/src/main/scala/tests.scala index fc3a012..c3b90cc 100644 --- a/tests/src/main/scala/tests.scala +++ b/tests/src/main/scala/tests.scala @@ -43,10 +43,10 @@ class Length(val value: Int) extends AnyVal case class FruitBasket(fruits: Fruit*) case class Lunchbox(fruit: Fruit, drink: String) +case class Fruit(name: String) object Fruit { implicit val showFruit: Show[String, Fruit] = (f: Fruit) => f.name } -case class Fruit(name: String) case class Item(name: String, quantity: Int = 1, price: Int) @@ -116,19 +116,16 @@ object Tests extends TestApp { }.assert(_ == "Address(line1=Home,occupant=nobody)") test("even low-priority implicit beats Magnolia for nested case") { - import Show.gen implicitly[Show[String, Lunchbox]].show(Lunchbox(Fruit("apple"), "lemonade")) }.assert(_ == "Lunchbox(fruit=apple,drink=lemonade)") - test("low-priority implicit does not beat Magnolia when not nested") { - import Show.gen + test("low-priority implicit beats Magnolia when not nested") { implicitly[Show[String, Fruit]].show(Fruit("apple")) - }.assert(_ == "Fruit(name=apple)") + }.assert(_ == "apple") - test("low-priority implicit does not beat Magnolia when chained") { - import Show.gen + test("low-priority implicit beats Magnolia when chained") { implicitly[Show[String, FruitBasket]].show(FruitBasket(Fruit("apple"), Fruit("banana"))) - }.assert(_ == "FruitBasket(fruits=[Fruit(name=apple),Fruit(name=banana)])") + }.assert(_ == "FruitBasket(fruits=[apple,banana])") test("typeclass implicit scope has lower priority than ADT implicit scope") { implicitly[Show[String, Fruit]].show(Fruit("apple")) -- cgit v1.2.3