Skip to content

Commit 5cc4819

Browse files
committed
fix ambiguityTest and wrong usage of @testfactory, migrate ...ElementsOf
1 parent b12f7d0 commit 5cc4819

File tree

5 files changed

+244
-255
lines changed

5 files changed

+244
-255
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
package ch.tutteli.atrium.api.fluent.en_GB
22

3+
import ch.tutteli.atrium.api.verbs.expect
34
import ch.tutteli.atrium.creating.Expect
45
import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
6+
import ch.tutteli.atrium.specs.integration.AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest
57
import ch.tutteli.atrium.specs.integration.IterableToContainSpecBase.Companion.emptyInAnyOrderOnlyReportOptions
6-
import ch.tutteli.atrium.specs.notImplemented
8+
import ch.tutteli.atrium.specs.integration.utils.iterableLikeToIterableTestFactory
79
import ch.tutteli.atrium.specs.withNullableSuffix
8-
import org.spekframework.spek2.Spek
10+
import ch.tutteli.atrium.testfactories.TestFactory
11+
import kotlin.test.Test
912
import ch.tutteli.atrium.api.fluent.en_GB.IterableToContainInAnyOrderOnlyElementsOfExpectationsTest.Companion as C
1013

11-
class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest : Spek({
12-
//include(BuilderSpec)
13-
include(BuilderIterableLikeToIterableSpec)
14-
}) {
15-
object BuilderSpec : ch.tutteli.atrium.specs.integration.AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest(
14+
class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest :
15+
AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest(
1616
functionDescription to C::toContainElementsOf,
1717
(functionDescription to C::toContainElementsOfNullable).withNullableSuffix()
18-
)
18+
) {
1919

20-
object BuilderIterableLikeToIterableSpec :
21-
ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec<List<Int>>(
22-
functionDescription,
23-
listOf(1, 2),
24-
{ input -> toContain.inAnyOrder.only.elementsOf(input) }
25-
)
20+
@TestFactory
21+
fun iterableLikeToIterableTest() = iterableLikeToIterableTestFactory<List<Int>>(
22+
listOf(1, 2),
23+
functionDescription to { input -> toContain.inAnyOrder.only.elementsOf(input) }
24+
)
2625

2726
companion object : IterableToContainSpecBase() {
2827
val functionDescription = "$toContain.$inAnyOrder.$only.$elementsOf"
@@ -48,27 +47,28 @@ class IterableToContainInAnyOrderOnlyElementsOfExpectationsTest : Spek({
4847
} else expect.toContain.inAnyOrder.only.elementsOf(listOf(a, *aX), report = report)
4948
}
5049

51-
@Suppress("unused", "UNUSED_VALUE")
52-
private fun ambiguityTest() {
53-
var list: Expect<List<Number>> = notImplemented()
54-
var nList: Expect<Set<Number?>> = notImplemented()
55-
var subList: Expect<ArrayList<Number>> = notImplemented()
56-
var star: Expect<Collection<*>> = notImplemented()
57-
58-
list = list.toContain.inAnyOrder.only.elementsOf(emptyList<Int>())
59-
nList = nList.toContain.inAnyOrder.only.elementsOf(emptyList<Int>())
60-
subList = subList.toContain.inAnyOrder.only.elementsOf(emptyList<Int>())
61-
star = star.toContain.inAnyOrder.only.elementsOf(emptyList<Int>())
62-
63-
list = list.toContain.inAnyOrder.only.elementsOf(emptyList<Int>(), report = {})
64-
nList = nList.toContain.inAnyOrder.only.elementsOf(emptyList<Int>(), report = {})
65-
subList = subList.toContain.inAnyOrder.only.elementsOf(emptyList<Int>(), report = {})
66-
star = star.toContain.inAnyOrder.only.elementsOf(emptyList<Int>(), report = {})
50+
@Suppress("AssignedValueIsNeverRead", "UNUSED_VARIABLE", "UNUSED_VALUE")
51+
@Test
52+
fun ambiguityTest() {
53+
var list: Expect<List<Number>> = expect(listOf(1, 1.2))
54+
var nSet: Expect<Set<Number?>> = expect(setOf(1, 1.2))
55+
var nCollection: Expect<Set<Number?>> = expect(setOf(null, 1.2))
56+
var subList: Expect<ArrayList<Number>> = expect(arrayListOf(1, 1.2))
57+
var starSet: Expect<Set<*>> = expect(setOf(1, 1.2, "asdf"))
58+
var starCollection: Expect<Collection<*>> = expect(listOf(1, null, "asdf"))
6759

68-
nList = nList.toContain.inAnyOrder.only.elementsOf(emptyList<Int?>())
69-
star = star.toContain.inAnyOrder.only.elementsOf(emptyList<Int?>())
60+
list = list.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2))
61+
nSet = nSet.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2))
62+
nCollection = nCollection.toContain.inAnyOrder.only.elementsOf(listOf(null, 1.2))
63+
subList = subList.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2))
64+
starSet = starSet.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2, "asdf"))
65+
starCollection = starCollection.toContain.inAnyOrder.only.elementsOf(listOf(1, null, "asdf"))
7066

71-
list = list.toContain.inAnyOrder.only.elementsOf(emptyList<Int?>(), report = {})
72-
star = star.toContain.inAnyOrder.only.elementsOf(emptyList<Int?>(), report = {})
67+
list = list.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2), report = {})
68+
nSet = nSet.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2), report = {})
69+
subList = subList.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2), report = {})
70+
nCollection = nCollection.toContain.inAnyOrder.only.elementsOf(listOf(null, 1.2), report = {})
71+
starSet = starSet.toContain.inAnyOrder.only.elementsOf(listOf(1, 1.2, "asdf"), report = {})
72+
starCollection = starCollection.toContain.inAnyOrder.only.elementsOf(listOf(1, null, "asdf"), report = {})
7373
}
7474
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package ch.tutteli.atrium.api.fluent.en_GB
22

3-
import ch.tutteli.atrium.creating.Expect
43
import ch.tutteli.atrium.api.verbs.expect
4+
import ch.tutteli.atrium.creating.Expect
55
import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
6+
import ch.tutteli.atrium.specs.integration.AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest
67
import ch.tutteli.atrium.specs.integration.IterableToContainSpecBase.Companion.emptyInOrderOnlyReportOptions
7-
import ch.tutteli.atrium.specs.notImplemented
88
import ch.tutteli.atrium.specs.withNullableSuffix
99
import kotlin.test.Test
1010

1111
class IterableToContainInAnyOrderOnlyValuesExpectationsTest :
12-
ch.tutteli.atrium.specs.integration.AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest(
12+
AbstractIterableToContainInAnyOrderOnlyValuesExpectationsTest(
1313
functionDescription to Companion::toContainInAnyOrderOnlyValues,
1414
(functionDescription to Companion::toContainInAnyOrderOnlyNullableValues).withNullableSuffix()
1515
) {
@@ -39,38 +39,42 @@ class IterableToContainInAnyOrderOnlyValuesExpectationsTest :
3939
} else expect.toContain.inAnyOrder.only.values(a, *aX, report = report)
4040
}
4141

42-
@Suppress("AssignedValueIsNeverRead")
42+
@Suppress("AssignedValueIsNeverRead", "UNUSED_VARIABLE", "UNUSED_VALUE")
4343
@Test
4444
fun ambiguityTest() {
4545
var list: Expect<List<Number>> = expect(listOf(1))
46-
var nList: Expect<Set<Number?>> = expect(setOf(1))
47-
var subList: Expect<ArrayList<Number>> = expect(arrayListOf<Number>(1))
48-
var star: Expect<Collection<*>> = expect(listOf(1))
46+
var nSet: Expect<Set<Number?>> = expect(setOf(1))
47+
var nCollection: Expect<Collection<Number?>> = expect(setOf(null))
48+
var subList: Expect<ArrayList<Number>> = expect(arrayListOf(1))
49+
var starSet: Expect<Set<*>> = expect(setOf(1))
50+
var starCollection: Expect<Collection<*>> = expect(listOf(null))
4951

5052
var listValues: Expect<List<Number>> = expect(listOf(1, 1.2))
51-
var nListValues: Expect<Set<Number?>> = expect(setOf(1, 1.2))
52-
var subListValues: Expect<ArrayList<Number>> = expect(arrayListOf<Number>(1, 1.2))
53-
var starValues: Expect<Collection<*>> = expect(listOf(1, 1.2))
53+
var nSetValues: Expect<Set<Number?>> = expect(setOf(1, 1.2))
54+
var nCollectionValues: Expect<Set<Number?>> = expect(setOf(null, 1.2))
55+
var subListValues: Expect<ArrayList<Number>> = expect(arrayListOf(1, 1.2))
56+
var starSetValues: Expect<Set<*>> = expect(setOf(1, 1.2, "asdf"))
57+
var starCollectionValues: Expect<Collection<*>> = expect(listOf(1, null, "asdf"))
5458

5559
list = list.toContain.inAnyOrder.only.value(1)
56-
nList = nList.toContain.inAnyOrder.only.value(1)
60+
nSet = nSet.toContain.inAnyOrder.only.value(1)
61+
nCollection = nCollection.toContain.inAnyOrder.only.value(null)
5762
subList = subList.toContain.inAnyOrder.only.value(1)
58-
star = star.toContain.inAnyOrder.only.value(1)
63+
starSet = starSet.toContain.inAnyOrder.only.value(1)
64+
starCollection = starCollection.toContain.inAnyOrder.only.value(null)
5965

6066
listValues = listValues.toContain.inAnyOrder.only.values(1, 1.2)
61-
nListValues = nListValues.toContain.inAnyOrder.only.values(1, 1.2)
62-
subListValues = subListValues.toContain.inAnyOrder.only.values(1, 2.2)
63-
starValues = starValues.toContain.inAnyOrder.only.values(1, 1.2, "asdf")
67+
nSetValues = nSetValues.toContain.inAnyOrder.only.values(1, 1.2)
68+
nCollectionValues = nCollectionValues.toContain.inAnyOrder.only.values(null, 1.2)
69+
subListValues = subListValues.toContain.inAnyOrder.only.values(1, 1.2)
70+
starSetValues = starSetValues.toContain.inAnyOrder.only.values(1, 1.2, "asdf")
71+
starCollectionValues = starCollectionValues.toContain.inAnyOrder.only.values(1, null, "asdf")
6472

6573
listValues = listValues.toContain.inAnyOrder.only.values(1, 1.2, report = {})
66-
nListValues = nListValues.toContain.inAnyOrder.only.values(1, 1.2, report = {})
67-
subListValues = subListValues.toContain.inAnyOrder.only.values(1, 2.2, report = {})
68-
starValues = starValues.toContain.inAnyOrder.only.values(1, 1.2, "asdf", report = {})
69-
70-
nListValues = nListValues.toContain.inAnyOrder.only.values(null, 1.2)
71-
starValues = starValues.toContain.inAnyOrder.only.values(null, 1.2, "asdf")
72-
73-
nListValues = nListValues.toContain.inAnyOrder.only.values(null, 1.2, report = {})
74-
starValues = starValues.toContain.inAnyOrder.only.values(null, 1.2, "asdf", report = {})
74+
nSetValues = nSetValues.toContain.inAnyOrder.only.values(1, 1.2, report = {})
75+
subListValues = subListValues.toContain.inAnyOrder.only.values(1, 1.2, report = {})
76+
nCollectionValues = nCollectionValues.toContain.inAnyOrder.only.values(null, 1.2, report = {})
77+
starSetValues = starSetValues.toContain.inAnyOrder.only.values(1, 1.2, "asdf", report = {})
78+
starCollectionValues = starCollectionValues.toContain.inAnyOrder.only.values(1, null, "asdf", report = {})
7579
}
7680
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
package ch.tutteli.atrium.api.infix.en_GB
22

3+
import ch.tutteli.atrium.api.verbs.expect
34
import ch.tutteli.atrium.creating.Expect
45
import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
56
import 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

Comments
 (0)