Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package perl-Carp-Assert-More for 
openSUSE:Factory checked in at 2024-04-07 22:11:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Carp-Assert-More (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Carp-Assert-More.new.1905 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Carp-Assert-More"

Sun Apr  7 22:11:22 2024 rev:16 rq:1165828 version:2.4.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/perl-Carp-Assert-More/perl-Carp-Assert-More.changes  
    2023-06-03 00:07:21.734038014 +0200
+++ 
/work/SRC/openSUSE:Factory/.perl-Carp-Assert-More.new.1905/perl-Carp-Assert-More.changes
    2024-04-07 22:13:37.863357346 +0200
@@ -1,0 +2,16 @@
+Wed Mar  6 03:06:27 UTC 2024 - Tina Müller <[email protected]>
+
+- updated to 2.4.0
+   see /usr/share/doc/packages/perl-Carp-Assert-More/Changes
+
+  2.4.0   Mon Mar  4 21:54:07 CST 2024
+          [ENHANCEMENTS]
+          New function assert_arrayref_all() calls an assertion function for 
every element in the array.
+              my $aref_of_counts = get_counts();
+              assert_arrayref_all( $aref, \&assert_positive_integer, 'Counts 
are positive' );
+          assert_context_scalar() now provides a default message of
+          "function_name must be called in scalar context".
+          assert_context_nonvoid() now provide a default message of
+          "function_name must not be called in void context".
+
+-------------------------------------------------------------------

Old:
----
  Carp-Assert-More-2.3.0.tar.gz

New:
----
  Carp-Assert-More-2.4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Carp-Assert-More.spec ++++++
--- /var/tmp/diff_new_pack.0GqlN2/_old  2024-04-07 22:13:38.299373336 +0200
+++ /var/tmp/diff_new_pack.0GqlN2/_new  2024-04-07 22:13:38.299373336 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-Carp-Assert-More
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %define cpan_name Carp-Assert-More
 Name:           perl-Carp-Assert-More
-Version:        2.3.0
+Version:        2.4.0
 Release:        0
 License:        Artistic-2.0
 Summary:        Convenience assertions for common situations

++++++ Carp-Assert-More-2.3.0.tar.gz -> Carp-Assert-More-2.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/Changes 
new/Carp-Assert-More-2.4.0/Changes
--- old/Carp-Assert-More-2.3.0/Changes  2023-05-31 04:53:56.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/Changes  2024-03-05 04:55:22.000000000 +0100
@@ -1,6 +1,20 @@
 Revision history for Perl extension Carp::Assert::More.
 
 
+2.4.0   Mon Mar  4 21:54:07 CST 2024
+        [ENHANCEMENTS]
+        New function assert_arrayref_all() calls an assertion function for 
every element in the array.
+
+            my $aref_of_counts = get_counts();
+            assert_arrayref_all( $aref, \&assert_positive_integer, 'Counts are 
positive' );
+
+        assert_context_scalar() now provides a default message of
+        "function_name must be called in scalar context".
+
+        assert_context_nonvoid() now provide a default message of
+        "function_name must not be called in void context".
+
+
 2.3.0   Tue May 30 21:52:20 CDT 2023
         [ENHANCEMENTS]
         Added assert_arrayref_of() to verify that all of the elements
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/MANIFEST 
new/Carp-Assert-More-2.4.0/MANIFEST
--- old/Carp-Assert-More-2.3.0/MANIFEST 2023-05-31 05:00:40.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/MANIFEST 2024-03-05 04:55:56.000000000 +0100
@@ -9,6 +9,7 @@
 t/assert_all_keys_in.t
 t/assert_aoh.t
 t/assert_arrayref.t
+t/assert_arrayref_all.t
 t/assert_arrayref_nonempty.t
 t/assert_arrayref_of.t
 t/assert_cmp.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/META.json 
new/Carp-Assert-More-2.4.0/META.json
--- old/Carp-Assert-More-2.3.0/META.json        2023-05-31 05:00:39.000000000 
+0200
+++ new/Carp-Assert-More-2.4.0/META.json        2024-03-05 04:55:56.000000000 
+0100
@@ -50,6 +50,6 @@
          "https://opensource.org/licenses/artistic-license-2.0.php";
       ]
    },
-   "version" : "v2.3.0",
+   "version" : "v2.4.0",
    "x_serialization_backend" : "JSON::PP version 2.27400"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/META.yml 
new/Carp-Assert-More-2.4.0/META.yml
--- old/Carp-Assert-More-2.3.0/META.yml 2023-05-31 05:00:39.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/META.yml 2024-03-05 04:55:56.000000000 +0100
@@ -27,5 +27,5 @@
   bugtracker: https://github.com/petdance/carp-assert-more/issues
   homepage: https://github.com/petdance/carp-assert-more
   license: https://opensource.org/licenses/artistic-license-2.0.php
-version: v2.3.0
+version: v2.4.0
 x_serialization_backend: 'CPAN::Meta::YAML version 0.012'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/More.pm 
new/Carp-Assert-More-2.4.0/More.pm
--- old/Carp-Assert-More-2.3.0/More.pm  2023-05-31 04:59:45.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/More.pm  2024-03-05 04:55:22.000000000 +0100
@@ -15,12 +15,12 @@
 
 =head1 VERSION
 
-Version 2.3.0
+Version 2.4.0
 
 =cut
 
 BEGIN {
-    $VERSION = '2.3.0';
+    $VERSION = '2.4.0';
     @ISA = qw(Exporter);
     @EXPORT = qw(
         assert_all_keys_in
@@ -28,6 +28,7 @@
         assert_arrayref
         assert_arrayref_nonempty
         assert_arrayref_of
+        assert_arrayref_all
         assert_cmp
         assert_coderef
         assert_context_nonvoid
@@ -911,6 +912,57 @@
 }
 
 
+=head2 assert_arrayref_all( $aref, $sub [, $name] )
+
+Asserts that I<$aref> is reference to an array that has at least one
+element in it. Each element of the array is passed to subroutine I<$sub>
+which is assumed to be an assertion.
+
+For example:
+
+    my $aref_of_counts = get_counts();
+    assert_arrayref_all( $aref, \&assert_positive_integer, 'Counts are 
positive' );
+
+Whatever is passed as I<$name>, a string saying "Element #N" will be
+appended, where N is the zero-based index of the array.
+
+=cut
+
+sub assert_arrayref_all($$;$) {
+    my $aref = shift;
+    my $sub  = shift;
+    my $name = shift;
+
+    my @why;
+
+    assert_coderef( $sub, 'assert_arrayref_all requires a code reference' );
+
+    if ( ref($aref) eq 'ARRAY' || (Scalar::Util::blessed( $aref ) && 
$aref->isa( 'ARRAY' )) ) {
+        if ( @{$aref} ) {
+            my $inner_msg = defined($name) ? "$name: " : 'assert_arrayref_all: 
';
+            my $n = 0;
+            for my $i ( @{$aref} ) {
+                $sub->( $i, "${inner_msg}Element #$n" );
+                ++$n;
+            }
+        }
+        else {
+            push @why, 'Array contains no elements';
+        }
+    }
+    else {
+        push @why, 'First argument to assert_arrayref_all was not an array';
+    }
+
+    if ( @why ) {
+        require Carp;
+        &Carp::confess( _failure_msg($name), @why );
+    }
+
+    return;
+}
+
+
 =head2 assert_aoh( $ref [, $name ] )
 
 Verifies that C<$array> is an arrayref, and that every element is a hashref.
@@ -1261,14 +1313,17 @@
 
     something();
 
+If the C<$name> argument is not passed, a default message of "<funcname>
+must not be called in void context" is provided.
+
 =cut
 
 sub assert_context_nonvoid(;$) {
-    my $name = shift;
+    my @caller = caller(1);
 
-    my $wantarray = (caller(1))[5];
+    return if defined($caller[5]);
 
-    return if defined($wantarray);
+    my $name = shift // "$caller[3] must not be called in void context";
 
     require Carp;
     &Carp::confess( _failure_msg($name) );
@@ -1300,15 +1355,19 @@
     something();
     my @things = something();
 
+If the C<$name> argument is not passed, a default message of "<funcname>
+must be called in scalar context" is provided.
+
 =cut
 
 sub assert_context_scalar(;$) {
-    my $name = shift;
-
-    my $wantarray = (caller(1))[5];
+    my @caller = caller(1);
+    my $wantarray = $caller[5];
 
     return if defined($wantarray) && !$wantarray;
 
+    my $name = shift // "$caller[3] must be called in scalar context";
+
     require Carp;
     &Carp::confess( _failure_msg($name) );
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/t/assert_arrayref_all.t 
new/Carp-Assert-More-2.4.0/t/assert_arrayref_all.t
--- old/Carp-Assert-More-2.3.0/t/assert_arrayref_all.t  1970-01-01 
01:00:00.000000000 +0100
+++ new/Carp-Assert-More-2.4.0/t/assert_arrayref_all.t  2024-03-05 
04:55:22.000000000 +0100
@@ -0,0 +1,65 @@
+#!perl -Tw
+
+use warnings;
+use strict;
+
+use Test::More tests => 10;
+
+use Carp::Assert::More;
+
+use Test::Exception;
+
+my $FAILED = qr/Assertion failed/;
+
+my $api = \&assert_positive_integer;
+
+MAIN: {
+    # {} is not an arrayref.
+    throws_ok( sub { assert_arrayref_all( {}, $api ) }, $FAILED );
+
+    # A ref to a hash with stuff in it is not an arrayref.
+    my $ref = { foo => 'foo', bar => 'bar' };
+    throws_ok( sub { assert_arrayref_all( $ref, $api ) }, $FAILED );
+
+    # 3 is not an arrayref.
+    throws_ok( sub { assert_arrayref_all( 3, $api ) }, $FAILED );
+
+    # [] is a nonempty arrayref.
+    lives_ok( sub { assert_arrayref_all( [ 3 ], $api ) } );
+
+    # [] is an empty arrayref.
+    throws_ok( sub { assert_arrayref_all( [], $api ) }, $FAILED );
+
+    my @empty_ary = ();
+    throws_ok( sub { assert_arrayref_all( \@empty_ary, $api ) }, qr/Array 
contains no elements/ );
+
+    # A coderef is not an arrayref.
+    my $coderef = sub {};
+    throws_ok( sub { assert_arrayref_all( $coderef, $api ) }, $FAILED );
+
+    # An arrayref is not a coderef.
+    throws_ok( sub { assert_arrayref_all( \@empty_ary, [] ) }, 
qr/assert_arrayref_all requires a code reference/ );
+}
+
+
+MASS_ASSERTIONS: {
+    my @things = ( 1, 2, 4.3 );
+
+    throws_ok(
+        sub { assert_arrayref_all( \@things, $api ) },
+        qr/assert_arrayref_all: Element #2/,
+        'Automatic name comes back OK'
+    );
+
+    throws_ok(
+        sub { assert_arrayref_all( \@things, $api, 'All gotta be posint' ) },
+        qr/All gotta be posint: Element #2/,
+        'Automatic name comes back OK'
+    );
+
+    @things = 1..400;
+    assert_arrayref_all( \@things, $api, 'Must all be positive integer' );
+}
+
+
+exit 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/t/assert_context_nonvoid.t 
new/Carp-Assert-More-2.4.0/t/assert_context_nonvoid.t
--- old/Carp-Assert-More-2.3.0/t/assert_context_nonvoid.t       2021-08-13 
18:43:34.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/t/assert_context_nonvoid.t       2024-03-05 
04:55:22.000000000 +0100
@@ -4,12 +4,12 @@
 use strict;
 use 5.010;
 
-use Test::More tests => 3;
+use Test::More tests => 7;
 
 use Carp::Assert::More;
 
 sub important_function {
-    assert_context_nonvoid( 'important_function must not be called in void 
context' );
+    assert_context_nonvoid( 'void is bad' );
 
     return 2112;
 }
@@ -36,7 +36,62 @@
 eval {
     important_function();
 };
-like( $@, qr/\QAssertion (important_function must not be called in void 
context) failed!/ );
+like( $@, qr/\QAssertion (void is bad) failed!/ );
 
 
+# Now we test the assertions with the default message that the function 
provides.
+sub crucial_function {
+    assert_context_nonvoid();
+
+    return 2112;
+}
+
+
+# Keep the value returned.
+eval {
+    my $x = crucial_function();
+};
+is( $@, '' );
+
+
+# Keep the value in an array.
+eval {
+    my @x = crucial_function();
+};
+is( $@, '' );
+
+
+# Ignore the value returned.
+eval {
+    crucial_function();
+};
+like( $@, qr/\QAssertion (main::crucial_function must not be called in void 
context) failed!/ );
+
+
+# Test the default function name through multiple levels in different packages.
+
+package Bingo::Bongo;
+
+use Carp::Assert::More;
+
+sub vital_function {
+    assert_context_nonvoid();
+}
+
+
+package Wango;
+
+sub uninteresting_function {
+    Bingo::Bongo::vital_function();
+}
+
+
+package main;
+
+# Ignore the value returned.
+eval {
+    Wango::uninteresting_function();
+};
+like( $@, qr/\QAssertion (Bingo::Bongo::vital_function must not be called in 
void context) failed!/ );
+
 exit 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/t/assert_context_scalar.t 
new/Carp-Assert-More-2.4.0/t/assert_context_scalar.t
--- old/Carp-Assert-More-2.3.0/t/assert_context_scalar.t        2021-08-13 
18:43:34.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/t/assert_context_scalar.t        2024-03-05 
04:55:22.000000000 +0100
@@ -4,12 +4,15 @@
 use strict;
 use 5.010;
 
-use Test::More tests => 3;
+use Test::More tests => 7;
 
 use Carp::Assert::More;
 
+
+# First we test the assertions with an explicit message passed.
+
 sub important_function {
-    assert_context_scalar( 'important_function must be called in scalar 
context' );
+    assert_context_scalar( 'non-scalar context is bad' );
 
     return 2112;
 }
@@ -29,14 +32,72 @@
 eval {
     important_function();
 };
-like( $@, qr/\QAssertion (important_function must be called in scalar context) 
failed!/ );
+like( $@, qr/\QAssertion (non-scalar context is bad) failed!/ );
 
 
 # Call in list context.
 eval {
     my @x = important_function();
 };
-like( $@, qr/\QAssertion (important_function must be called in scalar context) 
failed!/ );
+like( $@, qr/\QAssertion (non-scalar context is bad) failed!/ );
+
+
+# Now we test the assertions with the default message that the function 
provides.
+sub crucial_function {
+    assert_context_scalar();
+
+    return 2112;
+}
+
+
+local $@;
+$@ = '';
+
+# Keep the value returned.
+eval {
+    my $x = crucial_function();
+};
+is( $@, '' );
+
+
+# Ignore the value returned.
+eval {
+    crucial_function();
+};
+like( $@, qr/\QAssertion (main::crucial_function must be called in scalar 
context) failed!/ );
 
 
+# Call in list context.
+eval {
+    my @x = crucial_function();
+};
+like( $@, qr/\QAssertion (main::crucial_function must be called in scalar 
context) failed!/ );
+
+
+# Test the default function name through multiple levels in different packages.
+
+package Bingo::Bongo;
+
+use Carp::Assert::More;
+
+sub vital_function {
+    assert_context_scalar();
+}
+
+
+package Wango;
+
+sub uninteresting_function {
+    Bingo::Bongo::vital_function();
+}
+
+
+package main;
+
+# Ignore the value returned.
+eval {
+    Wango::uninteresting_function();
+};
+like( $@, qr/\QAssertion (Bingo::Bongo::vital_function must be called in 
scalar context) failed!/ );
+
 exit 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Carp-Assert-More-2.3.0/t/test-coverage.t 
new/Carp-Assert-More-2.4.0/t/test-coverage.t
--- old/Carp-Assert-More-2.3.0/t/test-coverage.t        2023-05-31 
04:45:31.000000000 +0200
+++ new/Carp-Assert-More-2.4.0/t/test-coverage.t        2024-03-05 
04:55:22.000000000 +0100
@@ -1,6 +1,6 @@
 #!perl -Tw
 
-use Test::More tests => 41;
+use Test::More tests => 42;
 
 use Carp::Assert::More;
 

Reply via email to