Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more tests, overloading clearly hosed
- Loading branch information
Showing
3 changed files
with
77 additions
and
14 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
use strict; | |||
use warnings; | |||
use Test::More 'no_plan'; | |||
|
|||
use metamethod (); | |||
|
|||
{ | |||
my $ok = eval { | |||
package Foo; | |||
sub __metamethod__ { "just here to cause problems" } | |||
metamethod->import( sub { 1 } ); | |||
1; | |||
}; | |||
|
|||
my $error = $@; | |||
ok( ! $ok, "we can't use metamethod without custom name if conflict exists"); | |||
like($error, qr/already/, "... got the right error, more or less"); | |||
} | |||
|
|||
{ | |||
my $ok = eval { | |||
package Bar; | |||
metamethod->import(metamethod => \'doesnt_exist'); | |||
1; | |||
}; | |||
|
|||
my $error = $@; | |||
ok( ! $ok, "we can't provide metamethod by name if it doesn't exist"); | |||
like($error, qr/can't find/, "... got the right error, more or less"); | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
use strict; | |||
use warnings; | |||
use Test::More 'no_plan'; | |||
|
|||
use metamethod (); | |||
|
|||
TODO: { | |||
local $TODO = 'figure out how the crap overloading works'; | |||
|
|||
my @calls; | |||
{ | |||
package OLP; # overloads pass through | |||
metamethod->import( | |||
metamethod => sub { | |||
my ($self, $method, $args) = @_; | |||
push @calls, $method; | |||
return $method; | |||
}, | |||
overloads => 'metamethod', | |||
passthru => [ 'ISA' ], | |||
); | |||
} | |||
|
|||
my $olp = bless {} => 'OLP'; | |||
my $str = "$olp"; | |||
is($str, '(""', "we stringified to the stringification method name"); | |||
} |