Changeset 1517

Show
Ignore:
Timestamp:
02/21/05 15:25:00
Author:
miyagawa
Message:

Added more tests to 100% coverage.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Class-Trigger/trunk/Changes

    r856 r1517  
    11Revision history for Perl extension Class::Trigger. 
     2 
     30.09  Fri Feb 18 14:13:22 JST 2005 
     4        - Devel::Cover compliant code. Now 100% coverage. 
     5          (Thanks to Leif Eriksen and Phalanx folks) 
    26 
    370.08  Thu Feb 27 15:51:31 JST 2003 
  • Class-Trigger/trunk/MANIFEST

    r856 r1517  
    1010t/04_object.t 
    1111t/05_args.t 
     12t/06_coverage.t 
    1213t/lib/Foo.pm 
    1314t/lib/Foo/Bar.pm 
  • Class-Trigger/trunk/lib/Class/Trigger.pm

    r856 r1517  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.08
     5$VERSION = 0.09
    66 
    77use Class::Data::Inheritable; 
     
    4545sub call_trigger { 
    4646    my $self = shift; 
    47     my $all_triggers = __fetch_triggers($self) || return; # any triggers? 
     47    return unless my $all_triggers = __fetch_triggers($self); # any triggers? 
    4848    my $when = shift; 
    4949    if (my $triggers = $all_triggers->{$when}) { 
     
    6161 
    6262sub __validate_triggerpoint { 
    63     my $points = $_[0]->__triggerpoints || return
     63    return unless my $points = $_[0]->__triggerpoints
    6464    my ($self, $when) = @_; 
    65     Carp::croak("$when is not valid triggerpoint for ".(ref($self) || $self)) 
     65    Carp::croak("$when is not valid triggerpoint for ".(ref($self) ? ref($self) : $self)) 
    6666        unless $points->{$when}; 
    6767} 
  • Class-Trigger/trunk/t/01_trigger.t

    r625 r1517  
    11use strict; 
    2 use Test::More tests => 7
     2use Test::More qw(no_plan)
    33 
    44use IO::Scalar; 
     
    3939} 
    4040 
     41# coverage tests 
     42 
     43{ 
     44    # pass a non-code ref and catch the carp 
     45 
     46    my @die; 
     47 
     48    eval { 
     49        local $SIG{__DIE__} = sub {push @die, @_}; 
     50 
     51        Foo->add_trigger(wrong_type => []); 
     52    }; 
     53 
     54    like(pop(@die), qr(add_trigger[(][)] needs coderef at ), 'check for right callback param'); 
     55}