diff options
author | Nathan Gass | 2020-11-27 12:31:32 +0100 |
---|---|---|
committer | Nathan Gass | 2020-11-27 12:42:38 +0100 |
commit | 1b03f72e7edc609b326927dfebc9f3f0bd6228a1 (patch) | |
tree | d717c958199d417ccb4940057fd693d75d5e4bb8 /test | |
parent | 39dbd947f59394fab9238f7faaab74390aa0b783 (diff) | |
download | itools-1b03f72e7edc609b326927dfebc9f3f0bd6228a1.tar.gz itools-1b03f72e7edc609b326927dfebc9f3f0bd6228a1.tar.bz2 itools-1b03f72e7edc609b326927dfebc9f3f0bd6228a1.zip |
pass array values instead of keys to functions with only one argument in it::map and it::filter
Diffstat (limited to 'test')
-rwxr-xr-x | test/it.t | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -448,6 +448,7 @@ is(it::mod(7, 4), 3); is(it::map('5*$k+$v', [0 => 1, 1 => 2]), [1, 7]); is(it::map(function($k, $v) {return 5*$k+$v;}, [0 => 1, 1 => 2]), [1, 7]); +is(it::map(function($v) {return 2*$v;}, [0 => 1, 1 => 2]), [2, 4]); is(it::map('strlen', ["aaa", "aa"]), [3, 2]); is(it::map('it::ucfirst', ["aaa"]), ["Aaa"]); $dom = new DOMDocument; @@ -465,6 +466,8 @@ is(it::map('2*$v', ['foo' => 1, 'bar' => 2], ['keys' => 'foo']), ['foo' => 2, 'b # it::filter is(it::filter('$v > 2', [1, 5 => 2, 2 => 3]), [2 => 3]); is(it::filter('$k > 2', [1, 5 => 2, 2 => 3]), [5 => 2]); +is(it::filter(function($v) {return $v > 2;}, [1, 5 => 2, 2 => 3]), [2 => 3]); +is(it::filter(function($k, $v) {return $k > 2;}, [1, 5 => 2, 2 => 3]), [5 => 2]); is(it::split("b", "aba"), ["a", "a"]); is(it::split("b", "aBa"), ["a", "a"]); |