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 :  /usr/share/doc/perl-MooseX-Getopt/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-MooseX-Getopt/t/010_dashes.t
use strict;
use warnings;

use Test::More 0.88;
use Test::Fatal;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';

BEGIN {
    use_ok('MooseX::Getopt');
}

{
    package App;
    use Moose;

    with 'MooseX::Getopt::Dashes';

    has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' );
    has 'another_thingy'   => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], );
}

{
    local @ARGV = (qw/--some-thingy bar/);
    ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name';
}

{
    local @ARGV = (qw/--some_thingy bar/);
    like exception { App->new_with_options }, qr/Unknown option: some_thingy/;
}

{
    local @ARGV = (qw/--another_thingy bar/);
    ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name';
}

{
    local @ARGV = (qw/--another-thingy bar/);
    like exception { App->new_with_options }, qr/Unknown option: another-thingy/;
}

done_testing;

Hry