Move t/*/t into t/001_mouse
[gitmo/Mouse.git] / t / 001_mouse / 603-octal-defaults.t
CommitLineData
39c84648 1#!/usr/bin/env perl
2use Test::More qw(no_plan);
3
4# copied straight out of Moose t/100/019
5
6{
7 my $package = qq{
8package Test::Mouse::Go::Boom;
9use Mouse;
10use lib qw(lib);
11
12has id => (
13 isa => 'Str',
14 is => 'ro',
15 default => '019600', # this caused the original failure
16);
17
18no 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{
31package Test::Mouse::Go::Boom2;
32use Mouse;
33use lib qw(lib);
34
35has id => (
36 isa => 'Str',
37 is => 'ro',
38 default => 017600,
39);
40
41no 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{
54package Test::Mouse::Go::Boom3;
55use Mouse;
56use lib qw(lib);
57
58has id => (
59 isa => 'Str',
60 is => 'ro',
61 default => 0xFF,
62);
63
64no 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{
77package Test::Mouse::Go::Boom4;
78use Mouse;
79use lib qw(lib);
80
81has id => (
82 isa => 'Str',
83 is => 'ro',
84 default => '0xFF',
85);
86
87no 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{
100package Test::Mouse::Go::Boom5;
101use Mouse;
102use lib qw(lib);
103
104has id => (
105 isa => 'Str',
106 is => 'ro',
107 default => '0 but true',
108);
109
110no 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}