Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.