-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
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
macrosAutoCatsTests/src/test/resources/test-cases/subtypeParameter.success
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 @@ | ||
import com.softwaremill.macwire.auto.catssupport._ | ||
|
||
import cats.effect._ | ||
|
||
trait A | ||
class AA(i: Int) extends A | ||
|
||
class B(val a: A) | ||
|
||
object Test { | ||
|
||
val theAA: AA = new AA(1) | ||
val theB: B = { | ||
import cats.effect.unsafe.implicits.global | ||
|
||
val resource = autowire[B](theAA) | ||
resource.allocated.unsafeRunSync()._1 | ||
} | ||
|
||
} | ||
|
||
require(Test.theB.a == Test.theAA) |
42 changes: 42 additions & 0 deletions
42
macrosAutoCatsTests/src/test/resources/test-cases/taggingParameters.success
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,42 @@ | ||
import cats.effect._ | ||
import com.softwaremill.tagging._ | ||
import com.softwaremill.macwire.auto.catssupport._ | ||
|
||
class Cache { | ||
val state = scala.collection.mutable.HashMap.empty[String, String] | ||
} | ||
|
||
trait First | ||
trait Second | ||
|
||
class A(val cache: Cache) | ||
class B(val cache: Cache) | ||
class C(val cache: Cache) | ||
class D(val cache: Cache, val a: A, val b: B) | ||
class E(val c: C, val d: D) | ||
|
||
object Test { | ||
|
||
val cache1 = (new Cache()).taggedWith[First] | ||
val cache2 = (new Cache()).taggedWith[Second] | ||
|
||
val theE = { | ||
import cats.effect.unsafe.implicits.global | ||
|
||
val resource = autowire[E]( | ||
cache1, | ||
cache2, | ||
((c: Cache @@ First) => new A(c)), | ||
((c: Cache @@ First) => new B(c)), | ||
((c: Cache @@ Second) => new C(c)), | ||
((c: Cache @@ First) => new D(c, _, _)) | ||
) | ||
resource.allocated.unsafeRunSync()._1 | ||
} | ||
|
||
} | ||
|
||
require(Test.theE.d.a.cache == Test.cache1) | ||
require(Test.theE.d.b.cache == Test.cache1) | ||
require(Test.theE.d.cache == Test.cache1) | ||
require(Test.theE.c.cache == Test.cache2) |