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