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

tail = array:tail
reduce = array:reduce
append = array:append
range = array:range
arb   = math:arb

describe("fibonacci with arb precision", () => {

  it("should generate a small fibonacci sequence with decimal multiplication", () => {
    fibonacci_arb = compose(
      tail,
      reduce(
        (acc, i) => append(
          i > 1
            ? arb(
                array:join("+", [
                  acc[i],
                  acc[i - 1]
                ])
              )
            : string:to_string(i),
          acc
        ),
        ["0"]  # initial array with single string "0"
      ),
      range(0)
    )

    fibs = fibonacci_arb(8)

    expect_equal(array:length(fibs), 8)

    expect_equal( fibs[0], "0" )   
    expect_equal( fibs[1], "1" )
    expect_equal( fibs[2], "1" )
    expect_equal( fibs[3], "2" )
  })
})

