test: add forall test for empty list and non-bool/non-function args

Add test case verifying that `forall` returns true for an empty list regardless of predicate, and add two new test files covering runtime errors when `forall` receives a non-boolean-returning function or a non-function argument. Also refactor the `forall` implementation to use logical negation (`!`) instead of explicit `!= true` comparison.
This commit is contained in:
Gavin Schulz
2015-01-15 06:42:15 +00:00
parent 580ca8cf27
commit cb1703409c
5 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ static const char* libSource =
"\n"
" forall(f) {\n"
" for (element in this) {\n"
" if (f.call(element) != true) return false\n"
" if (!f.call(element)) return false\n"
" }\n"
" return true\n"
" }\n"