Merge branch 'sort' into 1.9.3

This commit is contained in:
Paul Beckingham
2010-07-21 15:33:24 -07:00
4 changed files with 319 additions and 238 deletions

View File

@@ -28,7 +28,7 @@
use strict;
use warnings;
use Test::More tests => 7;
use Test::More tests => 97;
# Create the rc file.
if (open my $fh, '>', 'sorting.rc')
@@ -38,19 +38,146 @@ if (open my $fh, '>', 'sorting.rc')
ok (-r 'sorting.rc', 'Created sorting.rc');
}
# Test sort order for most reports (including list) of:
# due+,priority-,active+,project+
qx{../task rc:sorting.rc add due:eow priority:H project:A due:tomorrow one};
qx{../task rc:sorting.rc add due:eow priority:H project:B due:tomorrow two};
qx{../task rc:sorting.rc add due:eow priority:H project:C due:tomorrow three};
qx{../task rc:sorting.rc add due:eow priority:H project:D due:tomorrow four};
my $output = qx{../task rc:sorting.rc list};
like ($output, qr/one.+two.+three.+four/ms, 'no active task sorting');
# Test assorted sort orders.
qx{../task rc:sorting.rc add priority:H project:A due:yesterday one};
qx{../task rc:sorting.rc add priority:M project:B due:today two};
qx{../task rc:sorting.rc add priority:L project:C due:tomorrow three};
qx{../task rc:sorting.rc add priority:H project:C due:today four};
qx{../task rc:sorting.rc start 1};
qx{../task rc:sorting.rc start 3};
$output = qx{../task rc:sorting.rc list};
like ($output, qr/one.+three.+two.+four/ms, 'active task sorting');
# pri:H pro:C due:today four
# pri:H pro:A * due:yesterday one
# pri:M pro:B due:today two
# pri:L pro:C * due:tomorrow three
my %tests =
(
# Single sort column.
'priority-' => '(?:one.+four|four.+one).+two.+three',
'priority+' => 'three.+two.+(?:one.+four|four.+one)',
'project-' => '(?:three.+four|four.+three).+two.+one',
'project+' => 'one.+two.+(?:three.+four|four.+three)',
'active-' => '(?:one.+three|three.+one).+(?:two.+four|four.+two)',
'active+' => '(?:two.+four|four.+two).+(?:one.+three|three.+one)',
'due-' => 'three.+(?:two.+four|four.+two).+one',
'due+' => 'one.+(?:two.+four|four.+two).+three',
'description-' => 'two.+three.+one.+four',
'description+' => 'four.+one.+three.+two',
# Two sort columns.
'priority-,project-' => 'four.+one.+two.+three',
'priority-,project+' => 'one.+four.+two.+three',
'priority+,project-' => 'three.+two.+four.+one',
'priority+,project+' => 'three.+two.+one.+four',
'priority-,active-' => 'one.+four.+two.+three',
'priority-,active+' => 'four.+one.+two.+three',
'priority+,active-' => 'three.+two.+one.+four',
'priority+,active+' => 'three.+two.+four.+one',
'priority-,due-' => 'four.+one.+two.+three',
'priority-,due+' => 'one.+four.+two.+three',
'priority+,due-' => 'three.+two.+four.+one',
'priority+,due+' => 'three.+two.+one.+four',
'priority-,description-' => 'one.+four.+two.+three',
'priority-,description+' => 'four.+one.+two.+three',
'priority+,description-' => 'three.+two.+one.+four',
'priority+,description+' => 'three.+two.+four.+one',
'project-,priority-' => 'four.+three.+two.+one',
'project-,priority+' => 'three.+four.+two.+one',
'project+,priority-' => 'one.+two.+four.+three',
'project+,priority+' => 'one.+two.+three.+four',
'project-,active-' => 'three.+four.+two.+one',
'project-,active+' => 'four.+three.+two.+one',
'project+,active-' => 'one.+two.+three.+four',
'project+,active+' => 'one.+two.+four.+three',
'project-,due-' => 'three.+four.+two.+one',
'project-,due+' => 'four.+three.+two.+one',
'project+,due-' => 'one.+two.+three.+four',
'project+,due+' => 'one.+two.+four.+three',
'project-,description-' => 'three.+four.+two.+one',
'project-,description+' => 'four.+three.+two.+one',
'project+,description-' => 'one.+two.+three.+four',
'project+,description+' => 'one.+two.+four.+three',
'active-,priority-' => 'one.+three.+four.+two',
'active-,priority+' => 'three.+one.+two.+four',
'active+,priority-' => 'four.+two.+one.+three',
'active+,priority+' => 'two.+four.+three.+one',
'active-,project-' => 'three.+one.+four.+two',
'active-,project+' => 'one.+three.+two.+four',
'active+,project-' => 'four.+two.+three.+one',
'active+,project+' => 'two.+four.+one.+three',
'active-,due-' => 'three.+one.+(?:four.+two|two.+four)',
'active-,due+' => 'one.+three.+(?:four.+two|two.+four)',
'active+,due-' => '(?:four.+two|two.+four).+three.+one',
'active+,due+' => '(?:four.+two|two.+four).+one.+three',
'active-,description-' => 'three.+one.+two.+four',
'active-,description+' => 'one.+three.+four.+two',
'active+,description-' => 'two.+four.+three.+one',
'active+,description+' => 'four.+two.+one.+three',
'due-,priority-' => 'three.+four.+two.+one',
'due-,priority+' => 'three.+two.+four.+one',
'due+,priority-' => 'one.+four.+two.+three',
'due+,priority+' => 'one.+two.+four.+three',
'due-,project-' => 'three.+four.+two.+one',
'due-,project+' => 'three.+two.+four.+one',
'due+,project-' => 'one.+four.+two.+three',
'due+,project+' => 'one.+two.+four.+three',
'due-,active-' => 'three.+(?:four.+two|two.+four).+one',
'due-,active+' => 'three.+(?:four.+two|two.+four).+one',
'due+,active-' => 'one.+(?:four.+two|two.+four).+three',
'due+,active+' => 'one.+(?:four.+two|two.+four).+three',
'due-,description-' => 'three.+two.+four.+one',
'due-,description+' => 'three.+four.+two.+one',
'due+,description-' => 'one.+two.+four.+three',
'due+,description+' => 'one.+four.+two.+three',
'description-,priority-' => 'two.+three.+one.+four',
'description-,priority+' => 'two.+three.+one.+four',
'description+,priority-' => 'four.+one.+three.+two',
'description+,priority+' => 'four.+one.+three.+two',
'description-,project-' => 'two.+three.+one.+four',
'description-,project+' => 'two.+three.+one.+four',
'description+,project-' => 'four.+one.+three.+two',
'description+,project+' => 'four.+one.+three.+two',
'description-,active-' => 'two.+three.+one.+four',
'description-,active+' => 'two.+three.+one.+four',
'description+,active-' => 'four.+one.+three.+two',
'description+,active+' => 'four.+one.+three.+two',
'description-,due-' => 'two.+three.+one.+four',
'description-,due+' => 'two.+three.+one.+four',
'description+,due-' => 'four.+one.+three.+two',
'description+,due+' => 'four.+one.+three.+two',
# Four sort columns.
'active+,project+,due+,priority+' => 'two.+four.+one.+three',
'project+,due+,priority+,active+' => 'one.+two.+four.+three',
);
for my $sort (sort keys %tests)
{
my $output = qx{../task rc:sorting.rc rc.report.list.sort:${sort} list};
like ($output, qr/$tests{$sort}/ms, "sort:${sort}");
}
# Cleanup.
unlink 'pending.data';