-
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 #91 from OndrejSpanel/seq-index
Scala 3 support for Seq / IndexedSeq
- Loading branch information
Showing
4 changed files
with
71 additions
and
13 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
27 changes: 27 additions & 0 deletions
27
quicklens/src/test/scala/com/softwaremill/quicklens/ModifyIndexedSeqIndexTest.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,27 @@ | ||
package com.softwaremill.quicklens | ||
|
||
import com.softwaremill.quicklens.TestData._ | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class ModifyIndexedSeqIndexTest extends AnyFlatSpec with Matchers { | ||
|
||
it should "modify a non-nested indexed seq with case class item" in { | ||
modify(is1)(_.index(2).a4.a5.name).using(duplicate) should be(l1at2dup) | ||
modify(is1)(_.index(2)) | ||
.using(a3 => modify(a3)(_.a4.a5.name).using(duplicate)) should be(l1at2dup) | ||
} | ||
|
||
it should "modify a nested indexed seq using index" in { | ||
modify(iss1)(_.index(2).index(1).name).using(duplicate) should be(ll1at2at1dup) | ||
} | ||
|
||
it should "modify a nested indexed seq using index and each" in { | ||
modify(iss1)(_.index(2).each.name).using(duplicate) should be(ll1at2eachdup) | ||
modify(iss1)(_.each.index(1).name).using(duplicate) should be(ll1eachat1dup) | ||
} | ||
|
||
it should "not modify if given index does not exist" in { | ||
modify(is1)(_.index(10).a4.a5.name).using(duplicate) should be(l1) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
quicklens/src/test/scala/com/softwaremill/quicklens/ModifySeqIndexTest.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,27 @@ | ||
package com.softwaremill.quicklens | ||
|
||
import com.softwaremill.quicklens.TestData._ | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class ModifySeqIndexTest extends AnyFlatSpec with Matchers { | ||
|
||
it should "modify a non-nested seq with case class item" in { | ||
modify(s1)(_.index(2).a4.a5.name).using(duplicate) should be(l1at2dup) | ||
modify(s1)(_.index(2)) | ||
.using(a3 => modify(a3)(_.a4.a5.name).using(duplicate)) should be(l1at2dup) | ||
} | ||
|
||
it should "modify a nested seq using index" in { | ||
modify(ss1)(_.index(2).index(1).name).using(duplicate) should be(ll1at2at1dup) | ||
} | ||
|
||
it should "modify a nested seq using index and each" in { | ||
modify(ss1)(_.index(2).each.name).using(duplicate) should be(ll1at2eachdup) | ||
modify(ss1)(_.each.index(1).name).using(duplicate) should be(ll1eachat1dup) | ||
} | ||
|
||
it should "not modify if given index does not exist" in { | ||
modify(s1)(_.index(10).a4.a5.name).using(duplicate) should be(l1) | ||
} | ||
} |
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