Add more tests
This commit is contained in:
parent
11f8cffec6
commit
f254b98a3f
10 changed files with 60 additions and 0 deletions
15
test/append_test.sh
Executable file
15
test/append_test.sh
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
testAppendToEmptyList() {
|
||||||
|
assertEquals 4 "$(list | append 4)"
|
||||||
|
}
|
||||||
|
|
||||||
|
testAppendToOneElementList() {
|
||||||
|
assertEquals "1 4" "$(list 1 | append 4 | unlist)"
|
||||||
|
}
|
||||||
|
|
||||||
|
testAppendToList() {
|
||||||
|
assertEquals "1 2 3 4 5 4" "$(list 1 2 3 4 5 | append 4 | unlist)"
|
||||||
|
}
|
||||||
|
|
||||||
|
. ./shunit2-init.sh
|
0
test/drop_test.sh
Normal file → Executable file
0
test/drop_test.sh
Normal file → Executable file
0
test/head_test.sh
Normal file → Executable file
0
test/head_test.sh
Normal file → Executable file
30
test/lambda_test.sh
Executable file
30
test/lambda_test.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
testLambdaOneArgument() {
|
||||||
|
identity() {
|
||||||
|
lambda x . '$x'
|
||||||
|
}
|
||||||
|
assertEquals "hi there !" "$(identity <<< 'echo hi there !')"
|
||||||
|
assertEquals 3 $(lambda x . 'echo $(($x + 1))' <<< '2')
|
||||||
|
assertEquals "hi there !" "$(λ x . 'echo $x' <<< 'hi there !')"
|
||||||
|
}
|
||||||
|
|
||||||
|
testLambdaSymbolTwoArguments() {
|
||||||
|
assertEquals 3 $(echo -e '1\n2' | lambda x y . 'echo $(($x + $y))')
|
||||||
|
assertEquals 5 $(echo -e '7\n2' | λ x y . 'echo $(($x - $y))')
|
||||||
|
}
|
||||||
|
|
||||||
|
testLambdaSymbolManyArguments() {
|
||||||
|
assertEquals 5 $(echo -e '1\n2\n3\n4\n5' | lambda a b c d e . 'echo $(($a + $b + $c + $d - $e))')
|
||||||
|
}
|
||||||
|
|
||||||
|
testLambdaSymbolManyArguments_ifInsufficientNumberOfArgumentsInLambda() {
|
||||||
|
assertEquals 6 $(echo -e '1\n2\n3\n4\n5' | lambda a b c . 'echo $(($a + $b + $c))')
|
||||||
|
}
|
||||||
|
|
||||||
|
testLambdaSymbolManyArguments_ifInsufficientNumberOfInputArguments() {
|
||||||
|
echo -e '1\n2' | lambda a b c d e . 'echo $(($a + $b + $c + $d + $e))' 2> /dev/null \
|
||||||
|
&& fail "There should be syntax error"
|
||||||
|
}
|
||||||
|
|
||||||
|
. ./shunit2-init.sh
|
0
test/last_test.sh
Normal file → Executable file
0
test/last_test.sh
Normal file → Executable file
0
test/list_test.sh
Normal file → Executable file
0
test/list_test.sh
Normal file → Executable file
15
test/prepend_test.sh
Executable file
15
test/prepend_test.sh
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
testPrependToEmptyList() {
|
||||||
|
assertEquals 4 "$(list | prepend 4)"
|
||||||
|
}
|
||||||
|
|
||||||
|
testPrependToOneElementList() {
|
||||||
|
assertEquals "4 1" "$(list 1 | prepend 4 | unlist)"
|
||||||
|
}
|
||||||
|
|
||||||
|
testPrependToList() {
|
||||||
|
assertEquals "4 1 2 3 4 5" "$(list 1 2 3 4 5 | prepend 4 | unlist)"
|
||||||
|
}
|
||||||
|
|
||||||
|
. ./shunit2-init.sh
|
0
test/tail_test.sh
Normal file → Executable file
0
test/tail_test.sh
Normal file → Executable file
0
test/take_test.sh
Normal file → Executable file
0
test/take_test.sh
Normal file → Executable file
0
test/unlist_test.sh
Normal file → Executable file
0
test/unlist_test.sh
Normal file → Executable file
Loading…
Reference in a new issue