tests/testthat/test-8-functionals.R

testthat(
    "8.1 map stream",
    code = {
        mapped <- ReadableStream$new(1:100) %|>%
            map_stream(function(chunk) {
                as.character(chunk)
            })

    }
)

testthat(
    "8.2 filter stream",
    code = {
        filtered <- ReadableStream$new(1:100) %|>%
            filter_stream(function(chunk) {
                chunk > 50
            })
    }
)

testthat(
    "8.3 reduce stream",
    code = {
        reduced <- ReadableStream$new(1:100) %|>%
            reduce_stream(function(total, chunk) {
                sum(total, chunk)
            })
    }
)

testthat(
    "8.4 walk stream",
    code = {
walked <- ReadableStream$new(1:100) %|>%
    walk_stream(function(data) {
        print(data)
    })

    }
)

testthat(
    "8.5 collect stream",
    code = {
        collected <- ReadableStream$new(1:100) %|>%
            collect_stream()
    }
)

testthat(
    "8.6 batch stream",
    code = {
        batched <- ReadableStream$new(1:100) %|>%
            batch_stream(5)
    }
)
ElianHugh/emitters documentation built on Feb. 6, 2022, 4:55 a.m.