Test2::Tools::Condition - Conditional block with Test2
use Test2::V0; use Test2::Tools::Condition; my $positive_number = condition { $_ > 0 }; is 123, $positive_number; is { a => 0, b => 1, }, { a => !$positive_number, b => $positive_number, };
Test2::Tools::Condition checks wether or not the value satisfies the condition.
Verify the value satisfies the condition and set $_ for $got value in block.
$_
$got
is 3, condition { 2 < $_ && $_ < 4 };
Verify the value unsatisfies the condition and set $_ for $got value in block.
is 7, !condition { 2 < $_ && $_ < 4 };
Test::Deep::Cond
Test2::Suite, Test2::Tools::Compare
Copyright (C) Takumi Akiyama.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Takumi Akiyama <t.akiym@gmail.com>
To install Test2::Tools::Condition, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test2::Tools::Condition
CPAN shell
perl -MCPAN -e shell install Test2::Tools::Condition
For more information on module installation, please visit the detailed CPAN module installation guide.