extend("test")
extend("array")
extend("math")
extend("string")

describe("array:reduce basic usage", () => {
  it("should sum up a list of integers", () => {
    expect_equal(
      array:reduce( (acc, x) => acc + x, 0, [1,2,3,4] ),
      10
    )
  })
})

describe("array:reduce partial usage", () => {
  it("should allow partial usage for the function and initial value", () => {
    sumReducer = array:reduce((acc, x) => acc + x, 100)

    expect_equal( sumReducer([10,20,5]), 135 )
  })

  it("should allow placeholder usage for the initial value", () => {
    partialReducer = array:reduce((acc, x) => acc * x, _, [2,5,5])

    expect_equal( partialReducer(1), 50 )
  })
})

