In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/956a2dcd84382eb97d8b5992429135d10acb6ba1?hp=a705fd33893d18a8306026f955019f8440681b9a>
- Log ----------------------------------------------------------------- commit 956a2dcd84382eb97d8b5992429135d10acb6ba1 Author: James E Keenan <[email protected]> Date: Sun Dec 18 09:01:09 2016 -0500 Upgrade Test-Simple to 1.302071. Had to run ./perl -Ilib regen/lib_cleanup.pl. ----------------------------------------------------------------------- Summary of changes: MANIFEST | 3 + Makefile.SH | 34 ++++----- cpan/Test-Simple/lib/Test/Builder.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Formatter.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Module.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Tester.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm | 2 +- cpan/Test-Simple/lib/Test/More.pm | 2 +- cpan/Test-Simple/lib/Test/Simple.pm | 2 +- cpan/Test-Simple/lib/Test/Tester.pm | 2 +- cpan/Test-Simple/lib/Test/Tester/Capture.pm | 2 +- cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm | 2 +- cpan/Test-Simple/lib/Test/Tester/Delegate.pm | 2 +- cpan/Test-Simple/lib/Test/use/ok.pm | 2 +- cpan/Test-Simple/lib/Test2.pm | 2 +- cpan/Test-Simple/lib/Test2/API.pm | 2 +- cpan/Test-Simple/lib/Test2/API/Breakage.pm | 2 +- cpan/Test-Simple/lib/Test2/API/Context.pm | 2 +- cpan/Test-Simple/lib/Test2/API/Instance.pm | 2 +- cpan/Test-Simple/lib/Test2/API/Stack.pm | 2 +- cpan/Test-Simple/lib/Test2/Event.pm | 43 ++++++++++- cpan/Test-Simple/lib/Test2/Event/Bail.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Diag.pm | 2 +- .../lib/Test2/Event/{Exception.pm => Encoding.pm} | 32 ++++----- cpan/Test-Simple/lib/Test2/Event/Exception.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Generic.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Info.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Note.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Ok.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Plan.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Skip.pm | 2 +- cpan/Test-Simple/lib/Test2/Event/Subtest.pm | 42 +++++++++-- .../Test2/Event/{Exception.pm => TAP/Version.pm} | 29 ++++---- cpan/Test-Simple/lib/Test2/Event/Waiting.pm | 2 +- cpan/Test-Simple/lib/Test2/Formatter.pm | 2 +- cpan/Test-Simple/lib/Test2/Formatter/TAP.pm | 29 +++++--- cpan/Test-Simple/lib/Test2/Hub.pm | 2 +- cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm | 2 +- .../lib/Test2/Hub/Interceptor/Terminator.pm | 2 +- cpan/Test-Simple/lib/Test2/Hub/Subtest.pm | 2 +- cpan/Test-Simple/lib/Test2/IPC.pm | 2 +- cpan/Test-Simple/lib/Test2/IPC/Driver.pm | 2 +- cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm | 2 +- cpan/Test-Simple/lib/Test2/Util.pm | 2 +- cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm | 2 +- cpan/Test-Simple/lib/Test2/Util/HashBase.pm | 80 +++++++++++++++------ cpan/Test-Simple/lib/Test2/Util/Trace.pm | 31 +++++++- cpan/Test-Simple/lib/ok.pm | 2 +- cpan/Test-Simple/t/Test2/behavior/Subtest_todo.t | 29 ++++++++ cpan/Test-Simple/t/Test2/modules/Formatter/TAP.t | 15 ++++ cpan/Test-Simple/t/Test2/modules/Util/HashBase.t | 84 +++++++++++++++++----- cpan/Test-Simple/t/tools.pl | 31 ++++++++ 53 files changed, 415 insertions(+), 147 deletions(-) copy cpan/Test-Simple/lib/Test2/Event/{Exception.pm => Encoding.pm} (53%) copy cpan/Test-Simple/lib/Test2/Event/{Exception.pm => TAP/Version.pm} (61%) create mode 100644 cpan/Test-Simple/t/Test2/behavior/Subtest_todo.t diff --git a/MANIFEST b/MANIFEST index 928cd43dfc..d38f65ccbc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2614,6 +2614,7 @@ cpan/Test-Simple/lib/Test2/API/Stack.pm cpan/Test-Simple/lib/Test2/Event.pm cpan/Test-Simple/lib/Test2/Event/Bail.pm cpan/Test-Simple/lib/Test2/Event/Diag.pm +cpan/Test-Simple/lib/Test2/Event/Encoding.pm cpan/Test-Simple/lib/Test2/Event/Exception.pm cpan/Test-Simple/lib/Test2/Event/Generic.pm cpan/Test-Simple/lib/Test2/Event/Info.pm @@ -2622,6 +2623,7 @@ cpan/Test-Simple/lib/Test2/Event/Ok.pm cpan/Test-Simple/lib/Test2/Event/Plan.pm cpan/Test-Simple/lib/Test2/Event/Skip.pm cpan/Test-Simple/lib/Test2/Event/Subtest.pm +cpan/Test-Simple/lib/Test2/Event/TAP/Version.pm cpan/Test-Simple/lib/Test2/Event/Waiting.pm cpan/Test-Simple/lib/Test2/Formatter.pm cpan/Test-Simple/lib/Test2/Formatter/TAP.pm @@ -2815,6 +2817,7 @@ cpan/Test-Simple/t/Test2/behavior/special_names.t cpan/Test-Simple/t/Test2/behavior/Subtest_buffer_formatter.t cpan/Test-Simple/t/Test2/behavior/Subtest_events.t cpan/Test-Simple/t/Test2/behavior/Subtest_plan.t +cpan/Test-Simple/t/Test2/behavior/Subtest_todo.t cpan/Test-Simple/t/Test2/behavior/Taint.t cpan/Test-Simple/t/Test2/legacy/TAP.t cpan/Test-Simple/t/Test2/modules/API.t diff --git a/Makefile.SH b/Makefile.SH index 10003fdac6..963d205f79 100755 --- a/Makefile.SH +++ b/Makefile.SH @@ -1351,23 +1351,23 @@ _cleaner2: -rmdir lib/Unicode/Collate/CJK lib/Unicode/Collate lib/Tie/Hash -rmdir lib/Thread lib/Text lib/Test2/Util lib/Test2/IPC/Driver -rmdir lib/Test2/IPC lib/Test2/Hub/Interceptor lib/Test2/Hub - -rmdir lib/Test2/Formatter lib/Test2/Event lib/Test2/API lib/Test2 - -rmdir lib/Test/use lib/Test/Tester lib/Test/Builder/Tester - -rmdir lib/Test/Builder/IO lib/Test/Builder lib/Test lib/Term - -rmdir lib/TAP/Parser/YAMLish lib/TAP/Parser/SourceHandler - -rmdir lib/TAP/Parser/Scheduler lib/TAP/Parser/Result - -rmdir lib/TAP/Parser/Iterator lib/TAP/Parser lib/TAP/Harness - -rmdir lib/TAP/Formatter/File lib/TAP/Formatter/Console - -rmdir lib/TAP/Formatter lib/TAP lib/Sys/Syslog lib/Sys lib/Sub - -rmdir lib/Search lib/Scalar lib/Pod/Text lib/Pod/Simple - -rmdir lib/Pod/Perldoc lib/PerlIO/via lib/PerlIO lib/Perl - -rmdir lib/Parse/CPAN lib/Parse lib/Params lib/Net/FTP lib/Module/Load - -rmdir lib/Module/CoreList lib/Module lib/Memoize lib/Math/BigInt - -rmdir lib/Math/BigFloat lib/Math lib/MIME lib/Locale/Maketext - -rmdir lib/Locale/Codes lib/Locale lib/List/Util lib/List lib/JSON/PP - -rmdir lib/JSON lib/IPC lib/IO/Uncompress/Adapter lib/IO/Uncompress - -rmdir lib/IO/Socket lib/IO/Compress/Zlib lib/IO/Compress/Zip - -rmdir lib/IO/Compress/Gzip lib/IO/Compress/Base + -rmdir lib/Test2/Formatter lib/Test2/Event/TAP lib/Test2/Event + -rmdir lib/Test2/API lib/Test2 lib/Test/use lib/Test/Tester + -rmdir lib/Test/Builder/Tester lib/Test/Builder/IO lib/Test/Builder + -rmdir lib/Test lib/Term lib/TAP/Parser/YAMLish + -rmdir lib/TAP/Parser/SourceHandler lib/TAP/Parser/Scheduler + -rmdir lib/TAP/Parser/Result lib/TAP/Parser/Iterator lib/TAP/Parser + -rmdir lib/TAP/Harness lib/TAP/Formatter/File + -rmdir lib/TAP/Formatter/Console lib/TAP/Formatter lib/TAP + -rmdir lib/Sys/Syslog lib/Sys lib/Sub lib/Search lib/Scalar + -rmdir lib/Pod/Text lib/Pod/Simple lib/Pod/Perldoc lib/PerlIO/via + -rmdir lib/PerlIO lib/Perl lib/Parse/CPAN lib/Parse lib/Params + -rmdir lib/Net/FTP lib/Module/Load lib/Module/CoreList lib/Module + -rmdir lib/Memoize lib/Math/BigInt lib/Math/BigFloat lib/Math lib/MIME + -rmdir lib/Locale/Maketext lib/Locale/Codes lib/Locale lib/List/Util + -rmdir lib/List lib/JSON/PP lib/JSON lib/IPC lib/IO/Uncompress/Adapter + -rmdir lib/IO/Uncompress lib/IO/Socket lib/IO/Compress/Zlib + -rmdir lib/IO/Compress/Zip lib/IO/Compress/Gzip lib/IO/Compress/Base -rmdir lib/IO/Compress/Adapter lib/IO/Compress lib/IO -rmdir lib/I18N/LangTags lib/I18N lib/Hash/Util lib/Hash lib/HTTP -rmdir lib/Filter/Util lib/Filter lib/File/Spec lib/ExtUtils/Typemaps diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm index b838f1db27..c21fbff36b 100644 --- a/cpan/Test-Simple/lib/Test/Builder.pm +++ b/cpan/Test-Simple/lib/Test/Builder.pm @@ -4,7 +4,7 @@ use 5.006; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { if( $] < 5.008 ) { diff --git a/cpan/Test-Simple/lib/Test/Builder/Formatter.pm b/cpan/Test-Simple/lib/Test/Builder/Formatter.pm index 2221f0f736..3586c9f662 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Formatter.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Formatter.pm @@ -2,7 +2,7 @@ package Test::Builder::Formatter; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Formatter::TAP; our @ISA = qw(Test2::Formatter::TAP) } diff --git a/cpan/Test-Simple/lib/Test/Builder/Module.pm b/cpan/Test-Simple/lib/Test/Builder/Module.pm index 0a01161cdf..7755da5a25 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Module.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Module.pm @@ -7,7 +7,7 @@ use Test::Builder; require Exporter; our @ISA = qw(Exporter); -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; =head1 NAME diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester.pm b/cpan/Test-Simple/lib/Test/Builder/Tester.pm index 43c128024d..46f5aecb93 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Tester.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Tester.pm @@ -1,7 +1,7 @@ package Test::Builder::Tester; use strict; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test::Builder; use Symbol; diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm index 9d58c05c73..d0cff138ef 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm @@ -1,7 +1,7 @@ package Test::Builder::Tester::Color; use strict; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; require Test::Builder::Tester; diff --git a/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm b/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm index 1ebf65fa26..31f2b4b0de 100644 --- a/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm +++ b/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm @@ -2,7 +2,7 @@ package Test::Builder::TodoDiag; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event::Diag; our @ISA = qw(Test2::Event::Diag) } diff --git a/cpan/Test-Simple/lib/Test/More.pm b/cpan/Test-Simple/lib/Test/More.pm index c544ff2aff..9fe4d5c730 100644 --- a/cpan/Test-Simple/lib/Test/More.pm +++ b/cpan/Test-Simple/lib/Test/More.pm @@ -17,7 +17,7 @@ sub _carp { return warn @_, " at $file line $line\n"; } -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test::Builder::Module; our @ISA = qw(Test::Builder::Module); diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm index 82bfe9b3be..15b7ab1326 100644 --- a/cpan/Test-Simple/lib/Test/Simple.pm +++ b/cpan/Test-Simple/lib/Test/Simple.pm @@ -4,7 +4,7 @@ use 5.006; use strict; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test::Builder::Module; our @ISA = qw(Test::Builder::Module); diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm index 4e2d50ebce..de66efeba3 100644 --- a/cpan/Test-Simple/lib/Test/Tester.pm +++ b/cpan/Test-Simple/lib/Test/Tester.pm @@ -18,7 +18,7 @@ require Exporter; use vars qw( @ISA @EXPORT ); -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; @EXPORT = qw( run_tests check_tests check_test cmp_results show_space ); @ISA = qw( Exporter ); diff --git a/cpan/Test-Simple/lib/Test/Tester/Capture.pm b/cpan/Test-Simple/lib/Test/Tester/Capture.pm index c1a4196de2..01fef34478 100644 --- a/cpan/Test-Simple/lib/Test/Tester/Capture.pm +++ b/cpan/Test-Simple/lib/Test/Tester/Capture.pm @@ -2,7 +2,7 @@ use strict; package Test::Tester::Capture; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test::Builder; diff --git a/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm b/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm index 2c9fb52fec..1e06d7a62b 100644 --- a/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm +++ b/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm @@ -3,7 +3,7 @@ use strict; package Test::Tester::CaptureRunner; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test::Tester::Capture; diff --git a/cpan/Test-Simple/lib/Test/Tester/Delegate.pm b/cpan/Test-Simple/lib/Test/Tester/Delegate.pm index 0ffae8b4bb..8724e189f0 100644 --- a/cpan/Test-Simple/lib/Test/Tester/Delegate.pm +++ b/cpan/Test-Simple/lib/Test/Tester/Delegate.pm @@ -3,7 +3,7 @@ use warnings; package Test::Tester::Delegate; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Scalar::Util(); diff --git a/cpan/Test-Simple/lib/Test/use/ok.pm b/cpan/Test-Simple/lib/Test/use/ok.pm index 56379db933..ddc3a4c117 100644 --- a/cpan/Test-Simple/lib/Test/use/ok.pm +++ b/cpan/Test-Simple/lib/Test/use/ok.pm @@ -1,7 +1,7 @@ package Test::use::ok; use 5.005; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; __END__ diff --git a/cpan/Test-Simple/lib/Test2.pm b/cpan/Test-Simple/lib/Test2.pm index a4153497ae..701b7780d7 100644 --- a/cpan/Test-Simple/lib/Test2.pm +++ b/cpan/Test-Simple/lib/Test2.pm @@ -2,7 +2,7 @@ package Test2; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; 1; diff --git a/cpan/Test-Simple/lib/Test2/API.pm b/cpan/Test-Simple/lib/Test2/API.pm index 288268f870..3e54b2a3e0 100644 --- a/cpan/Test-Simple/lib/Test2/API.pm +++ b/cpan/Test-Simple/lib/Test2/API.pm @@ -7,7 +7,7 @@ BEGIN { $ENV{TEST2_ACTIVE} = 1; } -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; my $INST; diff --git a/cpan/Test-Simple/lib/Test2/API/Breakage.pm b/cpan/Test-Simple/lib/Test2/API/Breakage.pm index 07d8e18aa4..8e0b25703e 100644 --- a/cpan/Test-Simple/lib/Test2/API/Breakage.pm +++ b/cpan/Test-Simple/lib/Test2/API/Breakage.pm @@ -2,7 +2,7 @@ package Test2::API::Breakage; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test2::Util qw/pkg_to_file/; diff --git a/cpan/Test-Simple/lib/Test2/API/Context.pm b/cpan/Test-Simple/lib/Test2/API/Context.pm index 8ac3c02654..e9844cbec9 100644 --- a/cpan/Test-Simple/lib/Test2/API/Context.pm +++ b/cpan/Test-Simple/lib/Test2/API/Context.pm @@ -2,7 +2,7 @@ package Test2::API::Context; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Carp qw/confess croak longmess/; diff --git a/cpan/Test-Simple/lib/Test2/API/Instance.pm b/cpan/Test-Simple/lib/Test2/API/Instance.pm index f220d2972b..4489faf60b 100644 --- a/cpan/Test-Simple/lib/Test2/API/Instance.pm +++ b/cpan/Test-Simple/lib/Test2/API/Instance.pm @@ -2,7 +2,7 @@ package Test2::API::Instance; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; our @CARP_NOT = qw/Test2::API Test2::API::Instance Test2::IPC::Driver Test2::Formatter/; diff --git a/cpan/Test-Simple/lib/Test2/API/Stack.pm b/cpan/Test-Simple/lib/Test2/API/Stack.pm index 9adb37b933..6b1483e22a 100644 --- a/cpan/Test-Simple/lib/Test2/API/Stack.pm +++ b/cpan/Test-Simple/lib/Test2/API/Stack.pm @@ -2,7 +2,7 @@ package Test2::API::Stack; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test2::Hub(); diff --git a/cpan/Test-Simple/lib/Test2/Event.pm b/cpan/Test-Simple/lib/Test2/Event.pm index 8eb0331426..b566952eef 100644 --- a/cpan/Test-Simple/lib/Test2/Event.pm +++ b/cpan/Test-Simple/lib/Test2/Event.pm @@ -2,11 +2,12 @@ package Test2::Event; use strict; use warnings; -our $VERSION = '1.302067'; - +our $VERSION = '1.302071'; use Test2::Util::HashBase qw/trace nested in_subtest subtest_id/; use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/; +use Test2::Util qw(pkg_to_file); +use Test2::Util::Trace; sub causes_fail { 0 } sub increments_count { 0 } @@ -21,6 +22,33 @@ sub sets_plan { () } sub summary { ref($_[0]) } +sub from_json { + my $class = shift; + my %p = @_; + + my $event_pkg = delete $p{__PACKAGE__}; + require(pkg_to_file($event_pkg)); + + if (exists $p{trace}) { + $p{trace} = Test2::Util::Trace->from_json(%{$p{trace}}); + } + + if (exists $p{subevents}) { + my @subevents; + for my $subevent (@{delete $p{subevents} || []}) { + push @subevents, Test2::Event->from_json(%$subevent); + } + $p{subevents} = \@subevents; + } + + return $event_pkg->new(%p); +} + +sub TO_JSON { + my $self = shift; + return {%$self, __PACKAGE__ => ref $self}; +} + 1; __END__ @@ -174,6 +202,17 @@ If the event is inside a subtest this should have the subtest ID. If the event is a final subtest event, this should contain the subtest ID. +=item $hashref = $e->TO_JSON + +This returns a hashref suitable for passing to the C<< Test2::Event->from_json +>> constructor. It is intended for use with the L<JSON> family of modules, +which will look for a C<TO_JSON> method when C<convert_blessed> is true. + +=item $e = Test2::Event->from_json(%$hashref) + +Given the hash of data returned by C<< $e->TO_JSON >>, this method returns a +new event object of the appropriate subclass. + =back =head1 THIRD PARTY META-DATA diff --git a/cpan/Test-Simple/lib/Test2/Event/Bail.pm b/cpan/Test-Simple/lib/Test2/Event/Bail.pm index 858e2907bc..e4bf5c7164 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Bail.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Bail.pm @@ -2,7 +2,7 @@ package Test2::Event::Bail; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Diag.pm b/cpan/Test-Simple/lib/Test2/Event/Diag.pm index ddf644ecbd..674527637c 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Diag.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Diag.pm @@ -2,7 +2,7 @@ package Test2::Event::Diag; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Exception.pm b/cpan/Test-Simple/lib/Test2/Event/Encoding.pm similarity index 53% copy from cpan/Test-Simple/lib/Test2/Event/Exception.pm copy to cpan/Test-Simple/lib/Test2/Event/Encoding.pm index 3af37689bc..0bbd93cf94 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Exception.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Encoding.pm @@ -1,22 +1,18 @@ -package Test2::Event::Exception; +package Test2::Event::Encoding; use strict; use warnings; -our $VERSION = '1.302067'; - +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } -use Test2::Util::HashBase qw{error}; - -sub causes_fail { 1 } +use Test2::Util::HashBase qw/encoding/; -sub summary { +sub init { my $self = shift; - chomp(my $msg = "Exception: " . $self->{+ERROR}); - return $msg; + defined $self->{+ENCODING} or $self->trace->throw("'encoding' is a required attribute"); } -sub diagnostics { 1 } +sub summary { 'Encoding set to ' . $_[0]->{+ENCODING} } 1; @@ -28,20 +24,22 @@ __END__ =head1 NAME -Test2::Event::Exception - Exception event +Test2::Event::Encoding - Set the encoding for the output stream =head1 DESCRIPTION -An exception event will display to STDERR, and will prevent the overall test -file from passing. +The encoding event is generated when a test file wants to specify the encoding +to be used when formatting its output. This event is intended to be produced +by formatter classes and used for interpreting test names, message contents, +etc. =head1 SYNOPSIS use Test2::API qw/context/; - use Test2::Event::Exception; + use Test2::Event::Encoding; my $ctx = context(); - my $event = $ctx->send_event('Exception', error => 'Stuff is broken'); + my $event = $ctx->send_event('Encoding', encoding => 'UTF-8'); =head1 METHODS @@ -49,9 +47,9 @@ Inherits from L<Test2::Event>. Also defines: =over 4 -=item $reason = $e->error +=item $encoding = $e->encoding -The reason for the exception. +The encoding being specified. =back diff --git a/cpan/Test-Simple/lib/Test2/Event/Exception.pm b/cpan/Test-Simple/lib/Test2/Event/Exception.pm index 3af37689bc..4283c74ada 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Exception.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Exception.pm @@ -2,7 +2,7 @@ package Test2::Event::Exception; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Generic.pm b/cpan/Test-Simple/lib/Test2/Event/Generic.pm index f61db2b471..0b3901d3ce 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Generic.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Generic.pm @@ -5,7 +5,7 @@ use warnings; use Carp qw/croak/; use Scalar::Util qw/reftype/; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } use Test2::Util::HashBase; diff --git a/cpan/Test-Simple/lib/Test2/Event/Info.pm b/cpan/Test-Simple/lib/Test2/Event/Info.pm index 678a1ce0a1..4564eedfdd 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Info.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Info.pm @@ -4,7 +4,7 @@ use warnings; use Scalar::Util qw/blessed/; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } use Test2::Util::HashBase qw/diagnostics renderer/; diff --git a/cpan/Test-Simple/lib/Test2/Event/Note.pm b/cpan/Test-Simple/lib/Test2/Event/Note.pm index 2f34fb90c4..69cb4a49c9 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Note.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Note.pm @@ -2,7 +2,7 @@ package Test2::Event::Note; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Ok.pm b/cpan/Test-Simple/lib/Test2/Event/Ok.pm index a70fb79e7c..1c107d6f6f 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Ok.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Ok.pm @@ -2,7 +2,7 @@ package Test2::Event::Ok; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Plan.pm b/cpan/Test-Simple/lib/Test2/Event/Plan.pm index dc6c71de0b..0996b2863c 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Plan.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Plan.pm @@ -2,7 +2,7 @@ package Test2::Event::Plan; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Skip.pm b/cpan/Test-Simple/lib/Test2/Event/Skip.pm index 2b4b4eef4d..9672be7f85 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Skip.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Skip.pm @@ -2,7 +2,7 @@ package Test2::Event::Skip; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) } diff --git a/cpan/Test-Simple/lib/Test2/Event/Subtest.pm b/cpan/Test-Simple/lib/Test2/Event/Subtest.pm index 1b96c22195..6aefc0e157 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Subtest.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Subtest.pm @@ -2,16 +2,50 @@ package Test2::Event::Subtest; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) } use Test2::Util::HashBase qw{subevents buffered subtest_id}; sub init { - my $self = shift; - $self->SUPER::init(); - $self->{+SUBEVENTS} ||= []; + my $self = shift; + $self->SUPER::init(); + $self->{+SUBEVENTS} ||= []; + if ($self->{+EFFECTIVE_PASS}) { + $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}; + } +} + +{ + no warnings 'redefine'; + + sub set_subevents { + my $self = shift; + my @subevents = @_; + + if ($self->{+EFFECTIVE_PASS}) { + $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @subevents; + } + + $self->{+SUBEVENTS} = \@subevents; + } + + sub set_effective_pass { + my $self = shift; + my ($pass) = @_; + + if ($pass) { + $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}; + } + elsif ($self->{+EFFECTIVE_PASS} && !$pass) { + for my $s (grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}) { + $_->set_effective_pass(0) unless $s->can('todo') && defined $s->todo; + } + } + + $self->{+EFFECTIVE_PASS} = $pass; + } } sub summary { diff --git a/cpan/Test-Simple/lib/Test2/Event/Exception.pm b/cpan/Test-Simple/lib/Test2/Event/TAP/Version.pm similarity index 61% copy from cpan/Test-Simple/lib/Test2/Event/Exception.pm copy to cpan/Test-Simple/lib/Test2/Event/TAP/Version.pm index 3af37689bc..05ea9a5613 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Exception.pm +++ b/cpan/Test-Simple/lib/Test2/Event/TAP/Version.pm @@ -1,22 +1,18 @@ -package Test2::Event::Exception; +package Test2::Event::TAP::Version; use strict; use warnings; -our $VERSION = '1.302067'; - +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } -use Test2::Util::HashBase qw{error}; - -sub causes_fail { 1 } +use Test2::Util::HashBase qw/version/; -sub summary { +sub init { my $self = shift; - chomp(my $msg = "Exception: " . $self->{+ERROR}); - return $msg; + defined $self->{+VERSION} or $self->trace->throw("'version' is a required attribute"); } -sub diagnostics { 1 } +sub summary { 'TAP version ' . $_[0]->{+VERSION} } 1; @@ -28,20 +24,19 @@ __END__ =head1 NAME -Test2::Event::Exception - Exception event +Test2::Event::TAP::Version - Event for TAP version. =head1 DESCRIPTION -An exception event will display to STDERR, and will prevent the overall test -file from passing. +This event is used if a TAP formatter wishes to set a version. =head1 SYNOPSIS use Test2::API qw/context/; - use Test2::Event::Exception; + use Test2::Event::Encoding; my $ctx = context(); - my $event = $ctx->send_event('Exception', error => 'Stuff is broken'); + my $event = $ctx->send_event('TAP::Version', version => 42); =head1 METHODS @@ -49,9 +44,9 @@ Inherits from L<Test2::Event>. Also defines: =over 4 -=item $reason = $e->error +=item $version = $e->version -The reason for the exception. +The TAP version being parsed. =back diff --git a/cpan/Test-Simple/lib/Test2/Event/Waiting.pm b/cpan/Test-Simple/lib/Test2/Event/Waiting.pm index 5fd0b357a7..372de9e424 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Waiting.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Waiting.pm @@ -2,7 +2,7 @@ package Test2::Event::Waiting; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } diff --git a/cpan/Test-Simple/lib/Test2/Formatter.pm b/cpan/Test-Simple/lib/Test2/Formatter.pm index daa45d1e68..1ad9e44958 100644 --- a/cpan/Test-Simple/lib/Test2/Formatter.pm +++ b/cpan/Test-Simple/lib/Test2/Formatter.pm @@ -2,7 +2,7 @@ package Test2::Formatter; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; my %ADDED; diff --git a/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm b/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm index 3074e1766f..b37d31beba 100644 --- a/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm +++ b/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm @@ -3,8 +3,7 @@ use strict; use warnings; require PerlIO; -our $VERSION = '1.302067'; - +our $VERSION = '1.302071'; use Test2::Util::HashBase qw{ no_numbers handles _encoding @@ -18,14 +17,15 @@ use Carp qw/croak/; BEGIN { require Test2::Formatter; our @ISA = qw(Test2::Formatter) } my %CONVERTERS = ( - 'Test2::Event::Ok' => 'event_ok', - 'Test2::Event::Skip' => 'event_skip', - 'Test2::Event::Note' => 'event_note', - 'Test2::Event::Diag' => 'event_diag', - 'Test2::Event::Bail' => 'event_bail', - 'Test2::Event::Exception' => 'event_exception', - 'Test2::Event::Subtest' => 'event_subtest', - 'Test2::Event::Plan' => 'event_plan', + 'Test2::Event::Ok' => 'event_ok', + 'Test2::Event::Skip' => 'event_skip', + 'Test2::Event::Note' => 'event_note', + 'Test2::Event::Diag' => 'event_diag', + 'Test2::Event::Bail' => 'event_bail', + 'Test2::Event::Exception' => 'event_exception', + 'Test2::Event::Subtest' => 'event_subtest', + 'Test2::Event::Plan' => 'event_plan', + 'Test2::Event::TAP::Version' => 'event_version', ); # Initial list of converters are safe for direct hash access cause we control them. @@ -309,6 +309,15 @@ sub event_plan { return [OUT_STD, "$plan\n"]; } +sub event_version { + my $self = shift; + my ($e, $num) = @_; + + my $version = $e->version; + + return [OUT_STD, "TAP version $version\n"]; +} + sub event_other { my $self = shift; my ($e, $num) = @_; diff --git a/cpan/Test-Simple/lib/Test2/Hub.pm b/cpan/Test-Simple/lib/Test2/Hub.pm index 5acee794f5..20fb035de5 100644 --- a/cpan/Test-Simple/lib/Test2/Hub.pm +++ b/cpan/Test-Simple/lib/Test2/Hub.pm @@ -2,7 +2,7 @@ package Test2::Hub; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Carp qw/carp croak confess/; diff --git a/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm b/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm index 97a257e7f4..036c37002e 100644 --- a/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm +++ b/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm @@ -2,7 +2,7 @@ package Test2::Hub::Interceptor; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test2::Hub::Interceptor::Terminator(); diff --git a/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm b/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm index c527e3a23e..785cca7043 100644 --- a/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm +++ b/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm @@ -2,7 +2,7 @@ package Test2::Hub::Interceptor::Terminator; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; 1; diff --git a/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm b/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm index 668ea6196f..5704a4f8bf 100644 --- a/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm +++ b/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm @@ -2,7 +2,7 @@ package Test2::Hub::Subtest; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::Hub; our @ISA = qw(Test2::Hub) } diff --git a/cpan/Test-Simple/lib/Test2/IPC.pm b/cpan/Test-Simple/lib/Test2/IPC.pm index 67b8d4e8a3..67707aff5e 100644 --- a/cpan/Test-Simple/lib/Test2/IPC.pm +++ b/cpan/Test-Simple/lib/Test2/IPC.pm @@ -2,7 +2,7 @@ package Test2::IPC; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Test2::API::Instance; diff --git a/cpan/Test-Simple/lib/Test2/IPC/Driver.pm b/cpan/Test-Simple/lib/Test2/IPC/Driver.pm index ba0800cacf..68b186c60c 100644 --- a/cpan/Test-Simple/lib/Test2/IPC/Driver.pm +++ b/cpan/Test-Simple/lib/Test2/IPC/Driver.pm @@ -2,7 +2,7 @@ package Test2::IPC::Driver; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Carp qw/confess longmess/; diff --git a/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm b/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm index 5e0418fdf5..cdfbba569e 100644 --- a/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm +++ b/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm @@ -2,7 +2,7 @@ package Test2::IPC::Driver::Files; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; BEGIN { require Test2::IPC::Driver; our @ISA = qw(Test2::IPC::Driver) } diff --git a/cpan/Test-Simple/lib/Test2/Util.pm b/cpan/Test-Simple/lib/Test2/Util.pm index 0a5347a52a..0a23de27b3 100644 --- a/cpan/Test-Simple/lib/Test2/Util.pm +++ b/cpan/Test-Simple/lib/Test2/Util.pm @@ -2,7 +2,7 @@ package Test2::Util; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Config qw/%Config/; diff --git a/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm b/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm index 38c81b97e9..bc62d7b73b 100644 --- a/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm +++ b/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm @@ -2,7 +2,7 @@ package Test2::Util::ExternalMeta; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use Carp qw/croak/; diff --git a/cpan/Test-Simple/lib/Test2/Util/HashBase.pm b/cpan/Test-Simple/lib/Test2/Util/HashBase.pm index 02516da798..76041efe5e 100644 --- a/cpan/Test-Simple/lib/Test2/Util/HashBase.pm +++ b/cpan/Test-Simple/lib/Test2/Util/HashBase.pm @@ -2,13 +2,26 @@ package Test2::Util::HashBase; use strict; use warnings; -our $VERSION = '1.302067'; +################################################################# +# # +# This is a generated file! Do not modify this file directly! # +# Use hashbase_inc.pl script to regenerate this file. # +# The script is part of the Object::HashBase distribution. # +# # +################################################################# + +{ + no warnings 'once'; + $Test2::Util::HashBase::VERSION = '0.002'; + *Test2::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS; +} require Carp; -$Carp::Internal{+__PACKAGE__} = 1; - -my %ATTR_SUBS; +{ + no warnings 'once'; + $Carp::Internal{+__PACKAGE__} = 1; +} BEGIN { # these are not strictly equivalent, but for out use we don't care @@ -24,21 +37,33 @@ BEGIN { } } +my %STRIP = ( + '^' => 1, + '-' => 1, +); + sub import { my $class = shift; - my $into = caller; + my $into = caller; - my $isa = _isa($into); - my $attr_subs = $ATTR_SUBS{$into} ||= {}; - my %subs = ( + my $isa = _isa($into); + my $attr_subs = $Test2::Util::HashBase::ATTR_SUBS{$into} ||= {}; + my %subs = ( ($into->can('new') ? () : (new => \&_new)), - (map %{ $ATTR_SUBS{$_}||{} }, @{$isa}[1 .. $#$isa]), - (map { - my ($sub, $attr) = (uc $_, $_); - $sub => ($attr_subs->{$sub} = sub() { $attr }), - $attr => sub { $_[0]->{$attr} }, - "set_$attr" => sub { $_[0]->{$attr} = $_[1] }, - } @_), + (map %{$Test2::Util::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]), + ( + map { + my $p = substr($_, 0, 1); + my $x = $_; + substr($x, 0, 1) = '' if $STRIP{$p}; + my ($sub, $attr) = (uc $x, $x); + $sub => ($attr_subs->{$sub} = sub() { $attr }), + $attr => sub { $_[0]->{$attr} }, + $p eq '-' ? ("set_$attr" => sub { Carp::croak("'$attr' is read-only") }) + : $p eq '^' ? ("set_$attr" => sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] }) + : ("set_$attr" => sub { $_[0]->{$attr} = $_[1] }), + } @_ + ), ); no strict 'refs'; @@ -62,8 +87,7 @@ __END__ =head1 NAME -Test2::Util::HashBase - Base class for classes that use a hashref -of a hash. +Test2::Util::HashBase - Build hash based classes. =head1 SYNOPSIS @@ -74,7 +98,7 @@ A class: use warnings; # Generate 3 accessors - use Test2::Util::HashBase qw/foo bar baz/; + use Test2::Util::HashBase qw/foo -bar ^baz/; # Chance to initialize defaults sub init { @@ -103,7 +127,7 @@ Subclass it # We get the constants from the base class for free. $self->{+FOO} ||= 'SubFoo'; - $self->{+BAT} || = 'bat'; + $self->{+BAT} ||= 'bat'; $self->SUPER::init(); } @@ -124,7 +148,12 @@ use it: # Setters! $one->set_foo('A Foo'); - $one->set_bar('A Bar'); + + #'-bar' means read-only, so the setter will throw an exception (but is defined). + $one->set_bar('A bar'); + + # '^baz' means deprecated setter, this will warn about the setter being + # deprecated. $one->set_baz('A Baz'); $one->{+FOO} = 'xxx'; @@ -138,6 +167,13 @@ generated for you. You also get constants for each accessor (all caps) which return the key into the hash for that accessor. Single inheritance is also supported. +=head1 THIS IS A BUNDLED COPY OF HASHBASE + +This is a bundled copy of L<Object::HashBase>. This file was generated using +the +C</home/exodist/perl5/perlbrew/perls/main/bin/hashbase_inc.pl> +script. + =head1 METHODS =head2 PROVIDED BY HASH BASE @@ -222,8 +258,8 @@ are added to subclasses automatically. =head1 SOURCE -The source code repository for Test2 can be found at -F<http://github.com/Test-More/test-more/>. +The source code repository for HashBase can be found at +F<http://github.com/Test-More/HashBase/>. =head1 MAINTAINERS diff --git a/cpan/Test-Simple/lib/Test2/Util/Trace.pm b/cpan/Test-Simple/lib/Test2/Util/Trace.pm index 7884f0c9b6..20bce5602f 100644 --- a/cpan/Test-Simple/lib/Test2/Util/Trace.pm +++ b/cpan/Test-Simple/lib/Test2/Util/Trace.pm @@ -2,10 +2,10 @@ package Test2::Util::Trace; use strict; use warnings; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; -use Test2::Util qw/get_tid/; +use Test2::Util qw/get_tid pkg_to_file/; use Carp qw/confess/; @@ -47,6 +47,21 @@ sub file { $_[0]->{+FRAME}->[1] } sub line { $_[0]->{+FRAME}->[2] } sub subname { $_[0]->{+FRAME}->[3] } +sub from_json { + my $class = shift; + my %p = @_; + + my $trace_pkg = delete $p{__PACKAGE__}; + require(pkg_to_file($trace_pkg)); + + return $trace_pkg->new(%p); +} + +sub TO_JSON { + my $self = shift; + return {%$self, __PACKAGE__ => ref $self}; +} + 1; __END__ @@ -124,6 +139,18 @@ Get the debug-info line number. Get the debug-info subroutine name. +=item $hashref = $t->TO_JSON + +This returns a hashref suitable for passing to the C<< +Test2::Util::Trace->from_json >> constructor. It is intended for use with the +L<JSON> family of modules, which will look for a C<TO_JSON> method when +C<convert_blessed> is true. + +=item $t = Test2::Util::Trace->from_json(%$hashref) + +Given the hash of data returned by C<< $t->TO_JSON >>, this method returns a +new trace object of the appropriate subclass. + =back =head1 SOURCE diff --git a/cpan/Test-Simple/lib/ok.pm b/cpan/Test-Simple/lib/ok.pm index 71b57c3f49..0d82054551 100644 --- a/cpan/Test-Simple/lib/ok.pm +++ b/cpan/Test-Simple/lib/ok.pm @@ -1,5 +1,5 @@ package ok; -our $VERSION = '1.302067'; +our $VERSION = '1.302071'; use strict; use Test::More (); diff --git a/cpan/Test-Simple/t/Test2/behavior/Subtest_todo.t b/cpan/Test-Simple/t/Test2/behavior/Subtest_todo.t new file mode 100644 index 0000000000..2ee0608e62 --- /dev/null +++ b/cpan/Test-Simple/t/Test2/behavior/Subtest_todo.t @@ -0,0 +1,29 @@ +use strict; +use warnings; + +BEGIN { require "t/tools.pl" } + +use Test2::API qw/run_subtest intercept/; + +my $events = intercept { + todo 'testing todo', sub { + run_subtest( + 'fails in todo', + sub { + ok(1, 'first passes'); + ok(0, 'second fails'); + }); + }; +}; + +ok($events->[1], 'Test2::Event::Subtest', 'subtest ran'); +ok($events->[1]->effective_pass, 'Test2::Event::Subtest', 'subtest effective_pass is true'); +ok($events->[1]->todo, 'testing todo', 'subtest todo is set to expected value'); +my @oks = grep { $_->isa('Test2::Event::Ok') } @{$events->[1]->subevents}; +is(scalar @oks, 2, 'got 2 Ok events in the subtest'); +ok($oks[0]->pass, 'first event passed'); +ok($oks[0]->effective_pass, 'first event effective_pass is true'); +ok(!$oks[1]->pass, 'second event failed'); +ok($oks[1]->effective_pass, 'second event effective_pass is true'); + +done_testing; diff --git a/cpan/Test-Simple/t/Test2/modules/Formatter/TAP.t b/cpan/Test-Simple/t/Test2/modules/Formatter/TAP.t index 887db1e5ba..a232186831 100644 --- a/cpan/Test-Simple/t/Test2/modules/Formatter/TAP.t +++ b/cpan/Test-Simple/t/Test2/modules/Formatter/TAP.t @@ -531,4 +531,19 @@ tests skip => sub { ); }; +tests version => sub { + require Test2::Event::TAP::Version; + my $ver = Test2::Event::TAP::Version->new( + trace => $trace, + version => '2', + ); + + is_deeply( + [$fmt->event_tap($ver, 1)], + [[OUT_STD, "TAP version 2\n"]], + "Got tap" + ); +}; + + done_testing; diff --git a/cpan/Test-Simple/t/Test2/modules/Util/HashBase.t b/cpan/Test-Simple/t/Test2/modules/Util/HashBase.t index 0e81e9fcec..7f1824ae16 100644 --- a/cpan/Test-Simple/t/Test2/modules/Util/HashBase.t +++ b/cpan/Test-Simple/t/Test2/modules/Util/HashBase.t @@ -1,10 +1,30 @@ use strict; use warnings; -BEGIN { require "t/tools.pl" }; + +use Test::More; + + +sub warnings(&) { + my $code = shift; + my @warnings; + local $SIG{__WARN__} = sub { push @warnings => @_ }; + $code->(); + return \@warnings; +} + +sub exception(&) { + my $code = shift; + local ($@, $!, $SIG{__DIE__}); + my $ok = eval { $code->(); 1 }; + my $error = $@ || 'SQUASHED ERROR'; + return $ok ? undef : $error; +} + BEGIN { - $INC{'My/HBase.pm'} = __FILE__; + $INC{'Object/HashBase/Test/HBase.pm'} = __FILE__; - package My::HBase; + package + main::HBase; use Test2::Util::HashBase qw/foo bar baz/; main::is(FOO, 'foo', "FOO CONSTANT"); @@ -13,8 +33,9 @@ BEGIN { } BEGIN { - package My::HBaseSub; - use base 'My::HBase'; + package + main::HBaseSub; + use base 'main::HBase'; use Test2::Util::HashBase qw/apple pear/; main::is(FOO, 'foo', "FOO CONSTANT"); @@ -24,7 +45,7 @@ BEGIN { main::is(PEAR, 'pear', "PEAR CONSTANT"); } -my $one = My::HBase->new(foo => 'a', bar => 'b', baz => 'c'); +my $one = main::HBase->new(foo => 'a', bar => 'b', baz => 'c'); is($one->foo, 'a', "Accessor"); is($one->bar, 'b', "Accessor"); is($one->baz, 'c', "Accessor"); @@ -43,7 +64,8 @@ is_deeply( ); BEGIN { - package My::Const::Test; + package + main::Const::Test; use Test2::Util::HashBase qw/foo/; sub do_it { @@ -54,19 +76,20 @@ BEGIN { } } -my $pkg = 'My::Const::Test'; +my $pkg = 'main::Const::Test'; is($pkg->do_it, 'const', "worked as expected"); { local $SIG{__WARN__} = sub { }; - *My::Const::Test::FOO = sub { 0 }; + *main::Const::Test::FOO = sub { 0 }; } ok(!$pkg->FOO, "overrode const sub"); is($pkg->do_it, 'const', "worked as expected, const was constant"); BEGIN { - $INC{'My/HBase/Wrapped.pm'} = __FILE__; + $INC{'Object/HashBase/Test/HBase/Wrapped.pm'} = __FILE__; - package My::HBase::Wrapped; + package + main::HBase::Wrapped; use Test2::Util::HashBase qw/foo bar/; my $foo = __PACKAGE__->can('foo'); @@ -79,19 +102,21 @@ BEGIN { } BEGIN { - $INC{'My/HBase/Wrapped/Inherit.pm'} = __FILE__; + $INC{'Object/HashBase/Test/HBase/Wrapped/Inherit.pm'} = __FILE__; - package My::HBase::Wrapped::Inherit; - use base 'My::HBase::Wrapped'; + package + main::HBase::Wrapped::Inherit; + use base 'main::HBase::Wrapped'; use Test2::Util::HashBase; } -my $o = My::HBase::Wrapped::Inherit->new(foo => 1); +my $o = main::HBase::Wrapped::Inherit->new(foo => 1); my $foo = $o->foo; is($o->bar, 1, 'parent attribute sub not overridden'); { - package Foo; + package + Foo; sub new; @@ -102,4 +127,31 @@ is($o->bar, 1, 'parent attribute sub not overridden'); is(Foo->new, 'foo', "Did not override existing 'new' method"); +BEGIN { + $INC{'Object/HashBase/Test/HBase2.pm'} = __FILE__; + + package + main::HBase2; + use Test2::Util::HashBase qw/foo -bar ^baz/; + + main::is(FOO, 'foo', "FOO CONSTANT"); + main::is(BAR, 'bar', "BAR CONSTANT"); + main::is(BAZ, 'baz', "BAZ CONSTANT"); +} + +my $ro = main::HBase2->new(foo => 'foo', bar => 'bar', baz => 'baz'); +is($ro->foo, 'foo', "got foo"); +is($ro->bar, 'bar', "got bar"); +is($ro->baz, 'baz', "got baz"); + +is($ro->set_foo('xxx'), 'xxx', "Can set foo"); +is($ro->foo, 'xxx', "got foo"); + +like(exception { $ro->set_bar('xxx') }, qr/'bar' is read-only/, "Cannot set bar"); + +my $warnings = warnings { is($ro->set_baz('xxx'), 'xxx', 'set baz') }; +like($warnings->[0], qr/set_baz\(\) is deprecated/, "Deprecation warning"); + done_testing; + +1; diff --git a/cpan/Test-Simple/t/tools.pl b/cpan/Test-Simple/t/tools.pl index e97bc78707..a5afc482ac 100644 --- a/cpan/Test-Simple/t/tools.pl +++ b/cpan/Test-Simple/t/tools.pl @@ -172,6 +172,37 @@ sub skip_all { $ctx->release if $ctx; } +sub todo { + my ($reason, $sub) = @_; + my $ctx = context(); + + # This code is mostly copied from Test2::Todo in the Test2-Suite + # distribution. + my $hub = test2_stack->top; + my $filter = $hub->pre_filter( + sub { + my ($active_hub, $event) = @_; + + # Turn a diag into a note + return Test2::Event::Note->new(%$event) if ref($event) eq 'Test2::Event::Diag'; + + # Set todo on ok's + if ($hub == $active_hub && $event->isa('Test2::Event::Ok')) { + $event->set_todo($reason); + $event->set_effective_pass(1); + } + + return $event; + }, + inherit => 1, + todo => $reason, + ); + $sub->(); + $hub->pre_unfilter($filter); + + $ctx->release if $ctx; +} + sub plan { my ($max) = @_; my $ctx = context(); -- Perl5 Master Repository
