r72578 - in /branches/upstream/libdatetime-set-perl/current: Changes MANIFEST META.yml lib/DateTime/Set.pm lib/DateTime/Span.pm lib/DateTime/SpanSet.pm t/01sanity.t t/21from_recurrence.t

periapt-guest at users.alioth.debian.org periapt-guest at users.alioth.debian.org
Wed Apr 13 16:19:48 UTC 2011


Author: periapt-guest
Date: Wed Apr 13 16:19:18 2011
New Revision: 72578

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=72578
Log:
[svn-upgrade] new version libdatetime-set-perl (0.30)

Added:
    branches/upstream/libdatetime-set-perl/current/t/21from_recurrence.t
Modified:
    branches/upstream/libdatetime-set-perl/current/Changes
    branches/upstream/libdatetime-set-perl/current/MANIFEST
    branches/upstream/libdatetime-set-perl/current/META.yml
    branches/upstream/libdatetime-set-perl/current/lib/DateTime/Set.pm
    branches/upstream/libdatetime-set-perl/current/lib/DateTime/Span.pm
    branches/upstream/libdatetime-set-perl/current/lib/DateTime/SpanSet.pm
    branches/upstream/libdatetime-set-perl/current/t/01sanity.t

Modified: branches/upstream/libdatetime-set-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/Changes?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/Changes (original)
+++ branches/upstream/libdatetime-set-perl/current/Changes Wed Apr 13 16:19:18 2011
@@ -1,4 +1,11 @@
 Changes for DateTime::Set
+
+0.30   2011-04-11
+- new test file t/21from_recurrence.t 
+  Contributed by Olivier Mengue
+
+0.29   2011-04-01 
+- new method is_empty_set - bug #50750
 
 0.28   2009-07-19
 - optimized DateTime::Set->as_list().

Modified: branches/upstream/libdatetime-set-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/MANIFEST?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/MANIFEST (original)
+++ branches/upstream/libdatetime-set-perl/current/MANIFEST Wed Apr 13 16:19:18 2011
@@ -27,6 +27,7 @@
 t/18as_list_empty.t
 t/19spanset_daylight_savings.t       
 t/20spanset_week_wrapped_recurrence.t
+t/21from_recurrence.t
 lib/DateTime/Set.pm
 lib/DateTime/Span.pm
 lib/DateTime/SpanSet.pm

Modified: branches/upstream/libdatetime-set-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/META.yml?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-set-perl/current/META.yml Wed Apr 13 16:19:18 2011
@@ -1,16 +1,24 @@
 --- #YAML:1.0
-name:                DateTime-Set
-version:             0.28
-abstract:            DateTime set objects
-license:             ~
-author:              
+name:               DateTime-Set
+version:            0.30
+abstract:           DateTime set objects
+author:
     - Flavio S. Glock <fglock at pucrs.br>
-generated_by:        ExtUtils::MakeMaker version 6.44
-distribution_type:   module
-requires:     
-    DateTime:                      0.12
-    Set::Infinite:                 0.59
-    Test::More:                    0
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    DateTime:       0.12
+    Set::Infinite:  0.59
+    Test::More:     0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libdatetime-set-perl/current/lib/DateTime/Set.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/lib/DateTime/Set.pm?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/lib/DateTime/Set.pm (original)
+++ branches/upstream/libdatetime-set-perl/current/lib/DateTime/Set.pm Wed Apr 13 16:19:18 2011
@@ -16,7 +16,7 @@
 use constant NEG_INFINITY => -1 * (100 ** 100 ** 100);
 
 BEGIN {
-    $VERSION = '0.28';
+    $VERSION = '0.30';
 }
 
 
@@ -298,6 +298,11 @@
     return bless { set => Set::Infinite::_recurrence->new }, $class;
 }
 
+sub is_empty_set {
+    my $set = $_[0];
+    $set->{set}->is_null;
+}
+
 sub clone { 
     my $self = bless { %{ $_[0] } }, ref $_[0];
     $self->{set} = $_[0]->{set}->copy;
@@ -844,6 +849,12 @@
     $set = DateTime::Set->empty_set;
     print "empty set" unless defined $set->max;
 
+=item * is_empty_set
+
+Returns true is the set is empty; false otherwise.
+
+    print "nothing" if $set->is_empty_set;
+
 =item * clone
 
 This object method returns a replica of the given object.

Modified: branches/upstream/libdatetime-set-perl/current/lib/DateTime/Span.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/lib/DateTime/Span.pm?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/lib/DateTime/Span.pm (original)
+++ branches/upstream/libdatetime-set-perl/current/lib/DateTime/Span.pm Wed Apr 13 16:19:18 2011
@@ -150,6 +150,11 @@
     return $class->from_datetimes(%args);
 }
 
+sub is_empty_set {
+    my $set = $_[0];
+    $set->{set}->is_null;
+}
+
 sub clone { 
     bless { 
         set => $_[0]->{set}->copy,

Modified: branches/upstream/libdatetime-set-perl/current/lib/DateTime/SpanSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/lib/DateTime/SpanSet.pm?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/lib/DateTime/SpanSet.pm (original)
+++ branches/upstream/libdatetime-set-perl/current/lib/DateTime/SpanSet.pm Wed Apr 13 16:19:18 2011
@@ -198,6 +198,11 @@
     return bless { set => Set::Infinite::_recurrence->new }, $class;
 }
 
+sub is_empty_set {
+    my $set = $_[0];
+    $set->{set}->is_null;
+}
+
 sub clone { 
     bless { 
         set => $_[0]->{set}->copy,
@@ -619,6 +624,12 @@
 
 Creates a new empty set.
 
+=item * is_empty_set
+
+Returns true is the set is empty; false otherwise.
+
+    print "nothing" if $set->is_empty_set;
+
 =item * clone
 
 This object method returns a replica of the given object.

Modified: branches/upstream/libdatetime-set-perl/current/t/01sanity.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/t/01sanity.t?rev=72578&op=diff
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/t/01sanity.t (original)
+++ branches/upstream/libdatetime-set-perl/current/t/01sanity.t Wed Apr 13 16:19:18 2011
@@ -3,7 +3,7 @@
 use strict;
 
 use Test::More;
-plan tests => 7;
+plan tests => 9;
 
 use DateTime;
 use DateTime::Set;
@@ -29,12 +29,15 @@
 ok( $s1->max->ymd eq '1900-11-22',
     'got 1900-11-22 - max' );
 
+is( $s1->is_empty_set, 0, 'non-empty set is not empty' );
+
 eval { DateTime::Set->from_datetimes() };
 ok( $@, 'Cannot call from_datetimes without dates parameter' );
 
 my $empty = DateTime::Set->empty_set;
 is( $empty->min, undef, 'empty set ->min should be undef' );
 is( $empty->max, undef, 'empty set ->max should be undef' );
+is( $empty->is_empty_set, 1, 'empty set is empty' );
 
 1;
 

Added: branches/upstream/libdatetime-set-perl/current/t/21from_recurrence.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-set-perl/current/t/21from_recurrence.t?rev=72578&op=file
==============================================================================
--- branches/upstream/libdatetime-set-perl/current/t/21from_recurrence.t (added)
+++ branches/upstream/libdatetime-set-perl/current/t/21from_recurrence.t Wed Apr 13 16:19:18 2011
@@ -1,0 +1,214 @@
+# Tests DateTime::Set built with from_recurrence
+# Copyright (c) 2009 Olivier Mengué
+# License: same as DateTime-Set-0.26 or any later version
+
+use Test::More;
+use DateTime::Set;
+
+diag('Test suite by Olivier Mengue < dolmen cpan org >');
+
+my @set = map {
+    DateTime->new(
+        year   => $_->[0],
+        month  => $_->[1],
+        day    => $_->[2],
+        hour   => $_->[3],
+        minute => $_->[4],
+        second => $_->[5],
+      )
+  }
+  map { [ split /[-T:]/ ] }
+  qw/
+  2009-02-27T08:50:05
+  2009-02-27T09:05:05
+  2009-02-27T09:20:05
+  2009-03-02T09:05:05
+  2009-03-02T09:20:05
+  2009-03-03T09:05:05
+  2009-03-03T09:20:05
+  /;
+
+plan tests =>
+	 ($#set+1+4)    # no span, next()
+	+($#set+1+4)    # no span, previous
+	+($#set+1+4)    # start, next()
+	+($#set  +4)    # after, next()
+	+($#set+1+4)    # end, previous()
+	+($#set  +4)    # before, previous()
+	+($#set+1+4)    # start, previous()
+	+($#set  +4)    # after, previous()
+	+($#set+1+4)    # end, next()
+	+($#set  +4)    # before, next()
+;
+
+my $start = $set[0];
+
+sub diag_sub
+{
+	my ($name, $sub) = (shift, shift);
+	exists $INC{'Test::More'} or eval { use Test::More }; 
+	return sub {
+		diag("$name(", join(', ', @_), ")");
+		if (wantarray) {
+			my @ret = $sub->(@_);
+			diag('=> ', @ret);
+			return @ret
+		} else {
+			my $ret = $sub->(@_);
+			diag('=> ', $ret);
+			return $ret;
+		}
+	}
+}
+
+my $dts = do {
+	my $idx = 0;
+	DateTime::Set->from_recurrence(
+		next => diag_sub(next => sub {
+			return $set[($idx = 0)] if ($_[0] <=> DateTime::NEG_INFINITY) <= 0; 
+			return DateTime::Infinite::Future->new if $_[0]->is_infinite or $idx == $#set;
+			return $set[++$idx];
+		}),
+		previous => diag_sub(previous => sub {
+			return $set[($idx = $#set)] if ($_[0] <=> DateTime::INFINITY) >= 0;
+			return DateTime::Infinite::Past->new if $_[0]->is_infinite or $idx == 0;
+			return $set[--$idx];
+		})
+	)
+}; 
+
+
+
+diag("no span, next()");
+{
+	my $it = $dts->iterator;
+	# ->current is "less or equal to"
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (@set) {
+		is($it->next, $d, $d);
+	}
+	is($it->next, undef, "set end -> undef");
+
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+	
+diag("no span, previous()");
+{
+	my $it = $dts->iterator;
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (reverse @set) {
+		is($it->previous, $d, $d);
+	}
+	is($it->previous, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+diag("start, next()");
+{
+	my $it = $dts->iterator(start => $set[0]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (@set) {
+		is($it->next, $d, $d);
+	}
+	is($it->next, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+diag("after, next()");
+{
+	my $it = $dts->iterator(after => $set[0]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (@set[1..$#set]) {
+		is($it->next, $d, $d);
+	}
+	is($it->next, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+diag("end, previous()");
+{
+	my $it = $dts->iterator(end => $set[-1]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (reverse @set) {
+		is($it->previous, $d, $d);
+	}
+	is($it->previous, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+diag("before, previous()");
+{
+	my $it = $dts->iterator(before => $set[-1]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-2], "current(Future) is $set[-2]");
+	for my $d (reverse @set[0..$#set-1]) {
+		is($it->previous, $d, $d);
+	}
+	is($it->previous, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+
+diag("start, previous()");
+{
+	my $it = $dts->iterator(start => $set[0]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (reverse @set) {
+		is($it->previous, $d, $d);
+	}
+	is($it->previous, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+diag("after, previous()");
+{
+	my $it = $dts->iterator(after => $set[0]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (reverse @set[1..$#set]) {
+		is($it->previous, $d, $d);
+	}
+	is($it->previous, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+
+diag("end, next()");
+{
+	my $it = $dts->iterator(end => $set[-1]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-1], "current(Future) is $set[-1]");
+	for my $d (@set) {
+		is($it->next, $d, $d);
+	}
+	is($it->next, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}
+
+diag("before, next()");
+{
+	my $it = $dts->iterator(before => $set[-1]);
+	is($it->current(DateTime::Infinite::Past->new), undef, "current(Past) is empty");
+	is($it->current(DateTime::Infinite::Future->new), $set[-2], "current(Future) is $set[-2]");
+	for my $d (@set[0..$#set-1]) {
+		is($it->next, $d, $d);
+	}
+	is($it->next, undef, "end -> undef");
+	# The set is now empty
+	is($it->previous(DateTime::Infinite::Future->new), undef, "set is now empty");
+}




More information about the Pkg-perl-cvs-commits mailing list