flow-mumu 0.2.0-rc.9

Stream transform tools plugin for the Lava language
Documentation
extend("test")
extend("flow")

describe("flow:to_array", () => {

  it("collects ints from iterator (end-exclusive)", () => {
    out = flow:to_array(ink(1,5))
    expect_equal(out, [1,2,3,4])
  })

  it("collects after transform", () => {
    out = flow:compose(
      flow:to_array,
      flow:trans(x => x * 3)
    )(ink(1,5))
    expect_equal(out, [3,6,9,12])
  })

  it("collects floats when mapper returns floats", () => {
    out = flow:compose(
      flow:to_array,
      flow:trans(x => x * 0.5)
    )(ink(1,5))
    expect_equal(out, [0.5,1.0,1.5,2.0])
  })

  it("errors on non-stream input", () => {
    test:expect_error(() => {
      flow:to_array(42)
    }, "InkIterator or InkTransform")
  })
})