File tree Expand file tree Collapse file tree 2 files changed +212
-110
lines changed
src-gen/test/java/io/vavr Expand file tree Collapse file tree 2 files changed +212
-110
lines changed Original file line number Diff line number Diff line change @@ -3130,13 +3130,19 @@ def generateTestClasses(): Unit = {
31303130 s " $mtype. ${builderName}( $j) "
31313131 } else {
31323132 val args = (1 until j).map(k => s " r $k" ).mkString(" , " )
3133- s " ( $args) -> $mtype. ${builderName}( $j) "
3133+ val argsUsed = (1 until j).map(k => s " r $k" ).mkString(" + " )
3134+ s " ( $args) -> $mtype. ${builderName}( ${argsUsed} + $j) "
31343135 } )(" ,\n " )}
31353136 ).yield( ${(i > 1 ).gen(" (" )}${(1 to i).gen(j => s " i $j" )(" , " )}${(i > 1 ).gen(" )" )} -> ${(1 to i).gen(j => s " i $j" )(" + " )});
3136- $assertThat(result.get()).isEqualTo( ${(1 to i).sum});
3137+
3138+ // Each step builds on the sum of all previous results plus its index
3139+ // This forms a sequence rₙ = 2ⁿ - 1, and the yield sums all rᵢ.
3140+ // Hence total = Σ(2ⁱ - 1) for i = 1..n = (2ⁿ⁺¹ - 2) - n
3141+ assertThat(result.get()).isEqualTo((1 << ( $i + 1)) - 2 - $i);
31373142 }
31383143 """ })(" \n\n " ))(" \n\n " )}
31393144
3145+
31403146 ${monadicFunctionTypesFor.gen(mtype => (1 to N ).gen(i => { xs """
31413147 @ $test
31423148 public void shouldIterateFor $mtype$i() {
You can’t perform that action at this time.
0 commit comments