File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
main/scala/it/agilelab/darwin/common/compat
test/scala/it/agilelab/darwin/common Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -58,11 +58,11 @@ package object compat {
5858 }
5959 }
6060
61- implicit class RightBiasedEither [+ L , + R ](self : Either [L , R ]) {
61+ implicit class RightBiasedEither [+ L , + R ](val self : Either [L , R ]) extends AnyVal {
6262 def rightMap [R1 ](f : R => R1 ): Either [L , R1 ] = {
6363 self match {
6464 case Right (v) => Right (f(v))
65- case _ => this .asInstanceOf [Either [L , R1 ]]
65+ case _ => self .asInstanceOf [Either [L , R1 ]]
6666 }
6767 }
6868 }
Original file line number Diff line number Diff line change 1+ package it .agilelab .darwin .common
2+
3+ import org .scalatest .flatspec .AnyFlatSpec
4+ import org .scalatest .matchers .should .Matchers
5+ import compat ._
6+
7+ class CompatSpec extends AnyFlatSpec with Matchers {
8+
9+ " RightBiasedEither" should " map correctly on left side" in {
10+ Left [Int , String ](3 ).rightMap {
11+ " Hello" + _
12+ } shouldBe Left [Int , String ](3 )
13+ }
14+
15+ it should " map correctly on right side" in {
16+ Right [Int , String ](" Darwin" ).rightMap {
17+ " Hello " + _
18+ } shouldBe Right [Int , String ](" Hello Darwin" )
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments