Code Monkey home page Code Monkey logo

carp-assert-more's People

Contributors

petdance avatar stigtsp avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

carp-assert-more's Issues

Create assert_all_in

assert_all_in( \@domains, [ 'A', 'B' ], 'all domains are valid' );

So for assert_all_in( $x, $y, $msg ), each value in $x is one of the values in $y.

assert_all_keys_in and assert_keys_are shouldn't stop at the first error

Consider

my $monolith = { h => 9, w => 4, d => 1 };
assert_keys_are( $monolith, [( h x q )] );

The output of the failed assertion should say both that d and w are not represented in the key list, and that both x and q not in the hash.

For this case:

   assert_all_keys_in( $monolith, [( h x q )] );

it should saw that both x and q are not in the hash.

In both cases, they stop at the first failure. All should be listed.

Flatten out the stack

The current implementation is optimized for the author of Carp::Assert::More, not the users who have to deal with the stacks of assertion calls.

Assertion (Could not find a row of test data) failed!
 at /var/perl5.20.3/lib/site_perl/5.20.3/Carp/Assert/More.pm line 199.
	Carp::Assert::More::assert_defined(undef, "Could not find a row of test data") called at /var/perl5.20.3/lib/site_perl/5.20.3/Carp/Assert/More.pm line 454
	Carp::Assert::More::assert_isa(undef, "HASH", "Could not find a row of test data") called at /var/perl5.20.3/lib/site_perl/5.20.3/Carp/Assert/More.pm line 622
	Carp::Assert::More::assert_hashref(undef, "Could not find a row of test data") called at test.t line 141

That should just be a single call to assert_hashref. It will be some replicated code, but that's OK. It will also speed things up.

Bring in _fail_msg

Carp::Assert::More uses Carp::Assert::_fail_msg(), tempting fate if the underlying Carp::Assert changes. Bring it into Carp::Assert::More.

Make further speedups

v2.0.0 is much faster than the 1.x series. See what other improvements we can eke out.

Create assert_keys_are

Sometimes you want exactly a set number of keys, and no others, like

assert_keys_are( $image_spec, [qw( height width )] );

Typo in assert_integer docs

The POD for assert_integer has a wrong example. -14 should pass, not FAIL.

=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.' );  # FAIL

=cut

Remove Carp::Assert entirely

Remove Carp::Assert as a requirement. Add our own assert so that the user doesn't have to use Carp::Assert if they just want a simple assert.

Restore compatibility with Perl 5.8

In the most recent release of this module you
added a small change to the code which requires Perl 5.10+ (the
defined or operator). Here's the line as on Metacpan:

https://metacpan.org/source/PETDANCE/Carp-Assert-More-1.20/More.pm#L695

I know the Perl community needs to learn to love newer Perl but I
would like to ask if you would reconsider this change and use a
slightly longer version of this line which could eliminate the defined
or op and restore compatibility with Perl 5.8. I only ask because
Catalyst is very committed to supporting our legacy users, many of
which are at companies where upgrading Perl is not going to happen.
Since the change I'm asking for is trivial and I see nothing else in
the code that is greatly benefiting from Perl 5.10+ I would hope this
is something you could consider. Our only alternative would be to
scour Catalyst and a number of its more important plugins (such as the
Authentication plugin which nearly everyone uses) to remove
Carp::Assert::More and work around as best we can. It's already been
a lot of hours of volunteer time compared to what I hope would be just
a few minutes of your effort.

All I think we need to do is change:

(line => https://metacpan.org/source/PETDANCE/Carp-Assert-More-1.20/More.pm#L695)

my $desc     = shift // 'Must be a DateTime object';
my $desc = defined($_[0]) ? shift(@_) : 'Must be a DateTime object';

change to

I'll also send a PR against master with the change. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.