Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ MANIFEST This list of files | |
MANIFEST.SKIP | ||
t/00compile.t | ||
t/control_rand.t | ||
t/exports.t | ||
t/rand.t |
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,72 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
# A class without any other exports. | ||
{ | ||
package Flowers; | ||
use Test::Sims; | ||
|
||
make_rand flower => [qw(Rose Daisy Ed Bob)]; | ||
make_rand numbers => [qw(1 2 3 4 5)]; | ||
} | ||
|
||
# A class which already has exports | ||
{ | ||
package Things; | ||
use Test::Sims; | ||
|
||
use base "Exporter"; | ||
our @EXPORT_OK = "stuff"; | ||
|
||
sub stuff { 42 } | ||
|
||
make_rand stuff => [qw(this that other thing)]; | ||
} | ||
|
||
|
||
# Test :rand export tag | ||
{ | ||
package Foo; | ||
|
||
Flowers->import(":rand"); | ||
|
||
::can_ok(__PACKAGE__, "rand_flower"); | ||
::can_ok(__PACKAGE__, "rand_numbers"); | ||
} | ||
|
||
|
||
# Test rand functions are in @EXPORT_OK | ||
{ | ||
package Bar; | ||
|
||
Flowers->import("rand_flower"); | ||
|
||
::can_ok(__PACKAGE__, "rand_flower"); | ||
} | ||
|
||
|
||
# Test rand functions are not exported by default. | ||
{ | ||
package Baz; | ||
|
||
Flowers->import(); | ||
|
||
::ok( !Baz->can("rand_flower"), "does not export rand by default" ); | ||
} | ||
|
||
|
||
# Test existing exports are preserved | ||
{ | ||
package Wiffle; | ||
|
||
Things->import("stuff", "rand_stuff"); | ||
|
||
::is( stuff(), 42, "\@EXPORT_OK preserved" ); | ||
::can_ok( Wiffle => "rand_stuff" ); | ||
} | ||
|
||
done_testing(); |