From ba915b267642d5472207e10b2aaef6c1208383c2 Mon Sep 17 00:00:00 2001 From: Julien Truffaut Date: Sun, 22 Aug 2021 21:15:41 +0200 Subject: [PATCH 1/2] GetMany should not allow to call getOne --- .../scala/monocly/impl/GetterImplTest.scala | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/scala/monocly/impl/GetterImplTest.scala diff --git a/src/test/scala/monocly/impl/GetterImplTest.scala b/src/test/scala/monocly/impl/GetterImplTest.scala new file mode 100644 index 0000000..36444c5 --- /dev/null +++ b/src/test/scala/monocly/impl/GetterImplTest.scala @@ -0,0 +1,23 @@ +package monocly.impl + +import munit.FunSuite + +class GetterImplTest extends munit.FunSuite { + + test("GetMany getOne") { + val getter = GetManyImpl((x: List[Int]) => x) + val input = List(1,2,3) + assertEquals( + getter.get(input), + 1 + ) + } + + test("GetMany getOne doesn't compile") { + assertNoDiff( + compileErrors("GetManyImpl((x: List[Int]) => x).get(List(1,2,3))"), + "Error: ..." + ) + } + +} From 4e00fda700fe785b5ed2ca76dcc7c73d1054b77c Mon Sep 17 00:00:00 2001 From: Julien Truffaut Date: Sun, 22 Aug 2021 21:16:48 +0200 Subject: [PATCH 2/2] add example for NoGetter --- src/test/scala/monocly/impl/GetterImplTest.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/scala/monocly/impl/GetterImplTest.scala b/src/test/scala/monocly/impl/GetterImplTest.scala index 36444c5..d639264 100644 --- a/src/test/scala/monocly/impl/GetterImplTest.scala +++ b/src/test/scala/monocly/impl/GetterImplTest.scala @@ -20,4 +20,11 @@ class GetterImplTest extends munit.FunSuite { ) } + test("NoGetter getOne doesn't compile") { + assertNoDiff( + compileErrors("NoGetter.get(1)"), + "Error: ..." + ) + } + }