Server IP : 192.168.23.10  /  Your IP : 18.220.204.184
Web Server : Apache
System : Linux echo.premieradvertising.com 5.14.0-362.8.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 7 14:54:22 EST 2023 x86_64
User : rrrallyteam ( 1049)
PHP Version : 8.1.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF
Directory (0755) :  /home/../usr/share/GConf/../grub/../doc/cronie/../libepoxy/../perl-CPAN-Meta/t/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/../usr/share/GConf/../grub/../doc/cronie/../libepoxy/../perl-CPAN-Meta/t/prereqs-finalize.t
use strict;
use warnings;
use Test::More 0.88;

use CPAN::Meta::Prereqs;

delete $ENV{PERL_YAML_BACKEND};
delete $ENV{PERL_JSON_BACKEND};
delete $ENV{CPAN_META_JSON_BACKEND};
delete $ENV{CPAN_META_JSON_DECODER};

sub dies_ok (&@) {
  my ($code, $qr, $comment) = @_;

  if (eval { $code->(); 1 }) {
    fail("$comment: did not die");
  } else {
    like($@, $qr, $comment);
  }
}

my $prereqs_struct = {
  runtime => {
    requires => {
      'Config' => '1.234',
      'Cwd'    => '876.5',
      'IO::File'   => 0,
      'perl'       => '5.005_03',
    },
    recommends => {
      'Pod::Text' => 0,
      'YAML'      => '0.35',
    },
  },
  build => {
    requires => {
      'Test' => 0,
    },
  }
};

my $prereqs = CPAN::Meta::Prereqs->new($prereqs_struct);

isa_ok($prereqs, 'CPAN::Meta::Prereqs');

$prereqs->finalize;

ok($prereqs->is_finalized, 'cloned obj is not finalized');

is_deeply($prereqs->as_string_hash, $prereqs_struct, '...and still round-trip');

$prereqs->requirements_for(qw(runtime requires))->add_minimum(Cwd => 10);

pass('...we can add a minimum if it has no effect');

dies_ok
  { $prereqs->requirements_for(qw(runtime requires))->add_minimum(Cwd => 1000) }
  qr{finalized req},
  '...but we die if it would alter a finalized prereqs';

$prereqs->requirements_for(qw(develop suggests));

pass('...we can get a V:R object for a previously unconfigured phase');

dies_ok
  { $prereqs->requirements_for(qw(develop suggests))->add_minimum(Foo => 1) }
  qr{finalized req},
  '...but we die if we try to put anything in it';

my $clone = $prereqs->clone;

isa_ok($clone, 'CPAN::Meta::Prereqs', 'cloned prereqs obj');

ok(! $clone->is_finalized, 'cloned obj is not finalized');

is_deeply($clone->as_string_hash, $prereqs_struct, '...it still round-trips');

$clone->requirements_for(qw(runtime requires))->add_minimum(Cwd => 10);

pass('...we can add minimum if it has no effect');

$clone->requirements_for(qw(runtime requires))->add_minimum(Cwd => 1000);

pass('...or if it has an effect');

$clone->requirements_for(qw(develop suggests));

pass('...we can get a V:R object for a previously unconfigured phase');

$clone->requirements_for(qw(develop suggests))->add_minimum(Foo => 1);

pass('...and we can add stuff to it');

done_testing;
# vim: ts=2 sts=2 sw=2 et :