-
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 #181 from softwaremill/fix-i159
Extract focuses from nested `Inlined` trees when determining modification path in Scala 3 macro
- Loading branch information
Showing
2 changed files
with
38 additions
and
11 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
22 changes: 22 additions & 0 deletions
22
quicklens/src/test/scala-3/com/softwaremill/quicklens/test/CustomModifyProxyTest.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,22 @@ | ||
package com.softwaremill.quicklens.test | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
import com.softwaremill.quicklens.* | ||
|
||
class CustomModifyProxyTest extends AnyFlatSpec with Matchers { | ||
|
||
it should "correctly modify a class using a custom modify proxy method" in { | ||
case class State(foo: Int) | ||
|
||
inline def set[A](state: State, inline path: State => A, value: A): State = { | ||
modify(state)(path).setTo(value) | ||
} | ||
|
||
val state = State(100) | ||
val res = set(state, _.foo, 200) | ||
val expected = State(200) | ||
res.shouldBe(expected) | ||
} | ||
|
||
} |