-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't treat locally defined subs as importable symbols
Otherwise we have the issue where: package Round; use parent 'Exporter'; use strict; use warnings; use Math::Round qw(nearest); our @EXPORT_OK = qw(round); sub round { my ( $number, $places ) = @_; return nearest( 10**-$places, $number ); } 1; gets an import changed to: use Math::Round qw( nearest round );
- Loading branch information
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use lib 't/lib', 'test-data/lib'; | ||
|
||
use Test::Differences qw( eq_or_diff ); | ||
use TestHelper qw( doc ); | ||
use Test::More import => [qw( done_testing )]; | ||
|
||
my ( $doc, $log ) = doc( | ||
filename => 'test-data/lib/Local/Round.pm', preserve_unused => 0, | ||
); | ||
|
||
my $expected = <<'END'; | ||
package Local::Round; | ||
use parent 'Exporter'; | ||
use strict; | ||
use warnings; | ||
use Math::Round qw( nearest ); | ||
our @EXPORT_OK = qw(round); | ||
sub round { | ||
my ( $number, $places ) = @_; | ||
return nearest( 10**-$places, $number ); | ||
} | ||
1; | ||
END | ||
|
||
eq_or_diff( | ||
$doc->tidied_document, | ||
$expected, | ||
'locally defined sub is not ignored' | ||
); | ||
|
||
done_testing(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package Local::Round; | ||
use parent 'Exporter'; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Math::Round qw( nearest ); | ||
our @EXPORT_OK = qw(round); | ||
|
||
sub round { | ||
my ( $number, $places ) = @_; | ||
return nearest( 10**-$places, $number ); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters