Skip to content

Instantly share code, notes, and snippets.

@mix3
Created December 17, 2014 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mix3/3fe98045dc4e4b65b8bc to your computer and use it in GitHub Desktop.
Save mix3/3fe98045dc4e4b65b8bc to your computer and use it in GitHub Desktop.
Const::Common 上書きできるかな?

$ cat lib/App/Const.pm

package App::Const;

use Const::Common( HOGE => 10, );

1;

$ cat t/test.t

use strict;
use warnings;
use utf8;

use App::Const;
use Test::More;
use Test::Mock::Guard;

is HOGE, 10, "orig";

{
    my $guard = mock_guard "App::Const" => { HOGE => 100, };
    is HOGE, 100, "overwrite";
}

done_testing;

$ carton exec perl -I lib/ t/test.t

ok 1 - orig
not ok 2 - overwrite
#   Failed test 'overwrite'
#   at t/test.t line 13.
#          got: '10'
#     expected: '100'
1..2
# Looks like you failed 1 test of 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment