remove trailing whitespace
[gitmo/Moose.git] / t / 100_bugs / 019_moose_octal_defaults.t
CommitLineData
2c0314b3 1#!/usr/bin/env perl
9f171ae1 2use Test::More tests => 10;
2c0314b3 3
22692dd4 4{
5 my $package = qq{
2c0314b3 6package Test::Moose::Go::Boom;
7use Moose;
8use lib qw(lib);
9
10has id => (
11 isa => 'Str',
12 is => 'ro',
22692dd4 13 default => '019600', # this caused the original failure
2c0314b3 14);
15
16no 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 29package Test::Moose::Go::Boom2;
30use Moose;
31use lib qw(lib);
32
33has id => (
34 isa => 'Str',
35 is => 'ro',
d03bd989 36 default => 017600,
2c0314b3 37);
38
39no 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{
52package Test::Moose::Go::Boom3;
53use Moose;
54use lib qw(lib);
55
56has id => (
57 isa => 'Str',
58 is => 'ro',
d03bd989 59 default => 0xFF,
22692dd4 60);
61
62no 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{
75package Test::Moose::Go::Boom4;
76use Moose;
77use lib qw(lib);
78
79has id => (
80 isa => 'Str',
81 is => 'ro',
d03bd989 82 default => '0xFF',
22692dd4 83);
84
85no 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{
98package Test::Moose::Go::Boom5;
99use Moose;
100use lib qw(lib);
101
102has id => (
103 isa => 'Str',
104 is => 'ro',
d03bd989 105 default => '0 but true',
2deb99ff 106);
107
108no 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}