-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So that we can: ``` def get(a: A): Optional[B] = ... val list: List[A] = ... val result: List[B] = list.flatMap(get) ```
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
core-tests/shared/src/test/scala/zio/prelude/data/OptionalSpec.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,21 @@ | ||
package zio.prelude.data | ||
|
||
import zio.Scope | ||
import zio.prelude.ZIOBaseSpec | ||
import zio.prelude.data.Optional | ||
import zio.test.{Spec, TestEnvironment, assertTrue} | ||
|
||
object OptionalSpec extends ZIOBaseSpec { | ||
|
||
override def spec: Spec[TestEnvironment with Scope, Any] = | ||
suite("Optional")( | ||
test("is an IterableOnce") { | ||
def get(a: Int): Optional[Long] = Optional.Present(a.toLong) | ||
val list: List[Int] = List(1, 2, 3) | ||
val result: List[Long] = list.flatMap(get) | ||
|
||
assertTrue(result == List(1L, 2L, 3L)) | ||
}, | ||
) | ||
|
||
} |
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