diff --git a/test/urgency.t b/test/urgency.t index 47adfc308..c4ffa095f 100755 --- a/test/urgency.t +++ b/test/urgency.t @@ -1,340 +1,275 @@ -#! /usr/bin/env perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ +#!/usr/bin/env python2.7 +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# http://www.opensource.org/licenses/mit-license.php +# +############################################################################### -use strict; -use warnings; -use Test::More tests => 47; +import sys +import os +import unittest +# Ensure python finds the local simpletap module +sys.path.append(os.path.dirname(os.path.abspath(__file__))) -# Ensure environment has no influence. -delete $ENV{'TASKDATA'}; -delete $ENV{'TASKRC'}; +from basetest import Task, TestCase -use File::Basename; -my $ut = basename ($0); -my $rc = $ut . '.rc'; -sub in_range -{ - my ($value, $low, $high, $message) = @_; +class TestUrgency(TestCase): + @classmethod + def setUpClass(cls): + """Executed once before any test in the class""" + cls.t = Task() + cls.t.config("urgency.uda.priority.H.coefficient", "10") + cls.t.config("urgency.uda.priority.M.coefficient", "6.5") + cls.t.config("urgency.uda.priority.L.coefficient", "3") + cls.t.config("urgency.active.coefficient", "10") + cls.t.config("urgency.project.coefficient", "10") + cls.t.config("urgency.due.coefficient", "10") + cls.t.config("urgency.blocking.coefficient", "10") + cls.t.config("urgency.blocked.coefficient", "10") + cls.t.config("urgency.annotations.coefficient", "10") + cls.t.config("urgency.tags.coefficient", "10") + cls.t.config("urgency.waiting.coefficient", "-10") + cls.t.config("urgency.next.coefficient", "10") + cls.t.config("urgency.user.project.PROJECT.coefficient", "10") + cls.t.config("urgency.user.tag.TAG.coefficient", "10") + cls.t.config("confirmation", "off") - if ($value >= $low && $value <= $high) - { - pass ($message); - } - else - { - diag ("Expected '$value' to be in the range $low --> $high"); - fail ($message); - } -} + cls.t("add control") # 1 -# Create the rc file. -if (open my $fh, '>', $rc) -{ - print $fh "data.location=.\n", - "urgency.uda.priority.H.coefficient=10\n", - "urgency.uda.priority.M.coefficient=6.5\n", - "urgency.uda.priority.L.coefficient=3\n", - "urgency.active.coefficient=10\n", - "urgency.project.coefficient=10\n", - "urgency.due.coefficient=10\n", - "urgency.blocking.coefficient=10\n", - "urgency.blocked.coefficient=10\n", - "urgency.annotations.coefficient=10\n", - "urgency.tags.coefficient=10\n", - "urgency.waiting.coefficient=-10\n", - "urgency.next.coefficient=10\n", - "urgency.user.project.PROJECT.coefficient=10\n", - "urgency.user.tag.TAG.coefficient=10\n", - "confirmation=off\n"; + cls.t("add 1a pri:H") # 2 + cls.t("add 1b pri:M") # 3 + cls.t("add 1c pri:L") # 4 - close $fh; -} + cls.t("add 2a project:P") # 5 -# Add a task, and verify that the individual urgency terms are being correctly -# calculated. + cls.t("add 3a") # 6 + cls.t("6 start") -# priority -qx{../src/task rc:$rc add control 2>&1}; # task 1 -qx{../src/task rc:$rc add 1a pri:H 2>&1}; # task 2 -qx{../src/task rc:$rc add 1b pri:M 2>&1}; # task 3 -qx{../src/task rc:$rc add 1c pri:L 2>&1}; # task 4 + cls.t("add 4a +next") # 7 -# priority: 0 (pending) -my $output = qx{../src/task rc:$rc 1 _urgency 2>&1}; -like ($output, qr/urgency 0$/ms, "$ut: Control = 0"); + cls.t("add 5a +one") # 8 + cls.t("add 5b +one +two") # 9 + cls.t("add 5c +one +two +three") # 10 + cls.t("add 5d +one +two +three +four") # 11 -# priority: 10 (pri:H) -$output = qx{../src/task rc:$rc 2 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: pri:H = 10"); + cls.t("add 6a") # 12 + cls.t("12 annotate A") + cls.t("add 6b") # 13 + cls.t("13 annotate A") + cls.t("13 annotate B") + cls.t("add 6c") # 14 + cls.t("14 annotate A") + cls.t("14 annotate B") + cls.t("14 annotate C") + cls.t("add 6d") # 15 -# priority: 6.5 (pri:M) -$output = qx{../src/task rc:$rc 3 _urgency 2>&1}; -like ($output, qr/urgency 6\.5$/ms, "$ut: pri:M = 6.5"); + cls.t("15 annotate A") + cls.t("15 annotate B") + cls.t("15 annotate C") + cls.t("15 annotate D") -# priority: 3 (pri:L) -$output = qx{../src/task rc:$rc 4 _urgency 2>&1}; -like ($output, qr/urgency 3$/ms, "$ut: pri:L = 3"); + cls.t("add 7a wait:10s") # 16 -# project: 10 (project) -qx{../src/task rc:$rc add 2a project:P 2>&1}; # task 5 -$output = qx{../src/task rc:$rc 5 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: pro:P = 10"); + cls.t("add 8a") # 17 + cls.t("add 8b depends:17") # 18 -# active: 10 (active) -qx{../src/task rc:$rc add 3a 2>&1}; # task 6 -qx{../src/task rc:$rc 6 start 2>&1}; -$output = qx{../src/task rc:$rc 6 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: active = 10"); + cls.t("add 9a due:-10d") # 19 + cls.t("add 9b due:-7d") # 20 + cls.t("add 9c due:-6d") # 21 + cls.t("add 9d due:-5d") # 22 + cls.t("add 9e due:-4d") # 23 + cls.t("add 9f due:-3d") # 24 + cls.t("add 9g due:-2d") # 25 + cls.t("add 9h due:-1d") # 26 + cls.t("add 9i due:now") # 27 + cls.t("add 9j due:25h") # 28 + cls.t("add 9k due:49h") # 29 + cls.t("add 9l due:73h") # 30 + cls.t("add 9m due:97h") # 31 + cls.t("add 9n due:121h") # 32 + cls.t("add 9o due:145h") # 33 + cls.t("add 9p due:169h") # 34 + cls.t("add 9q due:193h") # 35 + cls.t("add 9r due:217h") # 36 + cls.t("add 9s due:241h") # 37 + cls.t("add 9t due:265h") # 38 + cls.t("add 9u due:289h") # 39 + cls.t("add 9v due:313h") # 40 + cls.t("add 9w due:337h") # 41 + cls.t("add 9x due:361h") # 42 -# next: 10 (+next) + 8 (1 tag) -qx{../src/task rc:$rc add 4a +next 2>&1}; # task 7 -$output = qx{../src/task rc:$rc 7 _urgency 2>&1}; -like ($output, qr/urgency 18$/ms, "$ut: +next = 18"); + cls.t("add 10a project:PROJECT") # 43 -# tags -qx{../src/task rc:$rc add 5a +one 2>&1}; # task 8 -qx{../src/task rc:$rc add 5b +one +two 2>&1}; # task 9 -qx{../src/task rc:$rc add 5c +one +two +three 2>&1}; # task 10 -qx{../src/task rc:$rc add 5d +one +two +three +four 2>&1}; # task 11 + cls.t("add 11a +TAG") # 44 -# tags: 8 (1 tag) -$output = qx{../src/task rc:$rc 8 _urgency 2>&1}; -like ($output, qr/urgency 8$/ms, "$ut: +one = 8"); + cls.t("add 12a scheduled:30d") # 45 + cls.t("add 12b scheduled:yesterday") # 46 -# tags: 9 (2 tags) -$output = qx{../src/task rc:$rc 9 _urgency 2>&1}; -like ($output, qr/urgency 9$/ms, "$ut: +one +two = 9"); + cls.t("add 13 pri:H") # 47 -# tags: 10 (3 tags) -$output = qx{../src/task rc:$rc 10 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: +one +two +three = 10"); + def assertApproximately(self, target, value): + """Verify that the number in 'value' is within the range""" + num = float(value.strip()) + self.assertEqual(target - 0.1 < num and num < target + 0.1, True) -# tags: 10 (4 tags) -$output = qx{../src/task rc:$rc 10 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: +one +two +three +four = 10"); + def test_urgency_priority(self): + """Verify urgency calculations involving priority""" + code, out, err = self.t("_get 1.urgency") + self.assertIn("0\n", out) + code, out, err = self.t("_get 2.urgency") + self.assertIn("10\n", out) + code, out, err = self.t("_get 3.urgency") + self.assertIn("6.5\n", out) + code, out, err = self.t("_get 4.urgency") + self.assertIn("3\n", out) -# annotations -qx{../src/task rc:$rc add 6a 2>&1}; # task 12 -qx{../src/task rc:$rc 12 annotate A 2>&1}; -qx{../src/task rc:$rc add 6b 2>&1}; # task 13 -qx{../src/task rc:$rc 13 annotate A 2>&1}; -qx{../src/task rc:$rc 13 annotate B 2>&1}; -qx{../src/task rc:$rc add 6c 2>&1}; # task 14 -qx{../src/task rc:$rc 14 annotate A 2>&1}; -qx{../src/task rc:$rc 14 annotate B 2>&1}; -qx{../src/task rc:$rc 14 annotate C 2>&1}; -qx{../src/task rc:$rc add 6d 2>&1}; # task 15 -qx{../src/task rc:$rc 15 annotate A 2>&1}; -qx{../src/task rc:$rc 15 annotate B 2>&1}; -qx{../src/task rc:$rc 15 annotate C 2>&1}; -qx{../src/task rc:$rc 15 annotate D 2>&1}; + def test_urgency_project(self): + """Verify urgency calculations involving project""" + code, out, err = self.t("_get 5.urgency") + self.assertIn("10\n", out) -# annotations: 8 (1 annotation) -$output = qx{../src/task rc:$rc 12 _urgency 2>&1}; -like ($output, qr/urgency 8$/ms, "$ut: 1 annotation = 8"); + def test_urgency_active(self): + """Verify urgency calculations involving active tasks""" + code, out, err = self.t("_get 6.urgency") + self.assertIn("10\n", out) -# annotations: 9 (2 annotations) -$output = qx{../src/task rc:$rc 13 _urgency 2>&1}; -like ($output, qr/urgency 9$/ms, "$ut: 2 annotations = 9"); + def test_urgency_next(self): + """Verify urgency calculations involving +next""" + code, out, err = self.t("_get 7.urgency") + self.assertIn("18\n", out) -# annotations: 10 (3 annotations) -$output = qx{../src/task rc:$rc 14 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: 3 annotations = 10"); + def test_urgency_tags(self): + """Verify urgency calculations involving tags""" + code, out, err = self.t("_get 8.urgency") + self.assertIn("8\n", out) + code, out, err = self.t("_get 9.urgency") + self.assertIn("9\n", out) + code, out, err = self.t("_get 10.urgency") + self.assertIn("10\n", out) + code, out, err = self.t("_get 11.urgency") + self.assertIn("10\n", out) -# annotations: 10 (4 annotations) -$output = qx{../src/task rc:$rc 15 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: 4 annotations = 10"); + def test_urgency_annotations(self): + """Verify urgency calculations involving annotations""" + code, out, err = self.t("_get 12.urgency") + self.assertIn("8\n", out) + code, out, err = self.t("_get 13.urgency") + self.assertIn("9\n", out) + code, out, err = self.t("_get 14.urgency") + self.assertIn("10\n", out) + code, out, err = self.t("_get 15.urgency") + self.assertIn("10\n", out) -# waiting: -10 -qx{../src/task rc:$rc add 7a wait:10s 2>&1}; # task 16 -$output = qx{../src/task rc:$rc 16 _urgency 2>&1}; -like ($output, qr/urgency -10$/ms, "$ut: waiting = -10"); + def test_urgency_waiting(self): + """Verify urgency calculations involving waiting tasks""" + code, out, err = self.t("_get 16.urgency") + self.assertIn("-10\n", out) -# blocked: 10 (blocked) -qx{../src/task rc:$rc add 8a depends:1 2>&1}; # task 17 -$output = qx{../src/task rc:$rc 17 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: blocked = 10"); + def test_urgency_dependencies(self): + """Verify urgency calculations involving dependencies""" + code, out, err = self.t("_get 17.urgency") + self.assertIn("10\n", out) + code, out, err = self.t("_get 18.urgency") + self.assertIn("10\n", out) -# blocking: 10 (blocking) -$output = qx{../src/task rc:$rc 1 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: blocking = 10"); + def test_urgency_due(self): + """Verify urgency calculations involving due dates""" + code, out, err = self.t("_get 19.urgency") + self.assertIn("10\n", out) + code, out, err = self.t("_get 20.urgency") + self.assertIn("10\n", out) + code, out, err = self.t("_get 21.urgency") + self.assertApproximately(9.62, out) + code, out, err = self.t("_get 22.urgency") + self.assertApproximately(9.24, out) + code, out, err = self.t("_get 23.urgency") + self.assertApproximately(8.86, out) + code, out, err = self.t("_get 24.urgency") + self.assertApproximately(8.48, out) + code, out, err = self.t("_get 25.urgency") + self.assertApproximately(8.1, out) + code, out, err = self.t("_get 26.urgency") + self.assertApproximately(7.71, out) + code, out, err = self.t("_get 27.urgency") + self.assertApproximately(7.33, out) + code, out, err = self.t("_get 28.urgency") + self.assertApproximately(6.94, out) + code, out, err = self.t("_get 29.urgency") + self.assertApproximately(6.56, out) + code, out, err = self.t("_get 30.urgency") + self.assertApproximately(6.17, out) + code, out, err = self.t("_get 31.urgency") + self.assertApproximately(5.79, out) + code, out, err = self.t("_get 32.urgency") + self.assertApproximately(5.41, out) + code, out, err = self.t("_get 33.urgency") + self.assertApproximately(5.03, out) + code, out, err = self.t("_get 34.urgency") + self.assertApproximately(4.65, out) + code, out, err = self.t("_get 35.urgency") + self.assertApproximately(4.27, out) + code, out, err = self.t("_get 36.urgency") + self.assertApproximately(3.89, out) + code, out, err = self.t("_get 37.urgency") + self.assertApproximately(3.51, out) + code, out, err = self.t("_get 38.urgency") + self.assertApproximately(3.13, out) + code, out, err = self.t("_get 39.urgency") + self.assertApproximately(2.75, out) + code, out, err = self.t("_get 40.urgency") + self.assertApproximately(2.37, out) + code, out, err = self.t("_get 41.urgency") + self.assertApproximately(2, out) + code, out, err = self.t("_get 42.urgency") + self.assertApproximately(2, out) -# due + def test_urgency_user_project(self): + """Verify urgency calculations involving user project""" + code, out, err = self.t("_get 43.urgency") + self.assertIn("20\n", out) -qx{../src/task rc:$rc add 9a due:-10d 2>&1}; # task 18 -qx{../src/task rc:$rc add 9b due:-7d 2>&1}; # task 19 -qx{../src/task rc:$rc add 9c due:-6d 2>&1}; # task 20 -qx{../src/task rc:$rc add 9d due:-5d 2>&1}; # task 21 -qx{../src/task rc:$rc add 9e due:-4d 2>&1}; # task 22 -qx{../src/task rc:$rc add 9f due:-3d 2>&1}; # task 23 -qx{../src/task rc:$rc add 9g due:-2d 2>&1}; # task 24 -qx{../src/task rc:$rc add 9h due:-1d 2>&1}; # task 25 -qx{../src/task rc:$rc add 9i due:now 2>&1}; # task 26 -qx{../src/task rc:$rc add 9j due:25h 2>&1}; # task 27 -qx{../src/task rc:$rc add 9k due:49h 2>&1}; # task 28 -qx{../src/task rc:$rc add 9l due:73h 2>&1}; # task 29 -qx{../src/task rc:$rc add 9m due:97h 2>&1}; # task 30 -qx{../src/task rc:$rc add 9n due:121h 2>&1}; # task 31 -qx{../src/task rc:$rc add 9o due:145h 2>&1}; # task 32 -qx{../src/task rc:$rc add 9p due:169h 2>&1}; # task 33 -qx{../src/task rc:$rc add 9q due:193h 2>&1}; # task 34 -qx{../src/task rc:$rc add 9r due:217h 2>&1}; # task 35 -qx{../src/task rc:$rc add 9s due:241h 2>&1}; # task 36 -qx{../src/task rc:$rc add 9t due:265h 2>&1}; # task 37 -qx{../src/task rc:$rc add 9u due:289h 2>&1}; # task 38 -qx{../src/task rc:$rc add 9v due:313h 2>&1}; # task 39 -qx{../src/task rc:$rc add 9w due:337h 2>&1}; # task 40 -qx{../src/task rc:$rc add 9x due:361h 2>&1}; # task 41 + def test_urgency_user_tag(self): + """Verify urgency calculations involving user tag""" + code, out, err = self.t("_get 44.urgency") + self.assertIn("18\n", out) -# due: 10 (due:-10d) -$output = qx{../src/task rc:$rc 18 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: due:-10d = 10"); + def test_urgency_scheduled(self): + """Verify urgency calculations involving a scheduled task""" + code, out, err = self.t("_get 45.urgency") + self.assertIn("0\n", out) + code, out, err = self.t("_get 46.urgency") + self.assertIn("5\n", out) -# due: 10 (due:-7d) -$output = qx{../src/task rc:$rc 19 _urgency 2>&1}; -like ($output, qr/urgency 10$/ms, "$ut: due:-7d = 10"); + def test_urgency_coefficient_override(self): + """Verify urgency coefficient override""" + code, out, err = self.t("rc.urgency.uda.priority.H.coefficient:0.01234 _get 47.urgency") + self.assertApproximately(0.01234, out) -# due: ~9.6 (due:-6d) -$output = qx{../src/task rc:$rc 20 _urgency 2>&1}; -my ($value) = $output =~ /urgency\s([0-9.]+)/; -in_range ($value, 9, 10, "$ut: due:-6d = 9 - 10"); -# due: 9.24 (due:-5d) -$output = qx{../src/task rc:$rc 21 _urgency 2>&1}; -like ($output, qr/urgency 9.24/ms, "$ut: due:-5d = 9.24"); +if __name__ == "__main__": + from simpletap import TAPTestRunner + unittest.main(testRunner=TAPTestRunner()) -# due: 8.86 (due:-4d) -$output = qx{../src/task rc:$rc 22 _urgency 2>&1}; -like ($output, qr/urgency 8.86/ms, "$ut: due:-4d = 8.86"); - -# due: 8.48 (due:-3d) -$output = qx{../src/task rc:$rc 23 _urgency 2>&1}; -like ($output, qr/urgency 8.48/ms, "$ut: due:-3d = 8.48"); - -# due: 8.1 (due:-2d) -$output = qx{../src/task rc:$rc 24 _urgency 2>&1}; -like ($output, qr/urgency 8.1/ms, "$ut: due:-2d = 8.1"); - -# due: 7.71 (due:-1d) -$output = qx{../src/task rc:$rc 25 _urgency 2>&1}; -like ($output, qr/urgency 7.71/ms, "$ut: due:-1d = 7.71"); - -# due: ~7.53 (due:now) -$output = qx{../src/task rc:$rc 26 _urgency 2>&1}; -($value) = $output =~ /urgency\s([0-9.]+)/; -in_range ($value, 7, 8, "$ut: due:now = 7 - 8"); - -# due: 6.94 (due:1d) -$output = qx{../src/task rc:$rc 27 _urgency 2>&1}; -like ($output, qr/urgency 6.94/ms, "$ut: due:1d = 6.94"); - -# due: 6.56 (due:2d) -$output = qx{../src/task rc:$rc 28 _urgency 2>&1}; -like ($output, qr/urgency 6.56/ms, "$ut: due:2d = 6.56"); - -# due: 6.17 (due:3d) -$output = qx{../src/task rc:$rc 29 _urgency 2>&1}; -like ($output, qr/urgency 6.17/ms, "$ut: due:3d = 6.17"); - -# due: 5.79 (due:4d) -$output = qx{../src/task rc:$rc 30 _urgency 2>&1}; -like ($output, qr/urgency 5.79/ms, "$ut: due:4d = 5.79"); - -# due: 5.41 (due:5d) -$output = qx{../src/task rc:$rc 31 _urgency 2>&1}; -like ($output, qr/urgency 5.41/ms, "$ut: due:5d = 5.41"); - -# due: 5.03 (due:6d) -$output = qx{../src/task rc:$rc 32 _urgency 2>&1}; -like ($output, qr/urgency 5.03/ms, "$ut: due:6d = 5.03"); - -# due: 4.65 (due:7d) -$output = qx{../src/task rc:$rc 33 _urgency 2>&1}; -like ($output, qr/urgency 4.65/ms, "$ut: due:7d = 4.65"); - -# due: 4.27 (due:8d) -$output = qx{../src/task rc:$rc 34 _urgency 2>&1}; -like ($output, qr/urgency 4.27/ms, "$ut: due:8d = 4.27"); - -# due: 3.89 (due:9d) -$output = qx{../src/task rc:$rc 35 _urgency 2>&1}; -like ($output, qr/urgency 3.89/ms, "$ut: due:9d = 3.89"); - -# due: 3.51 (due:10d) -$output = qx{../src/task rc:$rc 36 _urgency 2>&1}; -like ($output, qr/urgency 3.51/ms, "$ut: due:10d = 3.51"); - -# due: 3.13 (due:11d) -$output = qx{../src/task rc:$rc 37 _urgency 2>&1}; -like ($output, qr/urgency 3.13/ms, "$ut: due:11d = 3.13"); - -# due: 2.75 (due:12d) -$output = qx{../src/task rc:$rc 38 _urgency 2>&1}; -like ($output, qr/urgency 2.75/ms, "$ut: due:12d = 2.75"); - -# due: >2 (due:13d) -$output = qx{../src/task rc:$rc 39 _urgency 2>&1}; -($value) = $output =~ /urgency\s([0-9.]+)/; -in_range ($value, 2, 3, "$ut: due:13d = 2 - 3"); - -# due: 2 (due:14d) -$output = qx{../src/task rc:$rc 40 _urgency 2>&1}; -like ($output, qr/urgency 2/ms, "$ut: due:14d = 2"); - -# due: 2 (due:20d) -$output = qx{../src/task rc:$rc 41 _urgency 2>&1}; -like ($output, qr/urgency 2$/ms, "$ut: due:20d = 2"); - -# user.project: 10 (pro:PROJECT) + 10 (project) -qx{../src/task rc:$rc add 10a project:PROJECT 2>&1}; # task 42 -$output = qx{../src/task rc:$rc 42 _urgency 2>&1}; -like ($output, qr/urgency 20$/ms, "$ut: pro:PROJECT = 20"); - -# user.tag: 10 (+TAG) + 8 (1 tag) -qx{../src/task rc:$rc add 11a +TAG 2>&1}; # task 43 -$output = qx{../src/task rc:$rc 43 _urgency 2>&1}; -like ($output, qr/urgency 18$/ms, "$ut: +TAG = 18"); - -# scheduled 0 (scheduled future) -qx {../src/task rc:$rc add 12a scheduled:30d 2>&1}; -$output = qx{../src/task rc:$rc 44 _urgency 2>&1}; -like ($output, qr/urgency 0$/ms, "$ut: scheduled future = 0"); - -# scheduled 5 (scheduled past) -qx {../src/task rc:$rc add 12b scheduled:yesterday 2>&1}; -$output = qx{../src/task rc:$rc 45 _urgency 2>&1}; -like ($output, qr/urgency 5$/ms, "$ut: scheduled past = 5"); - -# urgency values between 0 and 1 -qx {../src/task rc:$rc add 13 pri:H 2>&1}; -$output = qx{../src/task rc:$rc rc.urgency.uda.priority.H.coefficient:0.01234 46 info 2>&1}; -like ($output, qr/Urgency\s+0\.01$/ms, "$ut: near-zero urgency is truncated"); - -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data), $rc; -exit 0; +# vim: ai sts=4 et sw=4