Created
June 7, 2018 08:06
-
-
Save kfly8/0cca4c6f145fd58ee50467a0643fa497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use Data::Validator; | |
use Types::Standard qw(Int); | |
use DDP; | |
sub strict_seq { | |
my $rule = Data::Validator->new( | |
key1 => Int, | |
key2 => Int, | |
)->with(qw/StrictSequenced/); | |
my $args = $rule->validate(@_); | |
} | |
sub smart_seq { | |
my $rule = Data::Validator->new( | |
key1 => Int, | |
key2 => Int, | |
)->with(qw/SmartSequenced/); | |
my $args = $rule->validate(@_); | |
} | |
sub seq { | |
my $rule = Data::Validator->new( | |
key1 => Int, | |
key2 => Int, | |
)->with(qw/Sequenced/); | |
my $args = $rule->validate(@_); | |
} | |
use Test::More; | |
use Test::Exception; | |
subtest 'strict sequenced' => sub { | |
lives_ok { strict_seq(1, 2) }; | |
dies_ok { strict_seq(1, key2 => 2) }; | |
dies_ok { strict_seq(1, {key2 => 2}) }; | |
dies_ok { strict_seq(key1 => 1, 2) }; | |
dies_ok { strict_seq(key1 => 1, key2 => 2) }; | |
}; | |
subtest 'smart sequenced' => sub { | |
lives_ok { smart_seq(1, 2) }; | |
dies_ok { smart_seq(1, key2 => 2) }; | |
lives_ok { smart_seq(1, {key2 => 2}) }; | |
dies_ok { smart_seq(key1 => 1, 2) }; | |
dies_ok { smart_seq(key1 => 1, key2 => 2) }; | |
}; | |
subtest 'sequenced' => sub { | |
lives_ok { seq(1, 2) }; | |
dies_ok { seq(1, key2 => 2) }; | |
lives_ok { seq(1, {key2 => 2}) }; | |
dies_ok { seq(key1 => 1, 2) }; | |
dies_ok { seq(key1 => 1, key2 => 2) }; | |
}; | |
done_testing; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment