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:
+1
-1
@@ -17,7 +17,7 @@ class Sequence {
|
||||
|
||||
forall(f) {
|
||||
for (element in this) {
|
||||
if (f.call(element) != true) return false
|
||||
if (!f.call(element)) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user