navi/test/func_test.sh
2019-09-27 15:12:55 -03:00

27 lines
402 B
Bash

#!/usr/bin/env bash
inc() {
local -r x="$1"
echo $((x+1))
}
sum() {
local -r x="$1"
local -r y="$2"
echo $((x*y))
}
func_map() {
func::list 1 2 3 \
| func::map inc \
| test::equals "$(func::list 2 3 4)"
}
func_reduce() {
func::list 1 2 3 \
| func::reduce sum 10 \
| test::equals 60
}
test::run "map works" func_map
test::run "reduce works" func_reduce