commit perl-Future for openSUSE:Factory
Hello community, here is the log from the commit of package perl-Future for openSUSE:Factory checked in at 2018-09-26 14:23:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Future (Old) and /work/SRC/openSUSE:Factory/.perl-Future.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-Future" Wed Sep 26 14:23:21 2018 rev:7 rq:638023 version:0.39 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Future/perl-Future.changes 2018-02-09 15:47:38.315191794 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Future.new/perl-Future.changes 2018-09-26 14:23:23.497924674 +0200 @@ -1,0 +2,6 @@ +Sat Sep 22 05:23:21 UTC 2018 - Stephan Kulow <coolo@suse.com> + +- updated to 0.39 + see /usr/share/doc/packages/perl-Future/Changes + +------------------------------------------------------------------- Old: ---- Future-0.38.tar.gz New: ---- Future-0.39.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Future.spec ++++++ --- /var/tmp/diff_new_pack.IsJdEC/_old 2018-09-26 14:23:24.333923344 +0200 +++ /var/tmp/diff_new_pack.IsJdEC/_new 2018-09-26 14:23:24.333923344 +0200 @@ -12,18 +12,18 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: perl-Future -Version: 0.38 +Version: 0.39 Release: 0 %define cpan_name Future Summary: Represent an Operation Awaiting Completion -License: Artistic-1.0 or GPL-1.0+ +License: Artistic-1.0 OR GPL-1.0-or-later Group: Development/Libraries/Perl -Url: http://search.cpan.org/dist/Future/ +Url: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/P/PE/PEVANS/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch @@ -71,9 +71,6 @@ See also Future::Utils which contains useful loop-constructing functions, to run a future-returning function repeatedly in a loop. -Unless otherwise noted, the following methods require at least version -_0.08_. - %prep %setup -q -n %{cpan_name}-%{version} ++++++ Future-0.38.tar.gz -> Future-0.39.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/Changes new/Future-0.39/Changes --- old/Future-0.38/Changes 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/Changes 2018-09-20 15:07:35.000000000 +0200 @@ -1,5 +1,11 @@ Revision history for Future +0.39 2018-09-20 14:03:05 + [CHANGES] + * Added Test::Future::Deferred + * Use Syntax::Keyword::Try in example code + * Various docs fixes + 0.38 2017-12-18 01:41:52 [CHANGES] * Added counting ability to Future::Mutex (RT123876) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/LICENSE new/Future-0.39/LICENSE --- old/Future-0.38/LICENSE 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/LICENSE 2018-09-20 15:07:35.000000000 +0200 @@ -1,4 +1,4 @@ -This software is copyright (c) 2017 by Paul Evans <leonerd@leonerd.org.uk>. +This software is copyright (c) 2018 by Paul Evans <leonerd@leonerd.org.uk>. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. @@ -12,7 +12,7 @@ --- The GNU General Public License, Version 1, February 1989 --- -This software is Copyright (c) 2017 by Paul Evans <leonerd@leonerd.org.uk>. +This software is Copyright (c) 2018 by Paul Evans <leonerd@leonerd.org.uk>. This is free software, licensed under: @@ -272,7 +272,7 @@ --- The Artistic License 1.0 --- -This software is Copyright (c) 2017 by Paul Evans <leonerd@leonerd.org.uk>. +This software is Copyright (c) 2018 by Paul Evans <leonerd@leonerd.org.uk>. This is free software, licensed under: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/MANIFEST new/Future-0.39/MANIFEST --- old/Future-0.38/MANIFEST 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/MANIFEST 2018-09-20 15:07:35.000000000 +0200 @@ -6,6 +6,7 @@ lib/Future/Phrasebook.pod lib/Future/Utils.pm lib/Test/Future.pm +lib/Test/Future/Deferred.pm LICENSE MANIFEST This list of files META.json @@ -36,5 +37,6 @@ t/36utils-map.t t/40mutex.t t/50test-future.t +t/51test-future-deferred.t t/90legacy.t t/99pod.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/META.json new/Future-0.39/META.json --- old/Future-0.38/META.json 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/META.json 2018-09-20 15:07:35.000000000 +0200 @@ -4,7 +4,7 @@ "Paul Evans <leonerd@leonerd.org.uk>" ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.422", + "generated_by" : "Module::Build version 0.4224", "license" : [ "perl_5" ], @@ -39,19 +39,23 @@ "provides" : { "Future" : { "file" : "lib/Future.pm", - "version" : "0.38" + "version" : "0.39" }, "Future::Mutex" : { "file" : "lib/Future/Mutex.pm", - "version" : "0.38" + "version" : "0.39" }, "Future::Utils" : { "file" : "lib/Future/Utils.pm", - "version" : "0.38" + "version" : "0.39" }, "Test::Future" : { "file" : "lib/Test/Future.pm", - "version" : "0.38" + "version" : "0.39" + }, + "Test::Future::Deferred" : { + "file" : "lib/Test/Future/Deferred.pm", + "version" : "0.39" } }, "release_status" : "stable", @@ -61,6 +65,6 @@ ], "x_IRC" : "irc://irc.perl.org/#io-async" }, - "version" : "0.38", - "x_serialization_backend" : "JSON::PP version 2.94" + "version" : "0.39", + "x_serialization_backend" : "JSON::PP version 2.97001" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/META.yml new/Future-0.39/META.yml --- old/Future-0.38/META.yml 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/META.yml 2018-09-20 15:07:35.000000000 +0200 @@ -10,7 +10,7 @@ configure_requires: Module::Build: '0.4004' dynamic_config: 1 -generated_by: 'Module::Build version 0.422, CPAN::Meta::Converter version 2.150010' +generated_by: 'Module::Build version 0.4224, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -19,16 +19,19 @@ provides: Future: file: lib/Future.pm - version: '0.38' + version: '0.39' Future::Mutex: file: lib/Future/Mutex.pm - version: '0.38' + version: '0.39' Future::Utils: file: lib/Future/Utils.pm - version: '0.38' + version: '0.39' Test::Future: file: lib/Test/Future.pm - version: '0.38' + version: '0.39' + Test::Future::Deferred: + file: lib/Test/Future/Deferred.pm + version: '0.39' requires: Carp: '1.25' Test::Builder::Module: '0' @@ -37,5 +40,5 @@ resources: IRC: irc://irc.perl.org/#io-async license: http://dev.perl.org/licenses/ -version: '0.38' +version: '0.39' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/README new/Future-0.39/README --- old/Future-0.38/README 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/README 2018-09-20 15:07:35.000000000 +0200 @@ -323,16 +323,15 @@ If the future is not yet ready, adds a callback to be invoked if the future is cancelled by the cancel method. If the future is already - ready, throws an exception. + ready the method is ignored. - If the future is cancelled, the callbacks will be invoked in the + If the future is later cancelled, the callbacks will be invoked in the reverse order to that in which they were registered. $on_cancel->( $future ) If passed another Future instance, the passed instance will be - cancelled when the original future is cancelled. This method does - nothing if the future is already complete. + cancelled when the original future is cancelled. USER METHODS @@ -421,9 +420,13 @@ $exception, @details = $future->failure - Returns the exception passed to the fail method, undef if the future - completed successfully via the done method, or raises an exception if - called on a future that is not yet ready. + If the future is ready, returns the exception passed to the fail method + or undef if the future completed successfully via the done method. + + If it is not yet ready and is not of a subclass that provides an await + method an exception is thrown. If it is subclassed to provide an await + method then this is used to wait for the future to be ready, before + returning the result or propagating its failure exception. If called in list context, will additionally yield a list of the details provided to the fail method. @@ -1035,7 +1038,7 @@ failed, it can be used to control a try/catch block directly. (This is sometimes called Exception Hoisting). - use Try::Tiny; + use Syntax::Keyword::Try; $f->on_ready( sub { my $f = shift; @@ -1044,7 +1047,7 @@ } catch { say "The operation failed with: ", $_; - }; + } } ); Even neater still may be the separate use of the on_done and on_fail diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/lib/Future/Mutex.pm new/Future-0.39/lib/Future/Mutex.pm --- old/Future-0.38/lib/Future/Mutex.pm 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/lib/Future/Mutex.pm 2018-09-20 15:07:35.000000000 +0200 @@ -8,7 +8,7 @@ use strict; use warnings; -our $VERSION = '0.38'; +our $VERSION = '0.39'; use Future; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/lib/Future/Utils.pm new/Future-0.39/lib/Future/Utils.pm --- old/Future-0.38/lib/Future/Utils.pm 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/lib/Future/Utils.pm 2018-09-20 15:07:35.000000000 +0200 @@ -8,7 +8,7 @@ use strict; use warnings; -our $VERSION = '0.38'; +our $VERSION = '0.39'; use Exporter 'import'; # Can't import the one from Exporter as it relies on package inheritance @@ -61,7 +61,7 @@ my $eventual_f = repeat { ... - return $trail_f; + return $trial_f; } until => sub { my $f = shift; return acceptable($f) }; my $eventual_f = repeat { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/lib/Future.pm new/Future-0.39/lib/Future.pm --- old/Future-0.38/lib/Future.pm 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/lib/Future.pm 2018-09-20 15:07:35.000000000 +0200 @@ -1,7 +1,7 @@ # You may distribute under the terms of either the GNU General Public License # or the Artistic License (the same terms as Perl itself) # -# (C) Paul Evans, 2011-2017 -- leonerd@leonerd.org.uk +# (C) Paul Evans, 2011-2018 -- leonerd@leonerd.org.uk package Future; @@ -9,7 +9,7 @@ use warnings; no warnings 'recursion'; # Disable the "deep recursion" warning -our $VERSION = '0.38'; +our $VERSION = '0.39'; use Carp qw(); # don't import croak use Scalar::Util qw( weaken blessed reftype ); @@ -647,21 +647,15 @@ $self->{ready} and Carp::croak "${\$self->__selfstr} is already ".$self->state." and cannot be ->fail'ed"; $self->{subs} and Carp::croak "${\$self->__selfstr} is not a leaf Future, cannot be ->fail'ed"; $self->{failure} = [ $exception, @details ]; - $self->_mark_ready( "fail" ); + $self->_mark_ready( "failed" ); } else { $self = $self->new; $self->{ready} = 1; - $self->{ready_at} = _shortmess "fail" if DEBUG; + $self->{ready_at} = _shortmess "failed" if DEBUG; $self->{failure} = [ $exception, @details ]; } - if( DEBUG ) { - my $at = Carp::shortmess( "failed" ); - chomp $at; $at =~ s/\.$//; - $self->{ready_at} = $at; - } - return $self; } @@ -705,17 +699,16 @@ $future->on_cancel( $code ) If the future is not yet ready, adds a callback to be invoked if the future is -cancelled by the C<cancel> method. If the future is already ready, throws an -exception. +cancelled by the C<cancel> method. If the future is already ready the method +is ignored. -If the future is cancelled, the callbacks will be invoked in the reverse order -to that in which they were registered. +If the future is later cancelled, the callbacks will be invoked in the reverse +order to that in which they were registered. $on_cancel->( $future ) If passed another C<Future> instance, the passed instance will be cancelled -when the original future is cancelled. This method does nothing if the future -is already complete. +when the original future is cancelled. =cut @@ -912,9 +905,13 @@ $exception, @details = $future->failure -Returns the exception passed to the C<fail> method, C<undef> if the future -completed successfully via the C<done> method, or raises an exception if -called on a future that is not yet ready. +If the future is ready, returns the exception passed to the C<fail> method or +C<undef> if the future completed successfully via the C<done> method. + +If it is not yet ready and is not of a subclass that provides an C<await> +method an exception is thrown. If it is subclassed to provide an C<await> +method then this is used to wait for the future to be ready, before returning +the result or propagating its failure exception. If called in list context, will additionally yield a list of the details provided to the C<fail> method. @@ -1578,7 +1575,7 @@ my ( $subs ) = @_; foreach my $sub ( @$subs ) { - blessed $sub and $sub->isa( "Future" ) or Carp::croak "Expected a Future, got $_"; + blessed $sub and $sub->isa( "Future" ) or Carp::croak "Expected a Future, got $sub"; } # Find the best prototype. Ideally anything derived if we can find one. @@ -2249,7 +2246,7 @@ it can be used to control a C<try>/C<catch> block directly. (This is sometimes called I<Exception Hoisting>). - use Try::Tiny; + use Syntax::Keyword::Try; $f->on_ready( sub { my $f = shift; @@ -2258,7 +2255,7 @@ } catch { say "The operation failed with: ", $_; - }; + } } ); Even neater still may be the separate use of the C<on_done> and C<on_fail> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/lib/Test/Future/Deferred.pm new/Future-0.39/lib/Test/Future/Deferred.pm --- old/Future-0.38/lib/Test/Future/Deferred.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/Future-0.39/lib/Test/Future/Deferred.pm 2018-09-20 15:07:35.000000000 +0200 @@ -0,0 +1,98 @@ +# You may distribute under the terms of either the GNU General Public License +# or the Artistic License (the same terms as Perl itself) +# +# (C) Paul Evans, 2018 -- leonerd@leonerd.org.uk + +package Test::Future::Deferred; + +use strict; +use warnings; +use base qw( Future ); + +our $VERSION = '0.39'; + +=head1 NAME + +C<Test::Future::Deferred> - a future which completes later + + my $future = Test::Future::Deferred->done_later( 1, 2, 3 ); + + # Future is not ready yet + + my @result = $future->get; + +=head1 DESCRIPTION + +This subclass of L<Future> provides two new methods and an implementation of +the C<await> interface, which allows the futures to appear pending at first, +but then to complete when C<get> is called at the toplevel on one of them. + +This behaviour is useful in unit tests to check that behaviour of a module +under test is correct even with non-immediate futures, as it allows a future +to easily be constructed that will complete "soon", but not yet, without +needing an event loop. + +Because these futures provide their own C<await> method, they shouldn't be +mixed in the same program with other kinds of futures from real event systems +or similar. + +=cut + +my @deferrals; + +sub await +{ + while( my $d = shift @deferrals ) { + my ( $f, $method, @args ) = @$d; + $f->$method( @args ); + } + # TODO: detect if still not done with no more deferrals +} + +=head1 METHODS + +=cut + +=head2 done_later + + $f->done_later( @args ) + +Equivalent to invoking the regular C<done> method as part of the C<await> +operation called on the toplevel future. This makes the future complete with +the given result, but only when C<get> is called. + +=cut + +sub done_later +{ + my $self = ref $_[0] ? shift : shift->new; + push @deferrals, [ $self, done => @_ ]; + return $self; +} + +=head2 fail_later + + $f->fail_later( $message, $category, @details ) + +Equivalent to invoking the regular C<fail> method as part of the C<await> +operation called on the toplevel future. This makes the future complete with +the given failure, but only when C<get> is called. As the C<failure> method +also waits for completion of the future, then it will return the failure +message given here also. + +=cut + +sub fail_later +{ + my $self = ref $_[0] ? shift : shift->new; + push @deferrals, [ $self, fail => @_ ]; + return $self; +} + +=head1 AUTHOR + +Paul Evans <leonerd@leonerd.org.uk> + +=cut + +0x55AA; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/lib/Test/Future.pm new/Future-0.39/lib/Test/Future.pm --- old/Future-0.38/lib/Test/Future.pm 2017-12-18 02:44:55.000000000 +0100 +++ new/Future-0.39/lib/Test/Future.pm 2018-09-20 15:07:35.000000000 +0200 @@ -9,7 +9,7 @@ use warnings; use base qw( Test::Builder::Module ); -our $VERSION = '0.38'; +our $VERSION = '0.39'; our @EXPORT = qw( no_pending_futures diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Future-0.38/t/51test-future-deferred.t new/Future-0.39/t/51test-future-deferred.t --- old/Future-0.38/t/51test-future-deferred.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Future-0.39/t/51test-future-deferred.t 2018-09-20 15:07:35.000000000 +0200 @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; +use Test::Fatal; + +use Test::Future::Deferred; + +# done +{ + my $f = Test::Future::Deferred->done_later( "result" ); + + ok( !$f->is_done, '$f not yet ready' ); + is( scalar $f->get, "result", '$f->get yields result anyway' ); +} + +# fail +{ + my $f = Test::Future::Deferred->fail_later( "oops\n" ); + + ok( !$f->is_failed, '$f not yet ready' ); + is( exception { $f->get }, "oops\n", '$f->get throws exception anyway' ); +} + +# failure +{ + my $f = Test::Future::Deferred->fail_later( "oops\n" ); + + ok( !$f->is_failed, '$f not yet ready' ); + is( $f->failure, "oops\n", '$f->failure returns exception anyway' ); +} + +done_testing;
participants (1)
-
root