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-Class-Mix/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Class-Mix/t/mro_no.t
use warnings;
use strict;

BEGIN {
	if("$]" >= 5.009005) {
		require Test::More;
		Test::More::plan(skip_all => "MRO available on this Perl");
	}
}

use Test::More tests => 18;

BEGIN { use_ok "Class::Mix", qw(mix_class); }

{ package Foo; }
{ package Bar; }
{ package Baz; }

# error cases
foreach(
	{mro=>[]},
	{mro=>undef},
	{mro=>"wibble"},
	{mro=>"c3"},
) {
	eval { mix_class($_) };
	isnt $@, "";
	eval { mix_class("Foo", $_) };
	isnt $@, "";
	eval { mix_class("Foo", "Bar", $_) };
	isnt $@, "";
}

# OK cases
no strict "refs";
is mix_class({mro=>"dfs"}), "UNIVERSAL";
is mix_class("Foo", {mro=>"dfs"}), "Foo";
my $foobar = mix_class("Foo", "Bar", {mro=>"dfs"});
is_deeply(\@{$foobar."::ISA"}, ["Foo", "Bar"]);
is mix_class({mro=>"dfs"}, "Foo", "Bar"), $foobar;
is mix_class("Foo", "Bar"), $foobar;

1;

Hry