summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorUrban Müller2017-01-25 16:05:28 +0100
committerUrban Müller2017-01-25 16:05:28 +0100
commitf59a46a6dfe0194ba43092304029b2b843ed54bc (patch)
tree1d5222d16101f27891408c8ce4e62726b2035199 /tests
parentb0f1f6067066ac5c4216672181150431270611bc (diff)
downloaditools-f59a46a6dfe0194ba43092304029b2b843ed54bc.tar.gz
itools-f59a46a6dfe0194ba43092304029b2b843ed54bc.tar.bz2
itools-f59a46a6dfe0194ba43092304029b2b843ed54bc.zip
optional keys selection in it::map
Diffstat (limited to 'tests')
-rwxr-xr-xtests/it.t7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/it.t b/tests/it.t
index 1a4ccf9..c276d49 100755
--- a/tests/it.t
+++ b/tests/it.t
@@ -12,7 +12,6 @@ $oldlocale = setlocale(LC_CTYPE, 0);
ini_set('default_charset', 'utf-8');
setlocale(LC_CTYPE, 'de_CH'); # required becuase we're checking German umlauts in latin1 mode
-
function match($regex, $string, $expect, $name, $p = array())
{
$GLOBALS['TEST_MORE_LEVEL'] = 1;
@@ -418,3 +417,9 @@ is(it::mod(7, 4), 3);
is(it::map('5*$k+$v', array(0 => 1, 1 => 2)), array(1, 7));
is(it::map(create_function('$k,$v', 'return 5*$k+$v;'), array(0 => 1, 1 => 2)), array(1, 7));
is(it::map(function($k, $v) {return 5*$k+$v;}, array(0 => 1, 1 => 2)), array(1, 7));
+is(it::map('strlen', array("aaa", "aa")), array(3, 2));
+is(it::map('it::ucfirst', array("aaa")), array("Aaa"));
+# Only map selected keys
+is(it::map('2*$v', [3, 4, 5], 'keys' => '0,1'), [6, 8, 5]);
+is(it::map('2*$v', [3, 4, 5], 'keys' => [0,1]), [6, 8, 5]);
+is(it::map('2*$v', ['foo' => 1, 'bar' => 2], 'keys' => 'foo'), ['foo' => 2, 'bar' =>2]);