From: Chris Prather Date: Fri, 21 Nov 2008 17:01:52 +0000 (+0000) Subject: add failing test for octal problem X-Git-Tag: 0.62~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c0314b302894e30c5d1cf2a7741c65e0456aa77;p=gitmo%2FMoose.git add failing test for octal problem tidy the test some add test for octal doing the right thing --- diff --git a/t/100_bugs/019_moose_octal_defaults.pm b/t/100_bugs/019_moose_octal_defaults.pm new file mode 100644 index 0000000..8cde1e4 --- /dev/null +++ b/t/100_bugs/019_moose_octal_defaults.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +use Test::More qw(no_plan); + +my $package = qq{ +package Test::Moose::Go::Boom; +use Moose; +use lib qw(lib); + +has id => ( + isa => 'Str', + is => 'ro', + default => '019600', # Moose doesn't quote this when inlining, an perl treats it as an octal ... and 9 isn't a valid octal +); + +no Moose; + +__PACKAGE__->meta->make_immutable; +}; + +eval $package; +$@ ? ::fail($@) : ::pass('quoted 019600 default works'); +my $obj = Test::Moose::Go::Boom->new; +::is($obj->id, '019600', 'value is still the same'); + +my $package2 = qq{ +package Test::Moose::Go::Boom2; +use Moose; +use lib qw(lib); + +has id => ( + isa => 'Str', + is => 'ro', + default => 017600, # Moose doesn't quote this when inlining, an perl treats it as an octal ... and 9 isn't a valid octal +); + +no Moose; + +__PACKAGE__->meta->make_immutable; +}; + + +eval $package2; +$@ ? ::fail($@) : ::pass('017600 octal default works'); +my $obj = Test::Moose::Go::Boom2->new; +::is($obj->id, 8064, 'value is still the same'); \ No newline at end of file