Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/proc/self/root/usr/share/doc/perl-Moose/t/bugs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/self/root/usr/share/doc/perl-Moose/t/bugs/moose_octal_defaults.t
use strict;
use warnings;

use Test::More;

{
    my $package = qq{
package Test::Moose::Go::Boom;
use Moose;
use lib qw(lib);

has id => (
    isa     => 'Str',
    is      => 'ro',
    default => '019600', # this caused the original failure
);

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 $package = qq{
package Test::Moose::Go::Boom2;
use Moose;
use lib qw(lib);

has id => (
    isa     => 'Str',
    is      => 'ro',
    default => 017600,
);

no Moose;

__PACKAGE__->meta->make_immutable;
};

    eval $package;
    $@ ? ::fail($@) : ::pass('017600 octal default works');
    my $obj = Test::Moose::Go::Boom2->new;
    ::is( $obj->id, 8064, 'value is still the same' );
}

{
    my $package = qq{
package Test::Moose::Go::Boom3;
use Moose;
use lib qw(lib);

has id => (
    isa     => 'Str',
    is      => 'ro',
    default => 0xFF,
);

no Moose;

__PACKAGE__->meta->make_immutable;
};

    eval $package;
    $@ ? ::fail($@) : ::pass('017600 octal default works');
    my $obj = Test::Moose::Go::Boom3->new;
    ::is( $obj->id, 255, 'value is still the same' );
}

{
    my $package = qq{
package Test::Moose::Go::Boom4;
use Moose;
use lib qw(lib);

has id => (
    isa     => 'Str',
    is      => 'ro',
    default => '0xFF',
);

no Moose;

__PACKAGE__->meta->make_immutable;
};

    eval $package;
    $@ ? ::fail($@) : ::pass('017600 octal default works');
    my $obj = Test::Moose::Go::Boom4->new;
    ::is( $obj->id, '0xFF', 'value is still the same' );
}

{
    my $package = qq{
package Test::Moose::Go::Boom5;
use Moose;
use lib qw(lib);

has id => (
    isa     => 'Str',
    is      => 'ro',
    default => '0 but true',
);

no Moose;

__PACKAGE__->meta->make_immutable;
};

    eval $package;
    $@ ? ::fail($@) : ::pass('017600 octal default works');
    my $obj = Test::Moose::Go::Boom5->new;
    ::is( $obj->id, '0 but true', 'value is still the same' );
}

done_testing;

Hry