From 6bd1e1ef4003a17d07db212cbb49a833abeb3c78 Mon Sep 17 00:00:00 2001 From: Michael Herger Date: Thu, 9 Jan 2025 17:53:10 +0100 Subject: [PATCH] Fix #1288 Update `Carp::Assert` to latest v0.22 Signed-off-by: Michael Herger --- CPAN/Carp/Assert.pm | 89 ++++++++++++++++++++++++++++++--------------- Changelog9.html | 1 + 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/CPAN/Carp/Assert.pm b/CPAN/Carp/Assert.pm index 2bf447c19fd..145704e7285 100644 --- a/CPAN/Carp/Assert.pm +++ b/CPAN/Carp/Assert.pm @@ -1,14 +1,14 @@ package Carp::Assert; -require 5.004; - +require 5.006; use strict qw(subs vars); +use warnings; use Exporter; use vars qw(@ISA $VERSION %EXPORT_TAGS); BEGIN { - $VERSION = '0.18'; + $VERSION = '0.22'; @ISA = qw(Exporter); @@ -111,19 +111,30 @@ Carp::Assert - executable comments =head1 DESCRIPTION -=for testing -use Carp::Assert; +=begin testing +BEGIN { + local %ENV = %ENV; + delete @ENV{qw(PERL_NDEBUG NDEBUG)}; + require Carp::Assert; + Carp::Assert->import; +} - "We are ready for any unforseen event that may or may not +local %ENV = %ENV; +delete @ENV{qw(PERL_NDEBUG NDEBUG)}; + +=end testing + + "We are ready for any unforseen event that may or may not occur." - Dan Quayle Carp::Assert is intended for a purpose like the ANSI C library -assert.h. If you're already familiar with assert.h, then you can +L. +If you're already familiar with assert.h, then you can probably skip this and go straight to the FUNCTIONS section. -Assertions are the explict expressions of your assumptions about the +Assertions are the explicit expressions of your assumptions about the reality your program is expected to deal with, and a declaration of those which it is not. They are used to prevent your program from blissfully processing garbage inputs (garbage in, garbage out becomes @@ -321,7 +332,7 @@ sub affirm (&;$) { require B::Deparse; $name = B::Deparse->new->coderef2text($_[0]); }; - $name = + $name = 'code display non-functional on this version of Perl, sorry' if $@; } @@ -381,18 +392,6 @@ sub shouldnt ($$) { return undef; } -# Sorry, I couldn't resist. -sub shouldn't ($$) { # emacs cperl-mode madness #' sub { - my $env_ndebug = exists $ENV{PERL_NDEBUG} ? $ENV{PERL_NDEBUG} - : $ENV{'NDEBUG'}; - if( $env_ndebug ) { - return undef; - } - else { - shouldnt($_[0], $_[1]); - } -} - =back =head1 Debugging vs Production @@ -437,7 +436,7 @@ evaluated. =head1 Differences from ANSI C -assert() is intended to act like the function from ANSI C fame. +assert() is intended to act like the function from ANSI C fame. Unfortunately, due to Perl's lack of macros or strong inlining, it's not nearly as unobtrusive. @@ -468,7 +467,7 @@ subroutine (even if that subroutine does nothing). Forgetting the C on an C is not so bad. While you still have the overhead of calling a subroutine (one that does nothing) it will B evaluate its code block and that can save -alot. +a lot. Try to remember the B. @@ -494,26 +493,56 @@ working on at the same time. =head1 BUGS, CAVETS and other MUSINGS -Someday, Perl will have an inline pragma, and the C -bletcherousness will go away. +=head2 Conflicts with C + +The C module exports an C routine which will conflict with C if both are used in the same namespace. If you are using both together, prevent C from exporting like so: + + use POSIX (); + use Carp::Assert; + +Since C exports way too much, you should be using it like that anyway. + +=head2 C and C<$^S> affirm() mucks with the expression's caller and it is run in an eval so anything that checks $^S will be wrong. -Yes, there is a C routine. It mostly works, but you B -put the C after it. +=head2 missing C It would be nice if we could warn about missing C. +=head1 SEE ALSO + +L - the wikipedia +page about C. + +L provides a set of convenience functions +that are wrappers around C. + +L provides support for subroutine pre- and post-conditions. +The documentation says it's slow. + +L provides compile-time assertions, which are usually +optimised away at compile time. Currently part of the L +distribution, but may get its own distribution sometime in 2014. + +L also provides an C function, for Perl >= 5.8.1. + +L provides an assertion mechanism for Perl >= 5.9.0. + +=head1 REPOSITORY + +L + =head1 COPYRIGHT -Copyright 2002 by Michael G Schwern Eschwern@pobox.comE. +Copyright 2001-2007 by Michael G Schwern Eschwern@pobox.comE. -This program is free software; you can redistribute it and/or +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -See F +See F =head1 AUTHOR diff --git a/Changelog9.html b/Changelog9.html index 32bb8fe5c85..a8a5f75facf 100644 --- a/Changelog9.html +++ b/Changelog9.html @@ -20,6 +20,7 @@

Version 9.0.2

  • Bug Fixes:
    • +
    • #1288 - Update Carp::Assert to latest to fix compatibility with recent Perl versions.