From: gfx Date: Wed, 19 Aug 2009 10:12:20 +0000 (+0900) Subject: Ensure generated accessors to be XS X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5fdacac1801a7161b63b44d32accfbb900381267;p=gitmo%2FMoose.git Ensure generated accessors to be XS --- diff --git a/t/020_attributes/030_xs_accessor.t b/t/020_attributes/030_xs_accessor.t new file mode 100755 index 0000000..b91dc9a --- /dev/null +++ b/t/020_attributes/030_xs_accessor.t @@ -0,0 +1,32 @@ +use strict; +use warnings; +use Test::More tests => 6; +use Class::MOP; + +use B qw(svref_2object); + +sub method_type{ + my($class, $method) = @_; + return svref_2object($class->can($method))->XSUB ? 'XS' + : $class->meta->get_method($method)->is_inline ? 'Inline' + : 'Basic'; +} + + +{ + package Foo; + use Moose; + __PACKAGE__->meta->add_attribute('r' => (reader => 'r')); + __PACKAGE__->meta->add_attribute('w' => (writer => 'w')); + __PACKAGE__->meta->add_attribute('a' => (accessor => 'a')); + __PACKAGE__->meta->add_attribute('c' => (clearer => 'c')); + __PACKAGE__->meta->add_attribute('p' => (predicate => 'p')); +} +ok(Foo->meta->get_meta_instance->can_xs(), 'can_xs()'); +is method_type('Foo', 'r'), 'XS', 'reader is XS'; +is method_type('Foo', 'w'), 'XS', 'writer is XS'; +is method_type('Foo', 'a'), 'XS', 'accessor is XS'; +is method_type('Foo', 'c'), 'XS', 'clearer is XS'; +is method_type('Foo', 'p'), 'XS', 'predicate is XS'; + +