2012-12-05 12:17:45 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
2012-12-05 12:17:45 -08:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => 'sort';
|
2014-10-07 03:40:21 -07:00
|
|
|
zci is_cached => 1;
|
2012-12-05 12:17:45 -08:00
|
|
|
|
2016-05-22 12:37:21 -07:00
|
|
|
sub build_test {
|
|
|
|
my ($input, $direction, $result) = @_;
|
|
|
|
return test_zci("$result (Sorted $direction)" , structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => $result,
|
|
|
|
subtitle => "Sort $direction: $input"
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => 'text'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-12-05 12:17:45 -08:00
|
|
|
ddg_goodie_test(
|
2014-10-07 03:40:21 -07:00
|
|
|
[qw( DDG::Goodie::Sort)],
|
2016-05-22 12:37:21 -07:00
|
|
|
'sort -1, +4, -3, 5.7' => build_test('-1, 4, -3, 5.7', 'ascendingly', '-3, -1, 4, 5.7'),
|
|
|
|
'sort [-1, +4, -3, 5.7]' => build_test('-1, 4, -3, 5.7', 'ascendingly', '-3, -1, 4, 5.7'),
|
|
|
|
'sort (-1, +4, -3, 5.7)' => build_test('-1, 4, -3, 5.7', 'ascendingly', '-3, -1, 4, 5.7'),
|
|
|
|
'sort desc -4.4 .5 1 66 15 -55' => build_test('-4.4, 0.5, 1, 66, 15, -55', 'descendingly', '66, 15, 1, 0.5, -4.4, -55'),
|
|
|
|
'sort desc -4.4 .5 1 66 2e-3 15 -55' => build_test('-4.4, 0.5, 1, 66, 0.002, 15, -55', 'descendingly', '66, 15, 1, 0.5, 0.002, -4.4, -55'),
|
|
|
|
'sort -3 -10 56 10' => build_test('-3, -10, 56, 10','ascendingly', '-10, -3, 10, 56'),
|
|
|
|
'sort descending 10, -1, +5.3, -95, 1' => build_test('10, -1, 5.3, -95, 1', 'descendingly', '10, 5.3, 1, -1, -95'),
|
|
|
|
'sort descending 10, -1, +5.3, -95, 1, 1e2' => build_test('10, -1, 5.3, -95, 1, 100', 'descendingly', '100, 10, 5.3, 1, -1, -95'),
|
2016-05-29 09:16:31 -07:00
|
|
|
'sort 1' => undef,
|
|
|
|
'sort 455' => undef,
|
2014-10-07 03:40:21 -07:00
|
|
|
'sort algorithm' => undef,
|
|
|
|
'sort 1 fish, 2 fish' => undef,
|
2015-12-05 23:01:48 -08:00
|
|
|
'sort' => undef,
|
2012-12-05 12:17:45 -08:00
|
|
|
);
|
|
|
|
|
2016-05-16 06:18:04 -07:00
|
|
|
done_testing;
|