zeroclickinfo-goodies/t/BashPrimaryExpressions.t

54 lines
1.5 KiB
Perl
Raw Normal View History

use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'expression_description';
zci is_cached => 1;
ddg_goodie_test(
[
'DDG::Goodie::BashPrimaryExpressions'
],
"bash [ -a b ]" => test_zci(
qr/.+ true if b exists./,
html => qr/.+/,
heading => "[ -a b ] (Bash)",
),
'bash [[ "abc" < "cba" ]]' => test_zci(
qr/.+ true if "abc" string-sorts before "cba" in the current locale./,
html => qr/.+/,
heading => '[[ &quot;abc&quot; &lt; &quot;cba&quot; ]] (Bash)',
),
'bash [ 2 -gt 1 ]' => test_zci(
qr/.+ true if 2 is numerically greater than 1./,
html => qr/.+/,
heading => '[ 2 -gt 1 ] (Bash)',
),
'bash [ ! hello == world ]' => test_zci(
qr/.+ false if the strings hello and world are equal./,
html => qr/.+/,
heading => '[ ! hello == world ] (Bash)',
),
'bash [[ /tmp/hello -nt /etc/test ]]' => test_zci (
qr#.+ true if /tmp/hello has been changed more recently than /etc/test or if /tmp/hello exists and /etc/test does not.#,
html => qr/.+/,
heading => '[[ /tmp/hello -nt /etc/test ]] (Bash)',
),
'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)',
),
'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 => '[[ &quot;abc&quot; -lt &quot;cba&quot; ]] (Bash)',
),
'bash if [ 1 -lt 2 -a 1 -lt 3 ]' => undef,
'bash if [ ![ 1 -lt 2 ] ]' => undef,
);
done_testing;