aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Krastev <joro.kr.21@gmail.com>2018-04-14 22:58:56 +0200
committerGeorgi Krastev <joro.kr.21@gmail.com>2018-04-14 23:53:16 +0200
commit43b8ee6e41a02ea110b3349dfb1db4d59574db35 (patch)
tree1ce0ec1a365a3733af51e774c94a015cc95c09ac
parentfb514c8045df9eb36064aef05e50595287e9d9fa (diff)
downloadmagnolia-43b8ee6e41a02ea110b3349dfb1db4d59574db35.tar.gz
magnolia-43b8ee6e41a02ea110b3349dfb1db4d59574db35.tar.bz2
magnolia-43b8ee6e41a02ea110b3349dfb1db4d59574db35.zip
Remove explicit Show.gen imports from tests
These imports were changing the priority of implicits which means the tests were not accurate.
-rw-r--r--tests/src/main/scala/tests.scala13
1 files 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"))