Skip to content

Commit

Permalink
more monkey_patch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 28, 2012
1 parent f74cf10 commit dc74456
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Template.pm
Expand Up @@ -310,7 +310,7 @@ sub _wrap {

# Escape function
my $escape = $self->escape;
monkey_patch $self->namespace, '_escape', sub {
monkey_patch $self->namespace, _escape => sub {
no warnings 'uninitialized';
ref $_[0] eq 'Mojo::ByteStream' ? $_[0] : $escape->("$_[0]");
};
Expand Down
10 changes: 6 additions & 4 deletions t/mojo/util.t
Expand Up @@ -400,15 +400,17 @@ is slurp($file), "just\nworks!", 'successful roundtrip';
ok !!MojoMonkeyTest->can('foo'), 'function "foo" exists';
is MojoMonkeyTest::foo(), 'foo', 'right result';
ok !MojoMonkeyTest->can('bar'), 'function "bar" does not exist';
monkey_patch 'MojoMonkeyTest', 'bar', sub {'bar'};
monkey_patch 'MojoMonkeyTest', bar => sub {'bar'};
ok !!MojoMonkeyTest->can('bar'), 'function "bar" exists';
is MojoMonkeyTest::bar(), 'bar', 'right result';
monkey_patch 'MojoMonkeyTest', 'foo', sub {'baz'};
monkey_patch 'MojoMonkeyTest', foo => sub {'baz'};
ok !!MojoMonkeyTest->can('foo'), 'function "foo" exists';
is MojoMonkeyTest::foo(), 'baz', 'right result';
ok !MojoMonkeyTest->can('yin'), 'function "yin" does not exist';
ok !MojoMonkeyTest->can('yang'), 'function "yang" does not exist';
monkey_patch 'MojoMonkeyTest',
yin => sub { 'yin' },
yang => sub { 'yang' };
yin => sub {'yin'},
yang => sub {'yang'};
ok !!MojoMonkeyTest->can('yin'), 'function "yin" exists';
is MojoMonkeyTest::yin(), 'yin', 'right result';
ok !!MojoMonkeyTest->can('yang'), 'function "yang" exists';
Expand Down

0 comments on commit dc74456

Please sign in to comment.