-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Construct root instances with factory methods (#192)
* Construct root instance with given factory methods * Add todo for partial applied functions
- Loading branch information
Showing
3 changed files
with
47 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
20 changes: 20 additions & 0 deletions
20
macrosAutoCatsTests/src/test/resources/test-cases/constructInstanceWithFactoryMethod.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,20 @@ | ||
class A() | ||
class B(val a: A) | ||
|
||
val created = scala.collection.mutable.ListBuffer[String]() | ||
|
||
def makeB(a: A) = {created.append("b"); new B(a)} | ||
|
||
object Test { | ||
val theB = autowire[B](makeB _) | ||
|
||
} | ||
|
||
val theB: B = { | ||
import cats.effect.unsafe.implicits.global | ||
Test.theB.allocated.unsafeRunSync()._1 | ||
} | ||
|
||
require(theB.a != null) | ||
require(created.size == 1) | ||
require(created(0) == "b") |
21 changes: 21 additions & 0 deletions
21
macrosAutoCatsTests/src/test/resources/test-cases/todo/passSomeParameters.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,21 @@ | ||
class A() | ||
class B(val a: A) | ||
|
||
val created = scala.collection.mutable.ListBuffer[String]() | ||
|
||
def makeB(s: String, a: A) = { created.append("b"); created.append(s); new B(a)} | ||
|
||
object Test { | ||
val theB = autowire[B](makeB("s", _)) | ||
|
||
} | ||
|
||
val theB: B = { | ||
import cats.effect.unsafe.implicits.global | ||
Test.theB.allocated.unsafeRunSync()._1 | ||
} | ||
|
||
require(theB.a != null) | ||
require(created.size == 2) | ||
require(created(0) == "b") | ||
require(created(0) == "s") |