Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

petdance (2468)

AOL IM: petdance (Add Buddy, Send Message)
Yahoo! ID: petdance (Add User, Send Message)

I'm Andy Lester, and I like to test stuff. I also write for the Perl Journal, and do tech edits on books. Sometimes I write code, too.

Journal of petdance (2468)

Friday August 09, 2002
08:17 PM

My latest project, Carp::Assert::More

[ #7016 ]
My latest little project of necessity is Carp::Assert::More.

I've become so spoiled by the swell convenience functions of Test::More that I missed them when I was throwing assertions in code. So, I started a module of 'em.

Down the road, Schwern has asked me to see if I can incorporate them and the rest of Carp::Assert into using Test::Builder, since they're so similar. My first thought is not a good one: Since Test::Builder uses a singleton, I'm not sure that a piece of code that both Carp::Assert and Test::More could co-exist in a single piece of code.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Unless I'm tremendously misunderstanding your point, the Test::Builder singleton exists to make that possible. That's why we wrote it that way. As long as you can translate things into calls to Test::Builder::ok() somehow, it ought to work.

    • Here's an example: I've got a module Foo that asserts regularly. Now, I go and run some tests against Foo's functions, including those that assert.

      package Foo;

      sub wango {
        my $self = shift;
        assert_isa( $self, 'Foo' );
        # Now do my object magic

      but then, I also want to test that, so in my .t file:

      my $foo = new Foo;
      isa( $foo, 'Foo' );
      my $n = $foo->wango;
      ok( $n, 'wango returned non-zero' );

      In this case, the singleton would be used by (in order) isa, assert_isa and ok. Test::Builder's



      • Oh, I think I understand. Writing tests for a module that uses Test::Builder can be tricky, yes. That's why there's Test::Builder::Tester [].

        • Writing tests for a module that uses Test::Builder can be tricky, yes.

          If we made Carp::Assert use Test::Builder, then EVERY module that uses Carp::Assert (which I hope would be many) would suddenly become one of those tricky modules and people would have to use T::B::T. :-(