Bug Fixes, Unit Tests

- Fixed bug where "foo:bar" was not recognized as an attribute, and
  generated an error rather than demoting is to part of the description.
- Fixed bug where en-passant deltas were applied only to the first task
  in a sequence.
- Fixed various unit test.
This commit is contained in:
Paul Beckingham 2009-06-18 22:01:43 -04:00
parent 1511c1fcfd
commit 9c2e70b73a
9 changed files with 53 additions and 39 deletions

View file

@ -239,7 +239,8 @@ bool Att::validNameValue (
autoComplete (name, candidates, matches);
if (matches.size () == 0)
throw std::string ("Unrecognized attribute '") + name + "'";
// throw std::string ("Unrecognized attribute '") + name + "'";
return false;
else if (matches.size () != 1)
{

View file

@ -428,12 +428,26 @@ void Context::parse (
std::string name = attribute.name ();
std::string mod = attribute.mod ();
std::string value = attribute.value ();
attribute.validNameValue (name, mod, value);
attribute.name (name);
attribute.mod (mod);
attribute.value (value);
if (attribute.validNameValue (name, mod, value))
{
attribute.name (name);
attribute.mod (mod);
attribute.value (value);
parseTask[attribute.name ()] = attribute;
parseTask[attribute.name ()] = attribute;
}
// *arg has the appearance of an attribute (foo:bar), but isn't
// recognized, so downgrade it to part of the description.
else
{
if (foundSequence)
foundSomethingAfterSequence = true;
if (descCandidate.length ())
descCandidate += " ";
descCandidate += *arg;
}
}
// Substitution of description and/or annotation text.

View file

@ -661,11 +661,7 @@ std::string handleDone ()
{
// Apply deltas.
deltaDescription (*task);
context.task.remove ("description");
deltaTags (*task);
context.task.remove ("tags");
deltaAttributes (*task);
deltaSubstitutions (*task);
@ -799,11 +795,7 @@ std::string handleModify ()
// Apply other deltas.
changes += deltaDescription (*other);
context.task.remove ("description");
changes += deltaTags (*other);
context.task.remove ("tags");
changes += deltaAttributes (*other);
changes += deltaSubstitutions (*other);
@ -853,11 +845,7 @@ std::string handleAppend ()
// Apply other deltas.
changes += deltaAppend (*other);
context.task.remove ("description");
changes += deltaTags (*other);
context.task.remove ("tags");
changes += deltaAttributes (*other);
if (changes)
@ -924,11 +912,7 @@ std::string handleDuplicate ()
// Apply deltas.
deltaDescription (dup);
context.task.remove ("description");
deltaTags (dup);
context.task.remove ("tags");
deltaAttributes (dup);
deltaSubstitutions (dup);
@ -1137,7 +1121,9 @@ int deltaAttributes (Task& task)
foreach (att, context.task)
{
if (att->first != "uuid")
if (att->first != "uuid" &&
att->first != "description" &&
att->first != "tags")
{
if (att->second.value () == "")
task.remove (att->first);

View file

@ -210,7 +210,7 @@ int main (int argc, char** argv)
n = Nibbler ("name:");
good = true;
try {a7.parse (n);} catch (...) {good = false;}
t.notok (good, "Att::parse (name:)");
t.ok (good, "Att::parse (name:)");
n = Nibbler ("name:\"value");
good = true;

View file

@ -41,13 +41,13 @@ if (open my $fh, '>', 'basic.rc')
# Test the usage command.
my $output = qx{../task rc:basic.rc};
like ($output, qr/Usage: task/, 'usage');
like ($output, qr/http:\/\/www\.beckingham\.net\/task\.html/, 'usage - url');
like ($output, qr/http:\/\/taskwarrior\.org/, 'usage - url');
# Test the version command.
$output = qx{../task rc:basic.rc version};
like ($output, qr/task \d+\.\d+\.\d+/, 'version - task version number');
like ($output, qr/ABSOLUTELY NO WARRANTY/, 'version - warranty');
like ($output, qr/http:\/\/www\.beckingham\.net\/task\.html/, 'version - url');
like ($output, qr/http:\/\/taskwarrior\.org/, 'version - url');
# Cleanup.
unlink 'basic.rc';

View file

@ -38,3 +38,16 @@
ok 3 - Removed completed.data
ok 4 - Removed bench.rc
6/18/2009
1.8.0:
1..4
ok 1 - Created bench.rc
# start=1245372501
# 1000 tasks added in 4 seconds
# 600 tasks altered in 45 seconds
# stop=1245372747
# total=246
ok 2 - Removed pending.data
ok 3 - Removed completed.data
ok 4 - Removed bench.rc

View file

@ -57,14 +57,14 @@ if (open my $fh, '>', 'annual.rc')
qx{../task rc:annual.rc add foo due:1/1/2000 recur:annual until:1/1/2009};
my $output = qx{../task rc:annual.rc list};
like ($output, qr/2\s+1\/1\/2000\s+- foo/, 'synthetic 1 no creep');
like ($output, qr/3\s+1\/1\/2001\s+- foo/, 'synthetic 2 no creep');
like ($output, qr/4\s+1\/1\/2002\s+- foo/, 'synthetic 3 no creep');
like ($output, qr/5\s+1\/1\/2003\s+- foo/, 'synthetic 4 no creep');
like ($output, qr/6\s+1\/1\/2004\s+- foo/, 'synthetic 5 no creep');
like ($output, qr/7\s+1\/1\/2005\s+- foo/, 'synthetic 6 no creep');
like ($output, qr/8\s+1\/1\/2006\s+- foo/, 'synthetic 7 no creep');
like ($output, qr/9\s+1\/1\/2007\s+- foo/, 'synthetic 8 no creep');
like ($output, qr/2\s+1\/1\/2000\s+- foo/, 'synthetic 1 no creep');
like ($output, qr/3\s+1\/1\/2001\s+- foo/, 'synthetic 2 no creep');
like ($output, qr/4\s+1\/1\/2002\s+- foo/, 'synthetic 3 no creep');
like ($output, qr/5\s+1\/1\/2003\s+- foo/, 'synthetic 4 no creep');
like ($output, qr/6\s+1\/1\/2004\s+- foo/, 'synthetic 5 no creep');
like ($output, qr/7\s+1\/1\/2005\s+- foo/, 'synthetic 6 no creep');
like ($output, qr/8\s+1\/1\/2006\s+- foo/, 'synthetic 7 no creep');
like ($output, qr/9\s+1\/1\/2007\s+- foo/, 'synthetic 8 no creep');
like ($output, qr/10\s+1\/1\/2008\s+- foo/, 'synthetic 9 no creep');
like ($output, qr/11\s+1\/1\/2009\s+- foo/, 'synthetic 10 no creep');

View file

@ -34,7 +34,7 @@ use Test::More tests => 16;
if (open my $fh, '>', 'default.rc')
{
print $fh "data.location=.\n",
"default.command=list\n",
"default.command=rc:default.rc list\n",
"default.project=PROJECT\n",
"default.priority=M\n";
close $fh;

View file

@ -46,21 +46,21 @@ like ($output, qr/Status\s+Pending\n/, 'Pending');
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc info 1};
like ($output, qr/Status\s+Deleted\n/, 'Deleted');
ok (! -r 'completed.data', 'completed.data not created');
ok (-r 'completed.data', 'completed.data created');
$output = qx{../task rc:undelete.rc undelete 1; ../task rc:undelete.rc info 1};
like ($output, qr/Status\s+Pending\n/, 'Pending');
ok (! -r 'completed.data', 'completed.data not created');
ok (-r 'completed.data', 'completed.data created');
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc list};
like ($output, qr/^No matches/, 'No matches');
like ($output, qr/No matches./, 'No matches');
ok (-r 'completed.data', 'completed.data created');
$output = qx{../task rc:undelete.rc undelete 1};
like ($output, qr/Task 1 not found/, 'Task 1 not found');
$output = qx{../task rc:undelete.rc info 1};
like ($output, qr/No matches./, 'no matches');
like ($output, qr/Task 1 not found/, 'No matches');
# Cleanup.
ok (-r 'pending.data', 'Need to remove pending.data');