File: 025_attribute_non_alpha_name.t

package info (click to toggle)
libclass-mop-perl 1.04-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,244 kB
  • ctags: 1,272
  • sloc: perl: 5,192; ansic: 241; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 646 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;

use Class::MOP;

use Test::More;

{
    package Foo;
    use metaclass;

    Foo->meta->add_attribute( '@foo', accessor => 'foo' );
    Foo->meta->add_attribute( '!bar', reader => 'bar' );
    Foo->meta->add_attribute( '%baz', reader => 'baz' );
}

{
    my $meta = Foo->meta;

    for my $name ( '@foo', '!bar', '%baz' ) {
        ok(
            $meta->has_attribute($name),
            "Foo has $name attribute"
        );

        my $meth = substr $name, 1;
        ok( $meta->has_method($meth), 'Foo has $meth method' );
    }

    $meta->make_immutable, redo
        unless $meta->is_immutable;
}

done_testing;