More tests...
This commit is contained in:
parent
f254b98a3f
commit
cb9eff8b81
3 changed files with 43 additions and 0 deletions
|
@ -1,5 +1,13 @@
|
|||
#! /bin/bash
|
||||
|
||||
testLambdaNoArguments_ifNoInput() {
|
||||
assertEquals 'Hi there' "$(echo | lambda . 'echo Hi there')"
|
||||
}
|
||||
|
||||
testLambdaNoArguments_ifSomeInputArguments() {
|
||||
assertEquals 'Hi there' "$(echo 'xx\nyy\nzz' | lambda . 'echo Hi there')"
|
||||
}
|
||||
|
||||
testLambdaOneArgument() {
|
||||
identity() {
|
||||
lambda x . '$x'
|
||||
|
|
33
test/map_test.sh
Executable file
33
test/map_test.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
testMapEmptyList() {
|
||||
assertEquals "" "$(list | map lambda x . 'echo $(($x + 1))')"
|
||||
}
|
||||
|
||||
testMapEmptyList_ifNoArgumentsInLambda() {
|
||||
assertEquals "" "$(list | map lambda . 'echo 3')"
|
||||
}
|
||||
|
||||
testMapOneElementList() {
|
||||
assertEquals "3" "$(list 2 | map lambda x . 'echo $(($x + 1))')"
|
||||
}
|
||||
|
||||
testMapList() {
|
||||
assertEquals "2 3 4 5 6" "$(list {1..5} | map lambda x . 'echo $(($x + 1))' | unlist)"
|
||||
}
|
||||
|
||||
testMapList_ifNoArgumentsInLambda() {
|
||||
assertEquals "9 9 9 9 9" "$(list {1..5} | map lambda . 'echo 9' | unlist)"
|
||||
}
|
||||
|
||||
testMapList_ifManyArgumentsInLambda() {
|
||||
list {1..5} | map lambda x y . 'echo $(($x + $y))' 2> /dev/null \
|
||||
&& fail "There should be syntax error, because map is an one argument operation"
|
||||
}
|
||||
|
||||
testFlatMap() {
|
||||
assertEquals "1 2 3 2 3 3" "$(list {1..3} | map lambda x . 'seq $x 3' | unlist)"
|
||||
assertEquals "d e h l l l o o r w" "$(list hello world | map lambda x . 'command fold -w 1 <<< $x' | sort | unlist)"
|
||||
}
|
||||
|
||||
. ./shunit2-init.sh
|
|
@ -1,3 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
oneTimeSetUp() {
|
||||
. ../src/fun.sh
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue