-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from KacperFKorban/fix-i157
Move the second type argument to the modify/modifyAll method in Scala 3
- Loading branch information
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
quicklens/src/test/scala-3/com/softwaremill/quicklens/test/LiteralTypeTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.softwaremill.quicklens.test | ||
|
||
import com.softwaremill.quicklens.TestData.duplicate | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import com.softwaremill.quicklens._ | ||
|
||
object LiteralTypeTestData { | ||
case class Test(f: "foo") | ||
case class Test1[A](f: A) | ||
} | ||
|
||
class LiteralTypeTest extends AnyFlatSpec with Matchers { | ||
import LiteralTypeTestData._ | ||
|
||
it should "modify a literal type field with an explicit parameter" in { | ||
Test("foo").modify["foo"](_.f).setTo("foo") should be(Test("foo")) | ||
} | ||
|
||
it should "modify a literal type field as a type parameter with an explicit parameter" in { | ||
Test1["foo"]("foo").modify["foo"](_.f).setTo("foo") should be(Test1("foo")) | ||
} | ||
|
||
it should "not compile for a wrong literal type" in { | ||
assertDoesNotCompile(""" | ||
import com.softwaremill.quicklens.* | ||
case class Test1[A](f: A) | ||
Test1["foo"]("foo").modify["foo"](_.f).setTo("bar") | ||
""") | ||
} | ||
} |