-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
e57fc5a
commit 3ba8bc7
Showing
8 changed files
with
166 additions
and
13 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
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,8 @@ | ||
package ScopedStrict::Mockee1; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
sub gonna_mock_this { return "you're not going to see this" } | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ScopedStrict::Mockee2; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
sub also_gonna_mock_this { return "you're not going to see this either" } | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ScopedStrict::NonStrictMocker; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::MockModule; | ||
|
||
Test::MockModule->new('ScopedStrict::Mockee2')->mock( | ||
also_gonna_mock_this => sub { "another mocked sub" } | ||
); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ScopedStrict::StrictMocker; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::MockModule qw(strict); | ||
|
||
Test::MockModule->new('ScopedStrict::Mockee1')->redefine( | ||
gonna_mock_this => sub { "mocked sub" } | ||
); | ||
|
||
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
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,20 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
use lib 't/lib'; | ||
|
||
# things we're going to mock | ||
use ScopedStrict::Mockee1; | ||
use ScopedStrict::Mockee2; | ||
|
||
# mock one of them in strict mode | ||
use ScopedStrict::StrictMocker; | ||
# this doesn't turn on strict mode, and tries to use ->mock(). It | ||
# shouldn't crash | ||
use ScopedStrict::NonStrictMocker; | ||
|
||
# yay, we didn't crash! | ||
pass "Using 'strict' mode in one module that we use didn't prevent ->mock()ing in another"; | ||
done_testing(); |