commit perl-Carp-Assert-More for openSUSE:Factory
Hello community, here is the log from the commit of package perl-Carp-Assert-More for openSUSE:Factory checked in at 2017-08-24 18:52:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Carp-Assert-More (Old) and /work/SRC/openSUSE:Factory/.perl-Carp-Assert-More.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-Carp-Assert-More" Thu Aug 24 18:52:38 2017 rev:7 rq:516828 version:1.16 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Carp-Assert-More/perl-Carp-Assert-More.changes 2013-06-06 15:10:26.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Carp-Assert-More.new/perl-Carp-Assert-More.changes 2017-08-24 18:52:43.654643849 +0200 @@ -1,0 +2,24 @@ +Sat Aug 5 05:10:50 UTC 2017 - coolo@suse.com + +- updated to 1.16 + see /usr/share/doc/packages/perl-Carp-Assert-More/Changes + + 1.16 Fri Aug 4 14:18:51 CDT 2017 + [ENHANCEMENTS] + Added the following functions: + * assert_numeric( $n ) + * assert_all_keys_in( \%hash, \@keylist ) + * assert_empty( [\%hash|\@list] ) + * assert_coderef( $ref ) + * assert_isa_in( $ref, \@class_list ) + Thanks to Eric A. Zarko for some of them. The rest were migrated + from a private code project. + + Renamed assert_listref() to assert_arrayref(), but keep + assert_listref() as backward compatibility. assert_listref() + may go away in the future. + + [DOCUMENTATION] + Fixed a goof in the assert_integer() docs. Thanks, Randy Lauen. + +------------------------------------------------------------------- Old: ---- Carp-Assert-More-1.14.tar.gz New: ---- Carp-Assert-More-1.16.tar.gz cpanspec.yml ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Carp-Assert-More.spec ++++++ --- /var/tmp/diff_new_pack.oIx3xm/_old 2017-08-24 18:52:44.726492927 +0200 +++ /var/tmp/diff_new_pack.oIx3xm/_new 2017-08-24 18:52:44.742490674 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Carp-Assert-More # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,28 +17,28 @@ Name: perl-Carp-Assert-More -Version: 1.14 +Version: 1.16 Release: 0 %define cpan_name Carp-Assert-More -Summary: Convenience wrappers around Carp::Assert +Summary: Convenience Wrappers Around Carp::Assert License: Artistic-2.0 Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Carp-Assert-More/ -Source: http://www.cpan.org/authors/id/P/PE/PETDANCE/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/P/PE/PETDANCE/%{cpan_name}-%{version}.tar.gz +Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Carp::Assert) BuildRequires: perl(Test::Exception) -#BuildRequires: perl(Carp::Assert::More) Requires: perl(Carp::Assert) Requires: perl(Test::Exception) %{perl_requires} %description -Carp::Assert::More is a set of wrappers around the the Carp::Assert manpage -functions to make the habit of writing assertions even easier. +Carp::Assert::More is a set of wrappers around the Carp::Assert functions +to make the habit of writing assertions even easier. Everything in here is effectively syntactic sugar. There's no technical reason to use @@ -72,6 +72,6 @@ %files -f %{name}.files %defattr(-,root,root,755) -%doc Changes README +%doc Changes README.md %changelog ++++++ Carp-Assert-More-1.14.tar.gz -> Carp-Assert-More-1.16.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/Changes new/Carp-Assert-More-1.16/Changes --- old/Carp-Assert-More-1.14/Changes 2012-10-31 17:37:08.000000000 +0100 +++ new/Carp-Assert-More-1.16/Changes 2017-08-04 21:18:59.000000000 +0200 @@ -1,5 +1,23 @@ Revision history for Perl extension Carp::Assert::More. +1.16 Fri Aug 4 14:18:51 CDT 2017 + [ENHANCEMENTS] + Added the following functions: + * assert_numeric( $n ) + * assert_all_keys_in( \%hash, \@keylist ) + * assert_empty( [\%hash|\@list] ) + * assert_coderef( $ref ) + * assert_isa_in( $ref, \@class_list ) + Thanks to Eric A. Zarko for some of them. The rest were migrated + from a private code project. + + Renamed assert_listref() to assert_arrayref(), but keep + assert_listref() as backward compatibility. assert_listref() + may go away in the future. + + [DOCUMENTATION] + Fixed a goof in the assert_integer() docs. Thanks, Randy Lauen. + 1.14 Wed Oct 31 11:37:04 CDT 2012 [ENHANCEMENTS] Added assert_undefined() for Ben Hengst. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/MANIFEST new/Carp-Assert-More-1.16/MANIFEST --- old/Carp-Assert-More-1.14/MANIFEST 2012-10-31 17:37:25.000000000 +0100 +++ new/Carp-Assert-More-1.16/MANIFEST 2017-08-04 21:19:09.000000000 +0200 @@ -3,9 +3,13 @@ MANIFEST Makefile.PL More.pm -README +README.md t/00-load.t +t/assert_all_keys_in.t +t/assert_arrayref.t +t/assert_coderef.t t/assert_defined.t +t/assert_empty.t t/assert_exists.t t/assert_fail.t t/assert_hashref.t @@ -13,6 +17,7 @@ t/assert_integer.t t/assert_is.t t/assert_isa.t +t/assert_isa_in.t t/assert_isnt.t t/assert_lacks.t t/assert_like.t @@ -26,6 +31,7 @@ t/assert_nonref.t t/assert_nonzero_integer.t t/assert_nonzero.t +t/assert_numeric.t t/assert_positive_integer.t t/assert_positive.t t/assert_undefined.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/META.json new/Carp-Assert-More-1.16/META.json --- old/Carp-Assert-More-1.14/META.json 2012-10-31 17:37:25.000000000 +0100 +++ new/Carp-Assert-More-1.16/META.json 2017-08-04 21:19:09.000000000 +0200 @@ -4,7 +4,7 @@ "unknown" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112621", + "generated_by" : "ExtUtils::MakeMaker version 7.16, CPAN::Meta::Converter version 2.150005", "license" : [ "artistic_2" ], @@ -22,20 +22,20 @@ "prereqs" : { "build" : { "requires" : { - "ExtUtils::MakeMaker" : 0 + "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { - "ExtUtils::MakeMaker" : 0 + "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { - "Carp" : 0, - "Carp::Assert" : 0, - "Scalar::Util" : 0, - "Test::Exception" : 0, + "Carp" : "0", + "Carp::Assert" : "0", + "Scalar::Util" : "0", + "Test::Exception" : "0", "Test::More" : "0.18" } } @@ -49,8 +49,9 @@ "http://www.opensource.org/licenses/artistic-license-2.0.php" ], "repository" : { - "url" : "http://github.com/petdance/carp-assert-more/tree/master" + "url" : "https://github.com/petdance/carp-assert-more/tree/master" } }, - "version" : "1.14" + "version" : "1.16", + "x_serialization_backend" : "JSON::PP version 2.27400" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/META.yml new/Carp-Assert-More-1.16/META.yml --- old/Carp-Assert-More-1.14/META.yml 2012-10-31 17:37:24.000000000 +0100 +++ new/Carp-Assert-More-1.16/META.yml 2017-08-04 21:19:09.000000000 +0200 @@ -3,28 +3,29 @@ author: - unknown build_requires: - ExtUtils::MakeMaker: 0 + ExtUtils::MakeMaker: '0' configure_requires: - ExtUtils::MakeMaker: 0 + ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112621' +generated_by: 'ExtUtils::MakeMaker version 7.16, CPAN::Meta::Converter version 2.150005' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + version: '1.4' name: Carp-Assert-More no_index: directory: - t - inc requires: - Carp: 0 - Carp::Assert: 0 - Scalar::Util: 0 - Test::Exception: 0 - Test::More: 0.18 + Carp: '0' + Carp::Assert: '0' + Scalar::Util: '0' + Test::Exception: '0' + Test::More: '0.18' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Carp-Assert-More license: http://www.opensource.org/licenses/artistic-license-2.0.php - repository: http://github.com/petdance/carp-assert-more/tree/master -version: 1.14 + repository: https://github.com/petdance/carp-assert-more/tree/master +version: '1.16' +x_serialization_backend: 'CPAN::Meta::YAML version 0.012' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/Makefile.PL new/Carp-Assert-More-1.16/Makefile.PL --- old/Carp-Assert-More-1.14/Makefile.PL 2012-10-31 15:53:54.000000000 +0100 +++ new/Carp-Assert-More-1.16/Makefile.PL 2017-08-04 21:18:59.000000000 +0200 @@ -37,7 +37,7 @@ $parms{META_MERGE} = { resources => { bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Carp-Assert-More', - repository => 'http://github.com/petdance/carp-assert-more/tree/master', + repository => 'https://github.com/petdance/carp-assert-more/tree/master', license => 'http://www.opensource.org/licenses/artistic-license-2.0.php', } }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/More.pm new/Carp-Assert-More-1.16/More.pm --- old/Carp-Assert-More-1.14/More.pm 2012-10-31 17:19:28.000000000 +0100 +++ new/Carp-Assert-More-1.16/More.pm 2017-08-04 21:18:59.000000000 +0200 @@ -7,8 +7,7 @@ use vars qw( $VERSION @ISA @EXPORT ); -*_fail_msg = *Carp::Assert::_fail_msg; - +sub _any(&;@); =head1 NAME @@ -16,15 +15,19 @@ =head1 VERSION -Version 1.14 +Version 1.16 =cut BEGIN { - $VERSION = '1.14'; + $VERSION = '1.16'; @ISA = qw(Exporter); @EXPORT = qw( + assert_all_keys_in + assert_arrayref + assert_coderef assert_defined + assert_empty assert_exists assert_fail assert_hashref @@ -32,6 +35,7 @@ assert_integer assert_is assert_isa + assert_isa_in assert_isnt assert_lacks assert_like @@ -45,6 +49,7 @@ assert_nonref assert_nonzero assert_nonzero_integer + assert_numeric assert_positive assert_positive_integer assert_undefined @@ -109,7 +114,7 @@ return if $string eq $match; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_isnt( $string, $unmatch [,$name] ) @@ -129,7 +134,7 @@ return if defined($string) && defined($unmatch) && ($string ne $unmatch); require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_like( $string, qr/regex/ [,$name] ) @@ -150,7 +155,7 @@ return if $string =~ $regex; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_unlike( $string, qr/regex/ [,$name] ) @@ -173,7 +178,7 @@ return if $string !~ $regex; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_defined( $this [, $name] ) @@ -186,7 +191,7 @@ return if defined( $_[0] ); require Carp; - &Carp::confess( _fail_msg($_[1]) ); + &Carp::confess( Carp::Assert::_fail_msg($_[1]) ); } =head2 assert_undefined( $this [, $name] ) @@ -199,7 +204,7 @@ return unless defined( $_[0] ); require Carp; - &Carp::confess( _fail_msg($_[1]) ); + &Carp::confess( Carp::Assert::_fail_msg($_[1]) ); } =head2 assert_nonblank( $this [, $name] ) @@ -216,18 +221,37 @@ return if $this ne ""; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } + =head1 NUMERIC ASSERTIONS +=head2 assert_numeric( $n [, $name] ) + +Asserts that C<$n> looks like a number, according to C<Scalar::Util::looks_like_number>. + +=cut + +sub assert_numeric { + my $n = shift; + my $name = shift; + + require Scalar::Util; + + assert( Scalar::Util::looks_like_number( $n ), $name ); + + return; +} + + =head2 assert_integer( $this [, $name ] ) Asserts that I<$this> is an integer, which may be zero or negative. assert_integer( 0 ); # pass assert_integer( 14 ); # pass - assert_integer( -14 ); # FAIL + assert_integer( -14 ); # pass assert_integer( '14.' ); # FAIL =cut @@ -240,7 +264,7 @@ return if $this =~ /^-?\d+$/; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_nonzero( $this [, $name ] ) @@ -263,7 +287,7 @@ return if $this+0 != 0; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_positive( $this [, $name ] ) @@ -284,7 +308,7 @@ return if $this+0 > 0; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_nonnegative( $this [, $name ] ) @@ -308,7 +332,7 @@ return if $this+0 >= 0; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_negative( $this [, $name ] ) @@ -329,7 +353,7 @@ return if $this+0 < 0; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_nonzero_integer( $this [, $name ] ) @@ -434,10 +458,76 @@ return if ref($this) eq $type; require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } +=head2 assert_isa_in( $obj, \@types [, $description] ) + +Assert that the blessed C<$obj> isa one of the types in C<\@types>. + + assert_isa_in( $obj, [ 'My::Foo', 'My::Bar' ], 'Must pass either a Foo or Bar object' ); + +=cut + +sub assert_isa_in($$;$) { + my $obj = shift; + my $types = shift; + my $name = shift; + + require Scalar::Util; + + my $ok = _any { Scalar::Util::blessed($obj) && $obj->isa($_) } @{$types}; + assert( $ok, $name ); + + return; +} + + +=head2 assert_empty( $this [, $name ] ) + +I<$this> must be a ref to either a hash or an array. Asserts that that +collection contains no elements. Will assert (with its own message, +not I<$name>) unless given a hash or array ref. It is OK if I<$this> has +been blessed into objecthood, but the semantics of checking an object to see +if it does not have keys (for a hashref) or returns 0 in scalar context (for +an array ref) may not be what you want. + + assert_empty( 0 ); # FAIL + assert_empty( 'foo' ); # FAIL + assert_empty( undef ); # FAIL + assert_empty( {} ); # pass + assert_empty( [] ); # pass + assert_empty( {foo=>1} );# FAIL + assert_empty( [1,2,3] ); # FAIL + +=cut + +sub assert_empty($;$) { + my $ref = shift; + my $name = shift; + + require Scalar::Util; + + my $underlying_type; + if ( Scalar::Util::blessed( $ref ) ) { + $underlying_type = Scalar::Util::reftype( $ref ); + } + else { + $underlying_type = ref( $ref ); + } + + if ( $underlying_type eq 'HASH' ) { + assert_is( scalar keys %{$ref}, 0, $name ); + } + elsif ( $underlying_type eq 'ARRAY' ) { + assert_is( scalar @{$ref}, 0, $name ); + } + else { + assert_fail( 'Not an array or hash reference' ); + } +} + =head2 assert_nonempty( $this [, $name ] ) I<$this> must be a ref to either a hash or an array. Asserts that that @@ -496,7 +586,7 @@ return unless ref( $this ); require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_hashref( $ref [,$name] ) @@ -527,6 +617,8 @@ return assert_isa( $ref, 'HASH', $name ); } +=head2 assert_arrayref( $ref [, $name] ) + =head2 assert_listref( $ref [,$name] ) Asserts that I<$ref> is defined, and is a reference to a (possibly empty) list. @@ -535,14 +627,31 @@ hash (see C<assert_hashref>) applies here; this method returns false even for objects whose underlying structure is an array. +C<assert_listref> is an alias for C<assert_arrayref> and may go away in +the future. Use C<assert_arrayref> instead. + =cut -sub assert_listref($;$) { - my $ref = shift; +sub assert_arrayref($;$) { + my $ref = shift; my $name = shift; return assert_isa( $ref, 'ARRAY', $name ); } +*assert_listref = *assert_arrayref; + +=head2 assert_coderef( $ref [,$name] ) + +Asserts that I<$ref> is defined, and is a reference to a closure. + +=cut + +sub assert_coderef($;$) { + my $ref = shift; + my $name = shift; + + return assert_isa( $ref, 'CODE', $name ); +} =head1 SET AND HASH MEMBERSHIP @@ -567,7 +676,7 @@ return if $string eq $element; } require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } =head2 assert_exists( \%hash, $key [,$name] ) @@ -595,7 +704,7 @@ for ( @list ) { if ( !exists( $hash->{$_} ) ) { require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } } } @@ -624,11 +733,39 @@ for ( @list ) { if ( exists( $hash->{$_} ) ) { require Carp; - &Carp::confess( _fail_msg($name) ); + &Carp::confess( Carp::Assert::_fail_msg($name) ); } } } + +=head2 assert_all_keys_in( \%hash, \@names [, $name ] ) + +Asserts that each key in C<%hash> is in the list of C<@names>. + +This is used to ensure that there are no extra keys in a given hash. + + assert_all_keys_in( $obj, [qw( height width depth )], '$obj can only contain height, width and depth keys' ); + +=cut + +sub assert_all_keys_in { + my $hash = shift; + my $valid_keys = shift; + my $name = shift; + + assert_hashref( $hash ); + assert_listref( $valid_keys ); + + foreach my $key ( keys %{$hash} ) { + assert_in( $key, $valid_keys, $name ); + } + + return; +} + + + =head1 UTILITY ASSERTIONS =head2 assert_fail( [$name] ) @@ -641,13 +778,21 @@ sub assert_fail(;$) { require Carp; - &Carp::confess( _fail_msg($_[0]) ); + &Carp::confess( Carp::Assert::_fail_msg($_[0]) ); +} + + +# Since List::Util doesn't have any() all the way back. +sub _any(&;@) { + my $sub = shift; + $sub->($_) && return 1 for @_; + return 0; } =head1 COPYRIGHT & LICENSE -Copyright 2005-2012 Andy Lester. +Copyright 2005-2017 Andy Lester. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. @@ -655,6 +800,7 @@ =head1 ACKNOWLEDGEMENTS Thanks to +Eric A. Zarko, Bob Diss, Pete Krawczyk, David Storrs, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/README new/Carp-Assert-More-1.16/README --- old/Carp-Assert-More-1.14/README 2012-10-31 14:51:23.000000000 +0100 +++ new/Carp-Assert-More-1.16/README 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -# Carp::Assert::More - -Carp::Assert::More is a set of handy assertion functions for Perl. - -For example, instead of writing - - assert( $foo ne '', '$foo cannot be blank' ); - -you can write - - assert_nonblank( $foo, '$foo cannot be blank' ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/README.md new/Carp-Assert-More-1.16/README.md --- old/Carp-Assert-More-1.14/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/README.md 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,14 @@ +# Carp::Assert::More + +[![Build Status](https://travis-ci.org/petdance/carp-assert-more.svg?branch=dev)](https://travis-ci.org/petdance/carp-assert-more) + +Carp::Assert::More is a set of handy assertion functions for Perl. + +For example, instead of writing + + assert( defined($foo), '$foo cannot be undefined' ); + assert( $foo ne '', '$foo cannot be blank' ); + +you can write + + assert_nonblank( $foo, '$foo cannot be blank' ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_all_keys_in.t new/Carp-Assert-More-1.16/t/assert_all_keys_in.t --- old/Carp-Assert-More-1.14/t/assert_all_keys_in.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_all_keys_in.t 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,36 @@ +#!perl -Tw + +use warnings; +use strict; + +use Test::More tests => 3; + +use Carp::Assert::More; + +use Test::Exception; + +my $monolith = { + depth => 1, + width => 4, + height => 9, +}; +my $shaq = { + firstname => 'Shaquille', + lastname => 'O\'Neal', + height => 85, +}; + +my @object_keys = qw( height width depth ); +my @person_keys = qw( firstname lastname height ); + +lives_ok( sub { assert_all_keys_in( $monolith, \@object_keys ) }, 'Monolith object has valid keys' ); +lives_ok( sub { assert_all_keys_in( $shaq, \@person_keys ) }, 'Shaq object has valid keys' ); + +throws_ok( + sub { assert_all_keys_in( $monolith, \@person_keys ) }, + qr/Assertion.*failed!/, + 'Monolith fails on person keys' +); + +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_arrayref.t new/Carp-Assert-More-1.16/t/assert_arrayref.t --- old/Carp-Assert-More-1.14/t/assert_arrayref.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_arrayref.t 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,66 @@ +#!perl -Tw + +# This is cut & paste of assert_arrayref.t + +package Foo; + +sub new { my $class = shift; return bless [@_], $class; } + +package main; + +use warnings; +use strict; + +use Test::More tests => 7; + +use Carp::Assert::More; + +local $@; +$@ = ''; + +# {} is not a listref +eval { + assert_arrayref( {} ); +}; +like( $@, qr/Assertion.*failed/ ); + +# a ref to a hash with stuff in it is not a listref +my $ref = { foo => 'foo', bar => 'bar' }; +eval { + assert_arrayref( $ref ); +}; +like( $@, qr/Assertion.*failed/ ); + +# 3 is not a listref +eval { + assert_arrayref( 3 ); +}; +like( $@, qr/Assertion.*failed/ ); + +# [] is a listref +eval { + assert_arrayref( [] ); +}; +is( $@, '' ); + +# a ref to a list with stuff in it is a listref +my @ary = ('foo', 'bar', 'baaz'); +eval { + assert_arrayref( \@ary ); +}; +is( $@, '' ); + +# sub {} is not a listref +eval { + assert_arrayref( sub {} ); +}; +like( $@, qr/Assertion.*failed/ ); + +# Foo->new->isa("ARRAY") returns true, so do we +eval { + assert_arrayref( Foo->new ); +}; +is( $@, '' ); + +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_coderef.t new/Carp-Assert-More-1.16/t/assert_coderef.t --- old/Carp-Assert-More-1.14/t/assert_coderef.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_coderef.t 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,61 @@ +#!perl -Tw + +package Foo; + +sub new { my $class = shift; return bless sub {}, $class; } + +package main; + +use warnings; +use strict; + +use Test::More tests => 7; + +use Carp::Assert::More; + +local $@; +$@ = ''; + +# {} is not a coderef +eval { + assert_coderef( {} ); +}; +like( $@, qr/Assertion.*failed/ ); + +# a ref to a hash with stuff in it is not a coderef +my $ref = { foo => 'foo', bar => 'bar' }; +eval { + assert_coderef( $ref ); +}; +like( $@, qr/Assertion.*failed/ ); + +# 3 is not a coderef +eval { + assert_coderef( 3 ); +}; +like( $@, qr/Assertion.*failed/ ); + +# [] is not a coderef +eval { + assert_coderef( [] ); +}; +like( $@, qr/Assertion.*failed/ ); + +# a ref to a list with stuff in it is not a coderef +my @ary = ('foo', 'bar', 'baaz'); +eval { + assert_coderef( \@ary ); +}; +like( $@, qr/Assertion.*failed/ ); + +# sub {} is a coderef +eval { + assert_coderef( sub {} ); +}; +is( $@, '' ); + +# Foo->new->isa("CODE") returns true, so do we +eval { + assert_coderef( Foo->new ); +}; +is( $@, '' ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_empty.t new/Carp-Assert-More-1.16/t/assert_empty.t --- old/Carp-Assert-More-1.14/t/assert_empty.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_empty.t 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,54 @@ +#!perl -Tw + +use warnings; +use strict; + +use Test::More tests => 12; +use Test::Exception; + +use Carp::Assert::More; + +use constant PASS => 1; +use constant FAIL => 0; + +my @cases = ( + [ 0 => FAIL ], + [ 'foo' => FAIL ], + [ undef => FAIL ], + [ {} => PASS ], + [ [] => PASS ], + [ {foo=>1} => FAIL ], + [ [1,2,3] => FAIL ], +); + +for my $case ( @cases ) { + my ($val,$expected_status) = @$case; + + eval { assert_empty( $val ) }; + $val = "undef" if !defined($val); + my $desc = "Checking \"$val\""; + + if ( $expected_status eq FAIL ) { + like( $@, qr/Assertion.+failed/, $desc ); + } else { + is( $@, "", $desc ); + } +} + +throws_ok( sub { assert_empty( 27 ) }, qr/Not an array or hash reference/ ); + +BLESSED_ARRAY: { + my $array_object = bless( [], 'WackyPackage' ); + lives_ok( sub { assert_empty( $array_object ) } ); + + push( @{$array_object}, 14 ); + throws_ok( sub { assert_empty( $array_object, 'Flooble' ) }, qr/\QAssertion (Flooble) failed!/ ); +} + +BLESSED_HASH: { + my $hash_object = bless( {}, 'WackyPackage' ); + lives_ok( sub { assert_empty( $hash_object ) } ); + + $hash_object->{foo} = 14; + throws_ok( sub { assert_empty( $hash_object, 'Flargle' ) }, qr/\QAssertion (Flargle) failed!/ ); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_exists.t new/Carp-Assert-More-1.16/t/assert_exists.t --- old/Carp-Assert-More-1.14/t/assert_exists.t 2012-10-31 17:29:03.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_exists.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,11 +3,9 @@ use warnings; use strict; -use Test::More tests=>8; +use Test::More tests => 7; -BEGIN { - use_ok( 'Carp::Assert::More' ); -} +use Carp::Assert::More; my %foo = ( name => 'Andy Lester', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_fail.t new/Carp-Assert-More-1.16/t/assert_fail.t --- old/Carp-Assert-More-1.14/t/assert_fail.t 2012-10-31 17:29:07.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_fail.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>2; +use Test::More tests => 1; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; eval { assert_fail( "Everything is broken!" ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_isa_in.t new/Carp-Assert-More-1.16/t/assert_isa_in.t --- old/Carp-Assert-More-1.14/t/assert_isa_in.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_isa_in.t 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,31 @@ +#!perl -Tw + +use warnings; +use strict; + +use Test::More tests => 12; +use Carp::Assert::More; + +use Test::Exception; + +my $rc = eval 'assert_isa_in(undef)'; +is( $rc, undef, 'Fails the eval' ); +like( $@, qr/Not enough arguments for Carp::Assert::More::assert_isa_in/, 'Prototype requires two arguments' ); + +dies_ok { assert_isa_in(undef, undef) } 'Dies with one undef argument'; +dies_ok { assert_isa_in(bless({}, 'x'), [] ) } 'No types passed in'; +dies_ok { assert_isa_in('z', []) } 'List of empty types does not allow you to pass non-objects'; + +lives_ok { assert_isa_in( bless({}, 'x'), [ 'x' ] ) } 'One out of one'; +dies_ok { assert_isa_in( bless({}, 'x'), [ 'y' ] ) } 'Zero out of one'; +lives_ok { assert_isa_in( bless({}, 'x'), [ 'y', 'x' ] ) } 'One out of two'; + +@y::ISA = ( 'x' ); +my $x = bless {}, 'y'; +isa_ok( $x, 'y', 'Verifying our assumptions' ); +lives_ok { assert_isa_in( bless({}, 'y'), [ 'y' ] ) } 'Matches child class'; +lives_ok { assert_isa_in( bless({}, 'y'), [ 'x' ] ) } 'Matches base class'; +dies_ok { assert_isa_in( bless({}, 'x'), [ 'y' ] ) } 'Parent does not match child'; + +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_negative.t new/Carp-Assert-More-1.16/t/assert_negative.t --- old/Carp-Assert-More-1.14/t/assert_negative.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_negative.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>7; +use Test::More tests => 6; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_negative_integer.t new/Carp-Assert-More-1.16/t/assert_negative_integer.t --- old/Carp-Assert-More-1.14/t/assert_negative_integer.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_negative_integer.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>8; +use Test::More tests => 7; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -33,3 +33,5 @@ } } +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_nonnegative.t new/Carp-Assert-More-1.16/t/assert_nonnegative.t --- old/Carp-Assert-More-1.14/t/assert_nonnegative.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_nonnegative.t 2016-07-06 20:10:36.000000000 +0200 @@ -1,11 +1,11 @@ -#!perl -Tw +#!perl -T use warnings; use strict; -use Test::More tests=>7; +use Test::More tests => 6; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -27,8 +27,8 @@ if ( $status eq FAIL ) { like( $@, qr/Assertion.+failed/, $desc ); - } else { - is( $@, "", $desc ); + } + else { + is( $@, '', $desc ); } } - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_nonnegative_integer.t new/Carp-Assert-More-1.16/t/assert_nonnegative_integer.t --- old/Carp-Assert-More-1.14/t/assert_nonnegative_integer.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_nonnegative_integer.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>7; +use Test::More tests => 6; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -32,3 +32,5 @@ } } +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_nonref.t new/Carp-Assert-More-1.16/t/assert_nonref.t --- old/Carp-Assert-More-1.14/t/assert_nonref.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_nonref.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests => 6; +use Test::More tests => 5; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; local $@; $@ = ''; @@ -41,3 +41,6 @@ assert_nonref( $ref ); }; like( $@, qr/Assertion.*failed/ ); + +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_nonzero.t new/Carp-Assert-More-1.16/t/assert_nonzero.t --- old/Carp-Assert-More-1.14/t/assert_nonzero.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_nonzero.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>7; +use Test::More tests => 6; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -32,3 +32,5 @@ } } +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_nonzero_integer.t new/Carp-Assert-More-1.16/t/assert_nonzero_integer.t --- old/Carp-Assert-More-1.14/t/assert_nonzero_integer.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_nonzero_integer.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>7; +use Test::More tests => 6; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -31,4 +31,3 @@ is( $@, "", $desc ); } } - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_numeric.t new/Carp-Assert-More-1.16/t/assert_numeric.t --- old/Carp-Assert-More-1.14/t/assert_numeric.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_numeric.t 2017-08-04 21:18:59.000000000 +0200 @@ -0,0 +1,57 @@ +#!perl -Tw + +use warnings; +use strict; + +use Test::More tests => 21; + +use Carp::Assert::More; + +use Test::Exception; + +my @good = ( + 1, + 2112, + '2112', + 3.1415926, + -5150, + '-0.12', + '0.12', + 2.112E+03, + 2.112E3, + 2.112e3, + 2.112e0, + 2.112e-1, +); +my @bad = ( + undef, + 'zero', + '', + [], + {}, + \99, + \*STDIN, + '3-5', + 3.5.4 +); + +for my $good ( @good ) { + lives_ok( + sub { assert_numeric( $good, "$good is good" ) }, + "$good passes assertion" + ); +} + +for my $bad ( @bad ) { + my $disp = $bad; + $disp = '<undef>' unless defined $disp; + throws_ok( + sub { assert_numeric( $bad, "$disp is bad" ) }, + qr/\Q$disp is bad/, + "$disp fails assertion" + ); +} + + +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_positive.t new/Carp-Assert-More-1.16/t/assert_positive.t --- old/Carp-Assert-More-1.14/t/assert_positive.t 2012-10-31 17:28:33.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/assert_positive.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>7; +use Test::More tests => 6; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -33,3 +33,5 @@ } } +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/assert_positive_integer.t new/Carp-Assert-More-1.16/t/assert_positive_integer.t --- old/Carp-Assert-More-1.14/t/assert_positive_integer.t 2005-10-14 19:02:35.000000000 +0200 +++ new/Carp-Assert-More-1.16/t/assert_positive_integer.t 2017-08-04 21:18:59.000000000 +0200 @@ -3,9 +3,9 @@ use warnings; use strict; -use Test::More tests=>8; +use Test::More tests => 7; -BEGIN { use_ok( 'Carp::Assert::More' ); } +use Carp::Assert::More; use constant PASS => 1; use constant FAIL => 2; @@ -33,3 +33,5 @@ } } +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Carp-Assert-More-1.14/t/test-coverage.t new/Carp-Assert-More-1.16/t/test-coverage.t --- old/Carp-Assert-More-1.14/t/test-coverage.t 2012-10-31 16:52:33.000000000 +0100 +++ new/Carp-Assert-More-1.16/t/test-coverage.t 2017-08-04 21:18:59.000000000 +0200 @@ -1,6 +1,6 @@ #!perl -Tw -use Test::More tests => 26; +use Test::More tests => 32; use Carp::Assert::More; ++++++ cpanspec.yml ++++++ --- #description_paragraphs: 3 #description: |- # override description from CPAN #summary: override summary from CPAN #no_testing: broken upstream #sources: # - source1 # - source2 #patches: # foo.patch: -p1 # bar.patch: #preamble: |- # BuildRequires: gcc-c++ #post_prep: |- # hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s, *,,g'` # sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL #post_build: |- # rm unused.files #post_install: |- # sed on %{name}.files #license: SUSE-NonFree #skip_noarch: 1 #custom_build: |- #./Build build flags=%{?_smp_mflags} --myflag #custom_test: |- #startserver && make test #ignore_requires: Bizarre::Module
participants (1)
-
root@hilbert.suse.de