Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 019_moose_octal_defaults.t
1 #!/usr/bin/env perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5 use Test::More;
6
7 {
8     my $package = qq{
9 package Test::Mouse::Go::Boom;
10 use Mouse;
11 use lib qw(lib);
12
13 has id => (
14     isa     => 'Str',
15     is      => 'ro',
16     default => '019600', # this caused the original failure
17 );
18
19 no Mouse;
20
21 __PACKAGE__->meta->make_immutable;
22 };
23
24     eval $package;
25     $@ ? ::fail($@) : ::pass('quoted 019600 default works');
26     my $obj = Test::Mouse::Go::Boom->new;
27     ::is( $obj->id, '019600', 'value is still the same' );
28 }
29
30 {
31     my $package = qq{
32 package Test::Mouse::Go::Boom2;
33 use Mouse;
34 use lib qw(lib);
35
36 has id => (
37     isa     => 'Str',
38     is      => 'ro',
39     default => 017600,
40 );
41
42 no Mouse;
43
44 __PACKAGE__->meta->make_immutable;
45 };
46
47     eval $package;
48     $@ ? ::fail($@) : ::pass('017600 octal default works');
49     my $obj = Test::Mouse::Go::Boom2->new;
50     ::is( $obj->id, 8064, 'value is still the same' );
51 }
52
53 {
54     my $package = qq{
55 package Test::Mouse::Go::Boom3;
56 use Mouse;
57 use lib qw(lib);
58
59 has id => (
60     isa     => 'Str',
61     is      => 'ro',
62     default => 0xFF,
63 );
64
65 no Mouse;
66
67 __PACKAGE__->meta->make_immutable;
68 };
69
70     eval $package;
71     $@ ? ::fail($@) : ::pass('017600 octal default works');
72     my $obj = Test::Mouse::Go::Boom3->new;
73     ::is( $obj->id, 255, 'value is still the same' );
74 }
75
76 {
77     my $package = qq{
78 package Test::Mouse::Go::Boom4;
79 use Mouse;
80 use lib qw(lib);
81
82 has id => (
83     isa     => 'Str',
84     is      => 'ro',
85     default => '0xFF',
86 );
87
88 no Mouse;
89
90 __PACKAGE__->meta->make_immutable;
91 };
92
93     eval $package;
94     $@ ? ::fail($@) : ::pass('017600 octal default works');
95     my $obj = Test::Mouse::Go::Boom4->new;
96     ::is( $obj->id, '0xFF', 'value is still the same' );
97 }
98
99 {
100     my $package = qq{
101 package Test::Mouse::Go::Boom5;
102 use Mouse;
103 use lib qw(lib);
104
105 has id => (
106     isa     => 'Str',
107     is      => 'ro',
108     default => '0 but true',
109 );
110
111 no Mouse;
112
113 __PACKAGE__->meta->make_immutable;
114 };
115
116     eval $package;
117     $@ ? ::fail($@) : ::pass('017600 octal default works');
118     my $obj = Test::Mouse::Go::Boom5->new;
119     ::is( $obj->id, '0 but true', 'value is still the same' );
120 }
121
122 done_testing;