2013-12-16 14:07:48 -08:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Test::More;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
2014-09-27 06:42:57 -07:00
|
|
|
zci answer_type => 'expression_description';
|
|
|
|
zci is_cached => 1;
|
2013-12-16 14:07:48 -08:00
|
|
|
|
|
|
|
ddg_goodie_test(
|
2014-03-30 15:15:32 -07:00
|
|
|
[
|
|
|
|
'DDG::Goodie::BashPrimaryExpressions'
|
|
|
|
],
|
|
|
|
"bash [ -a b ]" => test_zci(
|
2014-04-03 07:41:39 -07:00
|
|
|
qr/.+ true if b exists./,
|
2014-03-30 15:15:32 -07:00
|
|
|
html => qr/.+/,
|
|
|
|
heading => "[ -a b ] (Bash)",
|
|
|
|
),
|
|
|
|
'bash [[ "abc" < "cba" ]]' => test_zci(
|
2014-04-03 07:41:39 -07:00
|
|
|
qr/.+ true if "abc" string-sorts before "cba" in the current locale./,
|
2014-03-30 15:15:32 -07:00
|
|
|
html => qr/.+/,
|
|
|
|
heading => '[[ "abc" < "cba" ]] (Bash)',
|
|
|
|
),
|
|
|
|
'bash [ 2 -gt 1 ]' => test_zci(
|
2014-04-03 07:41:39 -07:00
|
|
|
qr/.+ true if 2 is numerically greater than 1./,
|
2014-03-30 15:15:32 -07:00
|
|
|
html => qr/.+/,
|
|
|
|
heading => '[ 2 -gt 1 ] (Bash)',
|
|
|
|
),
|
|
|
|
'bash [ ! hello == world ]' => test_zci(
|
2014-04-03 07:41:39 -07:00
|
|
|
qr/.+ false if the strings hello and world are equal./,
|
2014-03-30 15:15:32 -07:00
|
|
|
html => qr/.+/,
|
|
|
|
heading => '[ ! hello == world ] (Bash)',
|
|
|
|
),
|
|
|
|
'bash [[ /tmp/hello -nt /etc/test ]]' => test_zci (
|
2014-04-03 07:41:39 -07:00
|
|
|
qr#.+ true if /tmp/hello has been changed more recently than /etc/test or if /tmp/hello exists and /etc/test does not.#,
|
2014-03-30 15:15:32 -07:00
|
|
|
html => qr/.+/,
|
|
|
|
heading => '[[ /tmp/hello -nt /etc/test ]] (Bash)',
|
|
|
|
),
|
2014-02-10 13:24:52 -08:00
|
|
|
'bash [ -z hello ]' => test_zci(
|
2014-10-28 11:36:15 -07:00
|
|
|
qr/.+ true if the length of 'hello' is zero./,
|
2014-03-26 19:47:26 -07:00
|
|
|
html => qr/.+/,
|
|
|
|
heading => '[ -z hello ] (Bash)',
|
2014-02-10 13:24:52 -08:00
|
|
|
),
|
|
|
|
'bash if [[ "abc" -lt "cba" ]]' => test_zci(
|
2014-10-28 11:36:15 -07:00
|
|
|
qr/.+ true if "abc" is numerically less than "cba"./,
|
2014-03-26 19:47:26 -07:00
|
|
|
html => qr/.+/,
|
2014-03-27 09:32:58 -07:00
|
|
|
heading => '[[ "abc" -lt "cba" ]] (Bash)',
|
2014-02-10 13:24:52 -08:00
|
|
|
),
|
2014-03-30 15:15:32 -07:00
|
|
|
'bash if [ 1 -lt 2 -a 1 -lt 3 ]' => undef,
|
|
|
|
'bash if [ ![ 1 -lt 2 ] ]' => undef,
|
2013-12-16 14:07:48 -08:00
|
|
|
);
|
|
|
|
|
2014-02-10 13:24:52 -08:00
|
|
|
done_testing;
|