-
-
Notifications
You must be signed in to change notification settings - Fork 719
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 #1905 from InsertKoinIO/instance_factory_isolation
Instance Factory isolation fix
- Loading branch information
Showing
8 changed files
with
73 additions
and
23 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
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
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
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
40 changes: 40 additions & 0 deletions
40
projects/core/koin-core/src/commonTest/kotlin/org/koin/dsl/ModuleFactoryIsolationTest.kt
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,40 @@ | ||
package org.koin.dsl | ||
|
||
import org.koin.Simple | ||
import org.koin.core.annotation.KoinInternalApi | ||
import org.koin.core.module.Module | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
|
||
val myValModule = module { single { Simple.ComponentA() } } | ||
|
||
val myGetModule : Module | ||
get() = module { single { Simple.ComponentA() } } | ||
|
||
fun myFunModule() = module { single { Simple.ComponentA() } } | ||
|
||
@OptIn(KoinInternalApi::class) | ||
class ModuleFactoryIsolationTest { | ||
|
||
@Test | ||
fun testVariableIsolationAndInstanceFactories(){ | ||
val a = myGetModule | ||
val b = myGetModule | ||
|
||
val aA = myValModule | ||
val aB = myValModule | ||
|
||
val aF = myFunModule() | ||
val bF = myFunModule() | ||
|
||
assertTrue(a.mappings != b.mappings) | ||
assertEquals(a.mappings.values.first().beanDefinition, b.mappings.values.first().beanDefinition) | ||
|
||
assertEquals(aA.mappings, aB.mappings) | ||
|
||
assertTrue(aF.mappings != bF.mappings) | ||
assertEquals(aF.mappings.values.first().beanDefinition, bF.mappings.values.first().beanDefinition) | ||
} | ||
|
||
} |