Aion

 view release on metacpan or  search on metacpan

t/aion/meta/requires-feature.pm  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  BEGIN {     $SIG{__DIE__} = sub ...
# 
# use common::sense;
# 
# use Aion::Meta::Util qw//;
# use List::Util qw/pairmap/;
# use Scalar::Util qw/looks_like_number reftype blessed refaddr/;
# 
# Aion::Meta::Util::create_getters(qw/pkg name opt has/);
# 
# #  Конструктор
# sub new {
# 	my ($cls, $pkg, $name, @has) = @_;
# 	bless {pkg => $pkg, name => $name, opt => {@has}, has => \@has}, ref $cls || $cls;
# }
# 
# # Строковое представление фичи
# sub stringify {
# 	my ($self) = @_;
# 	my $has = join ', ', pairmap { "$a => ${\
# 		Aion::Meta::Util::val_to_str($b)
# 	}" } @{$self->{has}};
# 	return "req $self->{name} => ($has) of $self->{pkg}";
# }
# 
# # Сравнивает с фичей, но только значения которые есть в этой
# sub compare {
# 	my ($self, $feature) = @_;
# 
# 	die "Requires $self" unless UNIVERSAL::isa($feature, 'Aion::Meta::Feature');
# 
# 	my $fail = 0;
# 	for my $key (keys %{$self->{opt}}) {
# 		$fail = 1, last unless exists $feature->{opt}{$key};
# 
# 		my $value = $self->{opt}{$key};
# 		my $other_value = $feature->{opt}{$key};
# 		$fail = 1, last unless _deep_equal($value, $other_value);
# 	}
# 
# 	die "Feature mismatch with ${\$self->stringify}" if $fail;
# }
# 
# # Сравнивает два значения
# sub _deep_equal {
# 	my ($value, $other_value) = @_;
# 
# 	if (blessed $value) {
# 		return "" unless blessed $other_value;
# 
# 		if (overload::Method($value, '==')) {
# 			return "" unless $value == $other_value;
# 		}
# 		elsif (overload::Method($value, 'eq')) {
# 			return "" unless $value eq $other_value;
# 		}
# 		else {
# 			return "" if refaddr $value != refaddr $other_value;
# 		}
# 	}
# 	elsif (looks_like_number($value)) {
# 		return "" unless looks_like_number($other_value) && $value == $other_value;
# 	}
# 	elsif (reftype $value eq 'ARRAY') {
# 		for(my $i = 0; $i <= $#$value; $i++) {
# 			return "" unless _deep_equal($value->[$i], $other_value->[$i]);
# 		}
# 	}
# 	elsif (reftype $value eq 'HASH') {
# 		for my $k (keys %$value) {
# 			return "" unless exists $other_value->{$k} && _deep_equal($value->{$k}, $other_value->{$k});
# 		}
# 	}
# 	elsif (reftype $value eq 'SCALAR') {
# 		return "" unless reftype $other_value eq 'SCALAR' && _deep_equal($$value, $$other_value);
# 	}
# 	elsif (reftype $value eq 'CODE') {
# 		return "" unless reftype $other_value eq 'CODE' && refaddr $value == refaddr $other_value;
# 	}
# 	else {



( run in 1.633 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )