Skip to content

Commit

Permalink
100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed Feb 5, 2010
1 parent ec86418 commit 427b9f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Object/Quick.pm
Expand Up @@ -287,12 +287,13 @@ sub import {
my $class = shift;
return $class->$PARAM( 'import', @_ ) if ref( $class );

my %args = map { $_ => 1 } grep { $_ && m/^-/ } @_;
my %args = map { $_ => 1 } grep { m/^-/ } @_;

my @names = grep { $_ ? m/^-/ ? undef : $_ : undef } @_[0 .. 2];
my @default = qw/obj method clear/;
if ( $args{ -obj } || $args{ -all }) {
$names[$_] ||= $default[$_] for 0 .. 2;
$names[0] ||= 'obj';
$names[1] ||= 'method';
$names[2] ||= 'clear';
}

my %subs;
Expand Down
19 changes: 19 additions & 0 deletions t/40-Quick-Import.t
Expand Up @@ -3,6 +3,7 @@ use strict;
use warnings;

use Test::More;
use Test::Exception;

my $CLASS = 'Object::Quick';
use_ok( $CLASS );
Expand Down Expand Up @@ -105,4 +106,22 @@ ok( main::K->can( 'm' ), "Imported 'm'" );
ok( main::K->can( 'c' ), "Imported 'c'" );
#}}}

{
package Test::Twice;
use Object::Quick;
use Test::More;
use Test::Exception;

my @warnings;

$SIG{ __WARN__ } = sub { push @warnings => @_ };

Object::Quick->import( 'obj' );

is_deeply( \@warnings, [], "No warnings" );

lives_ok { Object::Quick->import( 'obj' ) } "Double import";
like( @warnings[0], qr/Not overriding function: Test::Twice::obj/, "Not overriden" );
}

done_testing();

0 comments on commit 427b9f5

Please sign in to comment.