diff options
author | Urban Müller | 2020-04-21 01:03:53 +0200 |
---|---|---|
committer | Urban Müller | 2020-04-21 01:03:53 +0200 |
commit | d987adefc85095f057c3d6d3eb2fa4c0d487d32b (patch) | |
tree | 4a6f7be8e35ff0c412666c41a46f22383d8ed5c2 /test/exec.t | |
parent | 1bd13e02d21ba01f38cd6df04de84b25a75a5264 (diff) | |
download | itools-d987adefc85095f057c3d6d3eb2fa4c0d487d32b.tar.gz itools-d987adefc85095f057c3d6d3eb2fa4c0d487d32b.tar.bz2 itools-d987adefc85095f057c3d6d3eb2fa4c0d487d32b.zip |
use new array syntax
Diffstat (limited to 'test/exec.t')
-rwxr-xr-x | test/exec.t | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/test/exec.t b/test/exec.t index c155c88..293ad61 100755 --- a/test/exec.t +++ b/test/exec.t @@ -4,71 +4,71 @@ # Tests for getopt in it.class is(it::exec("echo gna"), "gna\n", "basic exec"); -is(it::exec("echo {arg}", array('arg' => 'gna')), "gna\n", "exec with argument"); +is(it::exec("echo {arg}", ['arg' => 'gna']), "gna\n", "exec with argument"); is(it::exec("echo {0}", 'gna'), "gna\n", "exec with positional argument"); -is(it::shell_command("echo {arg}", array('arg' => 'gna07,-:blah')), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters"); -is(it::shell_command("echo {arg}", array('arg' => '2>&1')), "echo '2>&1'", "quote arguments with dangerous characters"); -is(it::shell_command("echo {arg}", array('arg' => '')), "echo ''", "quote empty arguments"); +is(it::shell_command("echo {arg}", ['arg' => 'gna07,-:blah']), "echo gna07,-:blah", "don't quote arguments with only whitelistes characters"); +is(it::shell_command("echo {arg}", ['arg' => '2>&1']), "echo '2>&1'", "quote arguments with dangerous characters"); +is(it::shell_command("echo {arg}", ['arg' => '']), "echo ''", "quote empty arguments"); is( - it::shell_command("echo {-opts}", array('-opts' => array('--longopt' => true))), + it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => true]]), "echo --longopt", "options argument with long option" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('-onedash' => true))), + it::shell_command("echo {-opts}", ['-opts' => ['-onedash' => true]]), "echo -onedash", "... with long option but only one dash" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('-s' => true))), + it::shell_command("echo {-opts}", ['-opts' => ['-s' => true]]), "echo -s", "... with short option" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('--longopt' => 'val'))), + it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => 'val']]), "echo --longopt val", "... with long option with value" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('-onedash' => 'val'))), + it::shell_command("echo {-opts}", ['-opts' => ['-onedash' => 'val']]), "echo -onedash val", "... with long option but only one dash and with value" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('-s' => 'val'))), + it::shell_command("echo {-opts}", ['-opts' => ['-s' => 'val']]), "echo -s val", "... with short option with value" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('--longopt' => false))), + it::shell_command("echo {-opts}", ['-opts' => ['--longopt' => false]]), "echo ", "... with disabled long option" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('-s' => false))), + it::shell_command("echo {-opts}", ['-opts' => ['-s' => false]]), "echo ", "... with disabled short option" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('longopt' => true))), + it::shell_command("echo {-opts}", ['-opts' => ['longopt' => true]]), "echo --longopt", "... long option without dashes" ); is( - it::shell_command("echo {-opts}", array('-opts' => array('s' => true))), + it::shell_command("echo {-opts}", ['-opts' => ['s' => true]]), "echo -s", "... short option without dashes" ); -foreach (array("", "C", "de_CH", "de_CH.utf8") as $locale) { +foreach (["", "C", "de_CH", "de_CH.utf8"] as $locale) { setlocale(LC_ALL, $locale); $arg = "preüpost"; if (it::match('utf8', $locale)) $arg = utf8_encode($arg); is(it::exec("echo " . $arg), $arg . "\n", "exec with umlaut (locale '$locale')"); - is(it::exec("echo {arg}", array('arg' => $arg)), $arg . "\n", "exec with argument and umlaut (locale '$locale')"); + is(it::exec("echo {arg}", ['arg' => $arg]), $arg . "\n", "exec with argument and umlaut (locale '$locale')"); } is(it::_exec_quotevalue(""), "''", "empty arg needs quotes"); @@ -84,7 +84,7 @@ it::system('touch /tmp/it_system_test'); ok(file_exists('/tmp/it_system_test'), 'shell command gets executed'); @unlink('/tmp/it_system_test'); -it::system('touch {path}', array('path' => '/tmp/it_system_test')); +it::system('touch {path}', ['path' => '/tmp/it_system_test']); ok(file_exists('/tmp/it_system_test'), 'shell command with argument'); @unlink('/tmp/it_system_test'); |