4 use CPAN::Meta::Requirements;
9 my ($code, $qr, $comment) = @_;
11 my $lived = eval { $code->(); 1 };
14 fail("$comment: did not die");
16 like($@, $qr, $comment);
21 my $req = CPAN::Meta::Requirements->new;
23 $req->add_minimum('Foo::Bar' => 10);
24 $req->add_minimum('Foo::Bar' => 0);
25 $req->add_minimum('Foo::Bar' => 2);
27 $req->add_minimum('Foo::Baz' => version->declare('v1.2.3'));
29 $req->add_minimum('Foo::Undef' => undef);
33 'Foo::Baz' => 'v1.2.3',
40 "some basic minimums",
45 $req->add_minimum('Foo::Bar', 2);
47 pass('we can add a Foo::Bar requirement with no effect post finalization');
49 dies_ok { $req->add_minimum('Foo::Bar', 12) }
51 "can't add a higher Foo::Bar after finalization";
53 dies_ok { $req->add_minimum('Foo::New', 0) }
55 "can't add a new module prereq after finalization";
57 dies_ok { $req->clear_requirement('Foo::Bar') }
59 "can't clear an existing prereq after finalization";
61 $req->clear_requirement('Bogus::Req');
63 pass('we can clear a prereq that was not set to begin with');
68 "none of our attempts to alter the object post-finalization worked",
71 my $cloned = $req->clone;
73 $cloned->add_minimum('Foo::Bar', 12);
76 $cloned->as_string_hash,
81 "we can alter a cloned V:R (finalization does not survive cloning)",
87 "...and original requirements are untouched",