mumu 0.11.1

Lava Mumu is a language for those in the now and that know
Documentation
# FILE: tests/flow_slice_test.mu

extend("flow")
extend("test")
extend("array")

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

  it("should skip the first item, then yield next 4 items from an ink(0..50)", () => {

    actual = flow:compose(
      flow:to_array,
      flow:slice(1,4),
      flow:trans(n => n * 10)
    )(ink(1,50))

    expect_equal(actual, [20,30,40,50])
  })
/*
  it("can skip 2, produce 2 => partial usage for the third argument", () => {
    partial = flow:slice(2, 2)
    # partial => waiting for the InkIterator
    finalSlice = partial( ink(10,15) )
    # ink(10,15) => [10,11,12,13,14]
    # skip the first 2 => skip 10,11 => yield next 2 => [12,13]
    out = array:map(x => x, finalSlice)
    expect_equal(out, [12,13])
  })

  it("handles placeholders => known ink, missing start+count", () => {
    partial2 = flow:slice(_, _, ink(3,8))
    # ink(3,8) => [3,4,5,6,7]
    # Provide the start, count => skip=1 => produce=3 => yields [4,5,6]
    final2 = partial2(1, 3)
    out2 = array:map(x => x, final2)
    expect_equal(out2, [4,5,6])
  })

  it("composes with flow:trans or another transform => partial usage", () => {
    # We'll do a transform => multiply by 10, then slice from item #2 for 2 items
    transPart = flow:trans(x => x * 10)
    slicePart = flow:slice(2,2)
    # Compose them manually => feed the transform output as the 'data' to slice
    # or do something like flow:compose if you want chaining. We'll do direct:
    transformResult = transPart( ink(1,6) )
    # transPart => yields [1,2,3,4,5] => times 10 => [10,20,30,40,50]
    finalSlice2 = slicePart(transformResult)
    # skip=2 => skip [10,20] => yield next 2 => [30,40]
    out3 = array:map(x => x, finalSlice2)
    expect_equal(out3, [30,40])
  })

  it("should error if third arg is not an InkIterator or InkTransform", () => {
    test:expect_error(() => {
      flow:slice(1,2, 999)
    })
    test:expect_error(() => {
      flow:slice(1,2, [1,2,3])
    })
  })
*/
})