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-Moose/t/basics/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Moose/t/basics/import_unimport.t
use strict;
use warnings;

use Test::More;


my @moose_exports = qw(
    extends with
    has
    before after around
    override
    augment
    super inner
    blessed confess
);

{
    package Foo;

    eval 'use Moose';
    die $@ if $@;
}

can_ok('Foo', $_) for @moose_exports;

{
    package Foo;

    eval 'no Moose';
    die $@ if $@;
}

ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;

# and check the type constraints as well

my @moose_type_constraint_exports = qw(
    type subtype as where message
    coerce from via
    enum
    find_type_constraint
);

{
    package Bar;

    eval 'use Moose::Util::TypeConstraints';
    die $@ if $@;
}

can_ok('Bar', $_) for @moose_type_constraint_exports;

{
    package Bar;

    eval 'no Moose::Util::TypeConstraints';
    die $@ if $@;
}

ok(!Bar->can($_), '... Bar can no longer do ' . $_) for @moose_type_constraint_exports;


{
    package Baz;

    use Moose;
    use Scalar::Util qw( blessed );

    no Moose;
}

can_ok( 'Baz', 'blessed' );

{
    package Moo;

    use Scalar::Util qw( blessed );
    use Moose;

    no Moose;
}

can_ok( 'Moo', 'blessed' );

my $blessed;
{
    package Quux;

    use Scalar::Util qw( blessed );
    use Moose blessed => { -as => \$blessed };

    no Moose;
}

can_ok( 'Quux', 'blessed' );
is( $blessed, \&Scalar::Util::blessed );

done_testing;

Hry