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