Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make carp_once register messages not just callsite

Add a test as well in t/106dbic_carp.t .
  • Loading branch information...
commit 8fda97d562ef6a2fe8894078da7e2c96009279b5 1 parent 0d6c550
@rkitover rkitover authored ribasushi committed
Showing with 32 additions and 3 deletions.
  1. +2 −0  Changes
  2. +3 −3 lib/DBIx/Class/Carp.pm
  3. +27 −0 t/106dbic_carp.t
View
2  Changes
@@ -53,6 +53,8 @@ Revision history for DBIx::Class
- Cleanup of complex resultset update/delete oprations - storage
specific code moved back to ResultSet and replaced by checks
of storage capabilities
+ - Fixed carp_once only emitting one single warning per package
+ regardless of warning content
0.08196 2011-11-29 05:35 (UTC)
* Fixes
View
6 lib/DBIx/Class/Carp.pm
@@ -81,10 +81,10 @@ sub import {
);
};
- my $fired;
+ my $fired = {};
*{"${into}::carp_once"} = sub {
- return if $fired;
- $fired = 1;
+ return if $fired->{$_[0]};
+ $fired->{$_[0]} = 1;
$warn->(
__find_caller($skip_pattern, $into),
View
27 t/106dbic_carp.t
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Warn;
+use DBIx::Class::Carp;
+use lib 't/lib';
+use DBICTest;
+
+warnings_exist {
+ DBIx::Class::frobnicate();
+} [
+ qr/carp1/,
+ qr/carp2/,
+], 'expected warnings from carp_once';
+
+done_testing;
+
+sub DBIx::Class::frobnicate {
+ DBIx::Class::branch1();
+ DBIx::Class::branch2();
+}
+
+sub DBIx::Class::branch1 { carp_once 'carp1' }
+sub DBIx::Class::branch2 { carp_once 'carp2' }
Please sign in to comment.
Something went wrong with that request. Please try again.