feat: make Sequence.all() and Sequence.any() return actual predicate values instead of booleans
Rewrite all() and any() to store and return the predicate's result directly, matching && and || semantics. Update documentation to describe the new behavior. Move tests from test/core/list/ to test/core/sequence/ and add cases verifying that the first falsey/truthy value is returned.
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
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
|
||||
@@ -1 +0,0 @@
|
||||
IO.print([1, 2, 3].all {|x| "truthy" }) // expect: true
|
||||
@@ -1 +0,0 @@
|
||||
[1, 2, 3].all("string") // expect runtime error: String does not implement 'call(_)'.
|
||||
@@ -1,10 +0,0 @@
|
||||
var a = [1, 2, 3]
|
||||
|
||||
var b = a.any {|x| x > 3 }
|
||||
IO.print(b) // expect: false
|
||||
|
||||
var d = a.any {|x| x > 1 }
|
||||
IO.print(d) // expect: true
|
||||
|
||||
var e = [].any {|x| true }
|
||||
IO.print(e) // expect: false
|
||||
@@ -1 +0,0 @@
|
||||
IO.print([1, 2, 3].any {|x| "truthy" }) // expect: true
|
||||
@@ -1 +0,0 @@
|
||||
[1, 2, 3].any("string") // expect runtime error: String does not implement 'call(_)'.
|
||||
Reference in New Issue
Block a user