Skip to content

Commit a63daff

Browse files
committed
fix code-generation, also generate drop test for Tuple4 - Tuple9
1 parent 4f382fb commit a63daff

File tree

8 files changed

+867
-12
lines changed

8 files changed

+867
-12
lines changed

gradle/code-generation/src/main/kotlin/code-generation.generate.gradle.kts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ val generate: TaskProvider<Task> = tasks.register("generate") {
343343
""".trimMargin()
344344
).appendLine()
345345

346-
appendMap("a$argNum", "A$argNum", tupleName, if (upperNumber <= 3) "3.2.0" else "2.0.0")
346+
appendMap("a$argNum", "A$argNum", tupleName, if (upperNumber <= 3) "3.2.0" else "2.0.0")
347347
if (upperNumber <= 3) {
348348
val argName = getKotlinArgName(argNum)
349349
val argNameCapitalized = argName.replaceFirstChar {
@@ -362,19 +362,19 @@ val generate: TaskProvider<Task> = tasks.register("generate") {
362362
fun appendDrop(argNameToDrop: String, argNameCapitalized: String, tupleName: String) =
363363
tupleDrop.append(
364364
"""
365-
|/**
366-
| * Creates a new [$tupleNameOneLower] by copying `this` [$tupleName] but dropping its ${
365+
|/**
366+
| * Creates a new [$tupleNameOneLower] by copying `this` [$tupleName] but dropping its ${
367367
withOrdinalIndicator(argNum)
368368
} component ([$tupleName.$argNameToDrop]).
369-
| *
370-
| * @return The newly created [$tupleNameOneLower].
371-
| *
372-
| * @since 3.2.0
373-
| */
374-
|fun <$typeArgs> $tupleName<$typeArgs>.drop$argNameCapitalized(): $tupleNameOneLower<$typeArgsWithoutDrop> =
375-
| Tuple(${numberWithoutDrop.joinToString(", ") { "a$it" }})
376-
|
377-
""".trimMargin()
369+
| *
370+
| * @return The newly created [$tupleNameOneLower].
371+
| *
372+
| * @since 3.2.0
373+
| */
374+
|fun <$typeArgs> $tupleName<$typeArgs>.drop$argNameCapitalized(): $tupleNameOneLower<$typeArgsWithoutDrop> =
375+
| Tuple(${numberWithoutDrop.joinToString(", ") { "a$it" }})
376+
|
377+
""".trimMargin()
378378
).appendLine()
379379

380380
appendDrop("a$argNum", "A$argNum", tupleName)
@@ -1215,6 +1215,7 @@ val generateTest: TaskProvider<Task> = tasks.register("generateTest") {
12151215
).appendLine()
12161216
}
12171217

1218+
appendDropTest("A$argNum")
12181219
if (upperNumber <= 3) {
12191220
val argNameToDrop = getKotlinArgName(argNum)
12201221
val argNameCapitalized = argNameToDrop.replaceFirstChar {

src/commonTest/generated/kotlin/ch/tutteli/kbox/drop/Tuple3DropTest.kt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ import kotlin.test.Test
1111

1212
class Tuple3DropTest {
1313

14+
@Test
15+
fun dropA1() {
16+
val a1 = listOf("string")
17+
val a2 = listOf(1)
18+
val a3 = listOf(2L)
19+
val tuple = Tuple3(a1, a2, a3)
20+
21+
expect(tuple.dropA1()) {
22+
feature { f(it::a1) }.toBeTheInstance(a2)
23+
feature { f(it::a2) }.toBeTheInstance(a3)
24+
}
25+
}
26+
1427
@Test
1528
fun dropFirst() {
1629
val a1 = listOf("string")
@@ -24,6 +37,19 @@ class Tuple3DropTest {
2437
}
2538
}
2639

40+
@Test
41+
fun dropA2() {
42+
val a1 = listOf("string")
43+
val a2 = listOf(1)
44+
val a3 = listOf(2L)
45+
val tuple = Tuple3(a1, a2, a3)
46+
47+
expect(tuple.dropA2()) {
48+
feature { f(it::a1) }.toBeTheInstance(a1)
49+
feature { f(it::a2) }.toBeTheInstance(a3)
50+
}
51+
}
52+
2753
@Test
2854
fun dropSecond() {
2955
val a1 = listOf("string")
@@ -37,6 +63,19 @@ class Tuple3DropTest {
3763
}
3864
}
3965

66+
@Test
67+
fun dropA3() {
68+
val a1 = listOf("string")
69+
val a2 = listOf(1)
70+
val a3 = listOf(2L)
71+
val tuple = Tuple3(a1, a2, a3)
72+
73+
expect(tuple.dropA3()) {
74+
feature { f(it::a1) }.toBeTheInstance(a1)
75+
feature { f(it::a2) }.toBeTheInstance(a2)
76+
}
77+
}
78+
4079
@Test
4180
fun dropThird() {
4281
val a1 = listOf("string")

src/commonTest/generated/kotlin/ch/tutteli/kbox/drop/Tuple4DropTest.kt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,64 @@ import kotlin.test.Test
1111

1212
class Tuple4DropTest {
1313

14+
@Test
15+
fun dropA1() {
16+
val a1 = listOf("string")
17+
val a2 = listOf(1)
18+
val a3 = listOf(2L)
19+
val a4 = listOf(3F)
20+
val tuple = Tuple4(a1, a2, a3, a4)
21+
22+
expect(tuple.dropA1()) {
23+
feature { f(it::a1) }.toBeTheInstance(a2)
24+
feature { f(it::a2) }.toBeTheInstance(a3)
25+
feature { f(it::a3) }.toBeTheInstance(a4)
26+
}
27+
}
28+
29+
@Test
30+
fun dropA2() {
31+
val a1 = listOf("string")
32+
val a2 = listOf(1)
33+
val a3 = listOf(2L)
34+
val a4 = listOf(3F)
35+
val tuple = Tuple4(a1, a2, a3, a4)
36+
37+
expect(tuple.dropA2()) {
38+
feature { f(it::a1) }.toBeTheInstance(a1)
39+
feature { f(it::a2) }.toBeTheInstance(a3)
40+
feature { f(it::a3) }.toBeTheInstance(a4)
41+
}
42+
}
43+
44+
@Test
45+
fun dropA3() {
46+
val a1 = listOf("string")
47+
val a2 = listOf(1)
48+
val a3 = listOf(2L)
49+
val a4 = listOf(3F)
50+
val tuple = Tuple4(a1, a2, a3, a4)
51+
52+
expect(tuple.dropA3()) {
53+
feature { f(it::a1) }.toBeTheInstance(a1)
54+
feature { f(it::a2) }.toBeTheInstance(a2)
55+
feature { f(it::a3) }.toBeTheInstance(a4)
56+
}
57+
}
58+
59+
@Test
60+
fun dropA4() {
61+
val a1 = listOf("string")
62+
val a2 = listOf(1)
63+
val a3 = listOf(2L)
64+
val a4 = listOf(3F)
65+
val tuple = Tuple4(a1, a2, a3, a4)
66+
67+
expect(tuple.dropA4()) {
68+
feature { f(it::a1) }.toBeTheInstance(a1)
69+
feature { f(it::a2) }.toBeTheInstance(a2)
70+
feature { f(it::a3) }.toBeTheInstance(a3)
71+
}
72+
}
73+
1474
}

src/commonTest/generated/kotlin/ch/tutteli/kbox/drop/Tuple5DropTest.kt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,89 @@ import kotlin.test.Test
1111

1212
class Tuple5DropTest {
1313

14+
@Test
15+
fun dropA1() {
16+
val a1 = listOf("string")
17+
val a2 = listOf(1)
18+
val a3 = listOf(2L)
19+
val a4 = listOf(3F)
20+
val a5 = listOf(4.0)
21+
val tuple = Tuple5(a1, a2, a3, a4, a5)
22+
23+
expect(tuple.dropA1()) {
24+
feature { f(it::a1) }.toBeTheInstance(a2)
25+
feature { f(it::a2) }.toBeTheInstance(a3)
26+
feature { f(it::a3) }.toBeTheInstance(a4)
27+
feature { f(it::a4) }.toBeTheInstance(a5)
28+
}
29+
}
30+
31+
@Test
32+
fun dropA2() {
33+
val a1 = listOf("string")
34+
val a2 = listOf(1)
35+
val a3 = listOf(2L)
36+
val a4 = listOf(3F)
37+
val a5 = listOf(4.0)
38+
val tuple = Tuple5(a1, a2, a3, a4, a5)
39+
40+
expect(tuple.dropA2()) {
41+
feature { f(it::a1) }.toBeTheInstance(a1)
42+
feature { f(it::a2) }.toBeTheInstance(a3)
43+
feature { f(it::a3) }.toBeTheInstance(a4)
44+
feature { f(it::a4) }.toBeTheInstance(a5)
45+
}
46+
}
47+
48+
@Test
49+
fun dropA3() {
50+
val a1 = listOf("string")
51+
val a2 = listOf(1)
52+
val a3 = listOf(2L)
53+
val a4 = listOf(3F)
54+
val a5 = listOf(4.0)
55+
val tuple = Tuple5(a1, a2, a3, a4, a5)
56+
57+
expect(tuple.dropA3()) {
58+
feature { f(it::a1) }.toBeTheInstance(a1)
59+
feature { f(it::a2) }.toBeTheInstance(a2)
60+
feature { f(it::a3) }.toBeTheInstance(a4)
61+
feature { f(it::a4) }.toBeTheInstance(a5)
62+
}
63+
}
64+
65+
@Test
66+
fun dropA4() {
67+
val a1 = listOf("string")
68+
val a2 = listOf(1)
69+
val a3 = listOf(2L)
70+
val a4 = listOf(3F)
71+
val a5 = listOf(4.0)
72+
val tuple = Tuple5(a1, a2, a3, a4, a5)
73+
74+
expect(tuple.dropA4()) {
75+
feature { f(it::a1) }.toBeTheInstance(a1)
76+
feature { f(it::a2) }.toBeTheInstance(a2)
77+
feature { f(it::a3) }.toBeTheInstance(a3)
78+
feature { f(it::a4) }.toBeTheInstance(a5)
79+
}
80+
}
81+
82+
@Test
83+
fun dropA5() {
84+
val a1 = listOf("string")
85+
val a2 = listOf(1)
86+
val a3 = listOf(2L)
87+
val a4 = listOf(3F)
88+
val a5 = listOf(4.0)
89+
val tuple = Tuple5(a1, a2, a3, a4, a5)
90+
91+
expect(tuple.dropA5()) {
92+
feature { f(it::a1) }.toBeTheInstance(a1)
93+
feature { f(it::a2) }.toBeTheInstance(a2)
94+
feature { f(it::a3) }.toBeTheInstance(a3)
95+
feature { f(it::a4) }.toBeTheInstance(a4)
96+
}
97+
}
98+
1499
}

src/commonTest/generated/kotlin/ch/tutteli/kbox/drop/Tuple6DropTest.kt

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,118 @@ import kotlin.test.Test
1111

1212
class Tuple6DropTest {
1313

14+
@Test
15+
fun dropA1() {
16+
val a1 = listOf("string")
17+
val a2 = listOf(1)
18+
val a3 = listOf(2L)
19+
val a4 = listOf(3F)
20+
val a5 = listOf(4.0)
21+
val a6 = listOf('c')
22+
val tuple = Tuple6(a1, a2, a3, a4, a5, a6)
23+
24+
expect(tuple.dropA1()) {
25+
feature { f(it::a1) }.toBeTheInstance(a2)
26+
feature { f(it::a2) }.toBeTheInstance(a3)
27+
feature { f(it::a3) }.toBeTheInstance(a4)
28+
feature { f(it::a4) }.toBeTheInstance(a5)
29+
feature { f(it::a5) }.toBeTheInstance(a6)
30+
}
31+
}
32+
33+
@Test
34+
fun dropA2() {
35+
val a1 = listOf("string")
36+
val a2 = listOf(1)
37+
val a3 = listOf(2L)
38+
val a4 = listOf(3F)
39+
val a5 = listOf(4.0)
40+
val a6 = listOf('c')
41+
val tuple = Tuple6(a1, a2, a3, a4, a5, a6)
42+
43+
expect(tuple.dropA2()) {
44+
feature { f(it::a1) }.toBeTheInstance(a1)
45+
feature { f(it::a2) }.toBeTheInstance(a3)
46+
feature { f(it::a3) }.toBeTheInstance(a4)
47+
feature { f(it::a4) }.toBeTheInstance(a5)
48+
feature { f(it::a5) }.toBeTheInstance(a6)
49+
}
50+
}
51+
52+
@Test
53+
fun dropA3() {
54+
val a1 = listOf("string")
55+
val a2 = listOf(1)
56+
val a3 = listOf(2L)
57+
val a4 = listOf(3F)
58+
val a5 = listOf(4.0)
59+
val a6 = listOf('c')
60+
val tuple = Tuple6(a1, a2, a3, a4, a5, a6)
61+
62+
expect(tuple.dropA3()) {
63+
feature { f(it::a1) }.toBeTheInstance(a1)
64+
feature { f(it::a2) }.toBeTheInstance(a2)
65+
feature { f(it::a3) }.toBeTheInstance(a4)
66+
feature { f(it::a4) }.toBeTheInstance(a5)
67+
feature { f(it::a5) }.toBeTheInstance(a6)
68+
}
69+
}
70+
71+
@Test
72+
fun dropA4() {
73+
val a1 = listOf("string")
74+
val a2 = listOf(1)
75+
val a3 = listOf(2L)
76+
val a4 = listOf(3F)
77+
val a5 = listOf(4.0)
78+
val a6 = listOf('c')
79+
val tuple = Tuple6(a1, a2, a3, a4, a5, a6)
80+
81+
expect(tuple.dropA4()) {
82+
feature { f(it::a1) }.toBeTheInstance(a1)
83+
feature { f(it::a2) }.toBeTheInstance(a2)
84+
feature { f(it::a3) }.toBeTheInstance(a3)
85+
feature { f(it::a4) }.toBeTheInstance(a5)
86+
feature { f(it::a5) }.toBeTheInstance(a6)
87+
}
88+
}
89+
90+
@Test
91+
fun dropA5() {
92+
val a1 = listOf("string")
93+
val a2 = listOf(1)
94+
val a3 = listOf(2L)
95+
val a4 = listOf(3F)
96+
val a5 = listOf(4.0)
97+
val a6 = listOf('c')
98+
val tuple = Tuple6(a1, a2, a3, a4, a5, a6)
99+
100+
expect(tuple.dropA5()) {
101+
feature { f(it::a1) }.toBeTheInstance(a1)
102+
feature { f(it::a2) }.toBeTheInstance(a2)
103+
feature { f(it::a3) }.toBeTheInstance(a3)
104+
feature { f(it::a4) }.toBeTheInstance(a4)
105+
feature { f(it::a5) }.toBeTheInstance(a6)
106+
}
107+
}
108+
109+
@Test
110+
fun dropA6() {
111+
val a1 = listOf("string")
112+
val a2 = listOf(1)
113+
val a3 = listOf(2L)
114+
val a4 = listOf(3F)
115+
val a5 = listOf(4.0)
116+
val a6 = listOf('c')
117+
val tuple = Tuple6(a1, a2, a3, a4, a5, a6)
118+
119+
expect(tuple.dropA6()) {
120+
feature { f(it::a1) }.toBeTheInstance(a1)
121+
feature { f(it::a2) }.toBeTheInstance(a2)
122+
feature { f(it::a3) }.toBeTheInstance(a3)
123+
feature { f(it::a4) }.toBeTheInstance(a4)
124+
feature { f(it::a5) }.toBeTheInstance(a5)
125+
}
126+
}
127+
14128
}

0 commit comments

Comments
 (0)