schwern / carp-assert Goto Github PK
View Code? Open in Web Editor NEWEmbedded sanity checks for Perl
Home Page: http://search.cpan.org/dist/Carp-Assert
Embedded sanity checks for Perl
Home Page: http://search.cpan.org/dist/Carp-Assert
NAME Carp::Assert - executable comments SYNOPSIS # Assertions are on. use Carp::Assert; $next_sunrise_time = sunrise(); # Assert that the sun must rise in the next 24 hours. assert(($next_sunrise_time - time) < 24*60*60) if DEBUG; # Assertions are off. no Carp::Assert; $next_pres = divine_next_president(); # Assert that if you predict Dan Quayle will be the next president # your crystal ball might need some polishing. However, since # assertions are off, IT COULD HAPPEN! shouldnt($next_pres, 'Dan Quayle') if DEBUG; DESCRIPTION "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 probably skip this and go straight to the FUNCTIONS section. Assertions are the explict 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 garbage in, error out) and to tell you when you've produced garbage output. (If I was going to be a cynic about Perl and the user nature, I'd say there are no user inputs but garbage, and Perl produces nothing but...) An assertion is used to prevent the impossible from being asked of your code, or at least tell you when it does. For example: # Take the square root of a number. sub my_sqrt { my($num) = shift; # the square root of a negative number is imaginary. assert($num >= 0); return sqrt $num; } The assertion will warn you if a negative number was handed to your subroutine, a reality the routine has no intention of dealing with. AUTHOR Michael G Schwern <[email protected]> WHAT IS THIS? This is Carp::Assert, a perl module. Please see the README that comes with this distribution. HOW DO I INSTALL IT? To install this module, cd to the directory that contains this README file and type the following: perl Makefile.PL make test make install To install this module into a specific directory, do: perl Makefile.PL PREFIX=/name/of/the/directory ...the rest is the same... Please also read the perlmodinstall man page, if available. WHAT MODULES DO I NEED? Carp
Getting the below warning importing Carp::Assert
via Pithub:
/usr/bin/perlbrew \
exec -q \
--with blead \
/home/regular/perl5/perlbrew/perls/blead/bin/perl5.37.9 \
/home/regular/bin/pithub
Old package separator "'" deprecated at
/home/regular/perl5/perlbrew/perls/blead/lib/site_perl/5.37.9/Carp/Assert.pm
line 396.
Maybe it's time to start removing '
from shouldn't
function in line 396:
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]);
}
}
Carp-Assert/lib/Carp/Assert.pm
Line 396 in af33480
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.