10 plan skip_all => "no XSLoader" unless eval { require XSLoader };
12 plan skip_all => $@ unless eval {
14 Moose->XSLoader::load($Moose::VERSION);
24 sub attr_to_meta_instance {
26 return $attr->associated_class->get_meta_instance;
29 sub meta_instance_to_attr_descs {
33 $mi->associated_metaclass->name,
36 key => ($_->slots)[0],
37 } } $mi->get_all_attributes ]
42 ok( defined &Moose::XS::new_getter );
43 ok( defined &Moose::XS::new_setter );
44 ok( defined &Moose::XS::new_accessor );
45 ok( defined &Moose::XS::new_predicate );
51 has x => ( is => "rw", predicate => "has_x" );
52 has y => ( is => "ro" );
53 has z => ( reader => "z", setter => "set_z" );
54 has ref => ( is => "rw", weak_ref => 1 );
58 my ( $x, $y, $z, $ref ) = map { Foo->meta->get_attribute($_) } qw(x y z ref);
59 $x->Moose::XS::new_accessor("Foo::x");
60 $x->Moose::XS::new_predicate("Foo::has_x");
61 $y->Moose::XS::new_getter("Foo::y");
62 $z->Moose::XS::new_getter("Foo::z");
63 $z->Moose::XS::new_setter("Foo::set_z");
64 $ref->Moose::XS::new_accessor("Foo::ref");
70 my $foo = Foo->new( x => "ICKS", y => "WHY", z => "ZEE", ref => $ref );
72 is( $foo->x, "ICKS" );
75 is( $foo->ref, $ref, );
77 lives_ok { $foo->x("YASE") };
79 is( $foo->x, "YASE" );
81 dies_ok { $foo->y("blah") };
85 dies_ok { $foo->z("blah") };
89 lives_ok { $foo->set_z("new") };
95 ok( !Foo->new->has_x );
99 is( $foo->ref(), undef );
105 is( $foo->ref, $ref, );
109 is( $foo->ref(), undef );