Since bash does not have first-class functions, I mimic anonymous functions by passing a string to a function, which is then evaluated by eval .
it() { echo "$1"
This allows you to write very concise tests (it defines the specification). Now I am wondering if this is a valid use of eval.
EDIT
I know that opening {and closing} is not needed in an anonymous function string, just like that it looks like something like Jasmine.
EDIT
pseudo anonymous function is actually a test, which means that at the end of the test there is something like
[[ var == 'foo' ]]
or
((i > 10))
i.e. some kind of test (or argue in terms of XUnit). He never needs to return anything but a return code, which is then evaluated, and if the return code is 0 (success), the description is printed in green, otherwise in red (test failed).
source share