From: Yuval Kogman Date: Mon, 28 Jan 2008 15:38:12 +0000 (+0000) Subject: get_code_info test X-Git-Tag: 0_53~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=423ea917f3d5740f4e4067fbbf50238a618f61c4;p=gitmo%2FClass-MOP.git get_code_info test --- diff --git a/t/082_get_code_info.t b/t/082_get_code_info.t new file mode 100644 index 0000000..1a10319 --- /dev/null +++ b/t/082_get_code_info.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More 'no_plan'; + +BEGIN { use_ok("Class::MOP") } + +use Sub::Name qw(subname); + +sub code_name_is ($$$;$) { + my ( $code, $stash, $name, $desc ) = @_; + $desc ||= "sub name is ${stash}::$name"; + + is_deeply( + [ Class::MOP::get_code_info($code) ], + [ $stash, $name ], + $desc, + ); +} + +code_name_is( sub {}, main => "__ANON__" ); + +code_name_is( subname("Foo::bar", sub {}), Foo => "bar" ); + +code_name_is( subname("", sub {}), "main" => "" ); + +require Class::MOP::Method; +code_name_is( \&Class::MOP::Method::name, "Class::MOP::Method", "name" ); +