Skip to content

Instantly share code, notes, and snippets.

@Songmu
Created December 17, 2014 09:41
Show Gist options
  • Save Songmu/a38e06f96948e3029217 to your computer and use it in GitHub Desktop.
Save Songmu/a38e06f96948e3029217 to your computer and use it in GitHub Desktop.
const.t
use strict;
use warnings;
use constant {HOGE => 10};
use Test::More;
use Test::Mock::Guard;
{
my $g = mock_guard main => { HOGE => sub { 100 }};
is HOGE, 10;
is HOGE(), 10;
is &HOGE(), 100;
is( main->HOGE, 100);
is "main"->HOGE, 100;
is __PACKAGE__->HOGE, 100;
is "main"->can('HOGE')->(), 100;
is(main->can('HOGE')->(), 100);
is $main::{HOGE}->(), 100;
}
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment