Add a new test file `test/range/reduce.wren` that validates the `reduce` method on numeric ranges. The test exercises two cases: summing integers 1 through 10 (expecting 55) and finding the minimum value with an initial accumulator of 100 (expecting 1).
5 lines
137 B
Plaintext
5 lines
137 B
Plaintext
var range = 1..10
|
|
|
|
IO.print(range.reduce {|a, b| a + b }) // expect: 55
|
|
IO.print(range.reduce(100) {|a, b| a < b ? a : b }) // expect: 1
|