11package ch.tutteli.atrium.api.infix.en_GB
22
3+ import ch.tutteli.atrium.api.verbs.expect
34import ch.tutteli.atrium.creating.Expect
45import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
56import ch.tutteli.atrium.specs.integration.IterableToContainSpecBase.Companion.emptyInAnyOrderOnlyReportOptions
6- import ch.tutteli.atrium.specs.notImplemented
7- import org.spekframework.spek2.Spek
7+ import ch.tutteli.atrium.specs.integration.utils.iterableLikeToIterableTestFactory
8+ import ch.tutteli.atrium.specs.withNullableSuffix
9+ import ch.tutteli.atrium.testfactories.TestFactory
10+ import kotlin.Number
11+ import kotlin.test.Test
812
9- class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest : Spek ({
10- // include(BuilderSpec)
11- include(BuilderIterableLikeToIterableSpec )
12- }) {
13- object BuilderSpec : ch.tutteli.atrium.specs.integration.AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest(
14- getToContainPair(),
15- getToContainNullablePair()
16- )
13+ class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest :
14+ ch.tutteli.atrium.specs.integration.AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest (
15+ functionDescription to Companion ::getToContainValues,
16+ (functionDescription to Companion ::getToContainNullableValues).withNullableSuffix(),
17+ ) {
1718
18- object BuilderIterableLikeToIterableSpec :
19- ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec <List <Int >>(
20- " toContain o inAny order but only elementsOf" ,
21- listOf (1 , 2 ),
22- { input -> it toContain o inAny order but only elementsOf input }
23- )
19+ @TestFactory
20+ fun iterableLikeToIterableTest () = iterableLikeToIterableTestFactory<List <Int >>(
21+ listOf (1 , 2 ),
22+ functionDescription to { input -> it toContain o inAny order but only elementsOf input }
23+ )
2424
2525 companion object : IterableToContainSpecBase () {
26- fun getToContainPair () =
27- " $toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf " to Companion ::getToContainValues
26+ val functionDescription = " $toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf "
2827
2928 private fun getToContainValues (
3029 expect : Expect <Iterable <Double >>,
@@ -41,9 +40,6 @@ class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest : Spek({
4140 )
4241 }
4342
44- fun getToContainNullablePair () =
45- " $toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf " to Companion ::getToContainNullableValues
46-
4743 private fun getToContainNullableValues (
4844 expect : Expect <Iterable <Double ?>>,
4945 a : Double? ,
@@ -60,29 +56,35 @@ class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest : Spek({
6056 }
6157 }
6258
59+ @Suppress(" AssignedValueIsNeverRead" , " UNUSED_VARIABLE" , " UNUSED_VALUE" )
60+ @Test
61+ fun ambiguityTest () {
62+ var list: Expect <List <Number >> = expect(listOf (1 , 1.2 ))
63+ var nSet: Expect <Set <Number ?>> = expect(setOf (1 , 1.2 ))
64+ var nCollection: Expect <Set <Number ?>> = expect(setOf (null , 1.2 ))
65+ var subList: Expect <ArrayList <Number >> = expect(arrayListOf (1 , 1.2 ))
66+ var starSet: Expect <Set <* >> = expect(setOf (1 , 1.2 , " asdf" ))
67+ var starCollection: Expect <Collection <* >> = expect(listOf (1 , null , " asdf" ))
6368
64- @Suppress( " unused " , " UNUSED_VALUE " )
65- private fun ambiguityTest () {
66- var list : Expect < List < Number >> = notImplemented( )
67- var nList : Expect < Set < Number ?>> = notImplemented( )
68- var subList : Expect < ArrayList < Number >> = notImplemented( )
69- var star : Expect < Collection < * >> = notImplemented( )
69+ list = list toContain o inAny order but only elementsOf listOf ( 1 , 1.2 )
70+ nSet = nSet toContain o inAny order but only elementsOf listOf ( 1 , 1.2 )
71+ nCollection = nCollection toContain o inAny order but only elementsOf listOf ( null , 1.2 )
72+ subList = subList toContain o inAny order but only elementsOf listOf ( 1 , 1.2 )
73+ starSet = starSet toContain o inAny order but only elementsOf listOf ( 1 , 1.2 , " asdf " )
74+ starCollection = starCollection toContain o inAny order but only elementsOf listOf ( 1 , null , " asdf " )
7075
71- list = list toContain o inAny order but only elementsOf emptyList<Int >()
72- nList = nList toContain o inAny order but only elementsOf emptyList<Int >()
73- subList = subList toContain o inAny order but only elementsOf emptyList<Int >()
74- star = star toContain o inAny order but only elementsOf emptyList<Int >()
75-
76- list = list toContain o inAny order but only the elementsOf(emptyList<Int >(), reportOptionsInAnyOrderOnly = {})
77- nList = nList toContain o inAny order but only the elementsOf(emptyList<Int >(), reportOptionsInAnyOrderOnly = {})
76+ list = list toContain o inAny order but only the elementsOf(listOf (1 , 1.2 ), reportOptionsInAnyOrderOnly = {})
77+ nSet = nSet toContain o inAny order but only the elementsOf(listOf (1 , 1.2 ), reportOptionsInAnyOrderOnly = {})
7878 subList =
79- subList toContain o inAny order but only the elementsOf(emptyList<Int >(), reportOptionsInAnyOrderOnly = {})
80- star = star toContain o inAny order but only the elementsOf(emptyList<Int >(), reportOptionsInAnyOrderOnly = {})
81-
82- nList = nList toContain o inAny order but only elementsOf emptyList<Int ?>()
83- star = star toContain o inAny order but only elementsOf emptyList<Int ?>()
84-
85- nList = nList toContain o inAny order but only the elementsOf(emptyList<Int ?>(), reportOptionsInAnyOrderOnly = {})
86- star = star toContain o inAny order but only the elementsOf(emptyList<Int ?>(), reportOptionsInAnyOrderOnly = {})
79+ subList toContain o inAny order but only the elementsOf(listOf (1 , 1.2 ), reportOptionsInAnyOrderOnly = {})
80+ nCollection = nCollection toContain o inAny order but only the elementsOf(
81+ listOf (null , 1.2 ),
82+ reportOptionsInAnyOrderOnly = {})
83+ starSet = starSet toContain o inAny order but only the elementsOf(
84+ listOf (1 , 1.2 , " asdf" ),
85+ reportOptionsInAnyOrderOnly = {})
86+ starCollection = starCollection toContain o inAny order but only the elementsOf(
87+ listOf (1 , null , " asdf" ),
88+ reportOptionsInAnyOrderOnly = {})
8789 }
8890}
0 commit comments