Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 100_bugs / 019_moose_octal_defaults.t
CommitLineData
4c98ebb0 1#!/usr/bin/env perl
ee5e6a03 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
5use Test::More;
4c98ebb0 6
7{
8 my $package = qq{
9package Test::Mouse::Go::Boom;
10use Mouse;
11use lib qw(lib);
12
13has id => (
14 isa => 'Str',
15 is => 'ro',
16 default => '019600', # this caused the original failure
17);
18
19no 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{
32package Test::Mouse::Go::Boom2;
33use Mouse;
34use lib qw(lib);
35
36has id => (
37 isa => 'Str',
38 is => 'ro',
39 default => 017600,
40);
41
42no 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{
55package Test::Mouse::Go::Boom3;
56use Mouse;
57use lib qw(lib);
58
59has id => (
60 isa => 'Str',
61 is => 'ro',
62 default => 0xFF,
63);
64
65no 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{
78package Test::Mouse::Go::Boom4;
79use Mouse;
80use lib qw(lib);
81
82has id => (
83 isa => 'Str',
84 is => 'ro',
85 default => '0xFF',
86);
87
88no 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{
101package Test::Mouse::Go::Boom5;
102use Mouse;
103use lib qw(lib);
104
105has id => (
106 isa => 'Str',
107 is => 'ro',
108 default => '0 but true',
109);
110
111no 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}
ee5e6a03 121
122done_testing;