From 6865fda6e102c6f86af84b95517e8fa4b6ffacd6 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 14 Feb 2011 17:39:11 -0800 Subject: [PATCH] Build a test to verify checkSegment. Addresses bug #12044. --- docs/changelog/7.x.x.txt | 1 + t/Spectre/Cron.t | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 t/Spectre/Cron.t diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 76d2772ca..8b2c605e8 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fixed #12042: userDefined variables have no template variable help - fixed #12045: Job listing template, missing summary - fixed #12043: Collaboration Systems don't pull mail that fast! + - fixed #12044: Spectre::Cron and non-integer time units 7.10.9 - fixed #12030: Calendar Feed Time Zone Issue diff --git a/t/Spectre/Cron.t b/t/Spectre/Cron.t new file mode 100644 index 000000000..b9a1f824e --- /dev/null +++ b/t/Spectre/Cron.t @@ -0,0 +1,43 @@ +# vim: syntax=perl +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use warnings; + +use Test::More; + +use lib "$FindBin::Bin/../lib"; + +use WebGUI::Test; +use WebGUI::Session; +use Spectre::Cron; + +plan tests => 11; + +my $session = WebGUI::Test->session; + +##The goal of this test is to make sure that checkSegment works correctly + +ok !Spectre::Cron::checkSegment(undef, 4, 3.5, [0..59]), 'checkSegment: fractional number is false, low'; +ok !Spectre::Cron::checkSegment(undef, 4, 4.5, [0..59]), '... fractional number is false, high'; + +ok Spectre::Cron::checkSegment(undef, 4, 4, [0..59]), 'exact match'; +ok !Spectre::Cron::checkSegment(undef, 4, 3, [0..59]), 'exact miss'; +ok !Spectre::Cron::checkSegment(undef, 4, '!4', [0..59]), 'negation, miss'; +ok Spectre::Cron::checkSegment(undef, 5, '!4', [0..59]), 'negation, match'; + +ok Spectre::Cron::checkSegment(undef, 4, '*/2', [0..59]), '*/, multiple'; +ok !Spectre::Cron::checkSegment(undef, 4, '*/3', [0..59]), '*/, not a multiple'; + +ok !Spectre::Cron::checkSegment(undef, 4, '1-3', [0..59]), 'out of range, low'; +ok !Spectre::Cron::checkSegment(undef, 4, '5-9', [0..59]), 'out of range, high'; +ok Spectre::Cron::checkSegment(undef, 4, '1-9', [0..59]), 'range match';