-
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 #92 from OndrejSpanel/scala3-array
Scala3 array - each / index
- Loading branch information
Showing
4 changed files
with
56 additions
and
6 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
27 changes: 27 additions & 0 deletions
27
quicklens/src/test/scala/com/softwaremill/quicklens/ModifyArrayIndexTest.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 ModifyArrayIndexTest extends AnyFlatSpec with Matchers { | ||
|
||
it should "modify a non-nested array with case class item" in { | ||
modify(ar1)(_.index(2).a4.a5.name).using(duplicate) should be(l1at2dup) | ||
modify(ar1)(_.index(2)) | ||
.using(a3 => modify(a3)(_.a4.a5.name).using(duplicate)) should be(l1at2dup) | ||
} | ||
|
||
it should "modify a nested array using index" in { | ||
modify(arar1)(_.index(2).index(1).name).using(duplicate) should be(ll1at2at1dup) | ||
} | ||
|
||
it should "modify a nested array using index and each" in { | ||
modify(arar1)(_.index(2).each.name).using(duplicate) should be(ll1at2eachdup) | ||
modify(arar1)(_.each.index(1).name).using(duplicate) should be(ll1eachat1dup) | ||
} | ||
|
||
it should "not modify if given index does not exist" in { | ||
modify(ar1)(_.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