feat: add Sequence.all method and forall documentation with tests
Implement `all(f)` method on Sequence class that returns true if all elements pass the predicate function. Add corresponding documentation entry for `forall(predicate)` in core-library.markdown. Include three test files covering basic functionality, non-boolean return handling, and non-function argument error cases.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
var a = [1, 2, 3]
|
||||
var b = a.all {|x| x > 1 }
|
||||
IO.print(b) // expect: false
|
||||
|
||||
var d = a.all {|x| x > 0 }
|
||||
IO.print(d) // expect: true
|
||||
|
||||
var e = [].all {|x| false }
|
||||
IO.print(e) // expect: true
|
||||
@@ -0,0 +1 @@
|
||||
[1, 2, 3].all {|x| "string" } // expect runtime error: String does not implement method '!' with 0 arguments.
|
||||
@@ -0,0 +1 @@
|
||||
[1, 2, 3].all("string") // expect runtime error: String does not implement method 'call' with 1 argument.
|
||||
Reference in New Issue
Block a user