Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Context::Singleton;
- use Test::Warnings qw[ had_no_warnings :no_end_tests ];
- sub expect_parser;
- frame {
- proclaim parser => Parqus->new ...;
- expect_parser 'it should parse empty string' => (
- with_query => '',
- expect => { },
- );
- expect_parse 'it should parse single word ...' => (
- with_query => ' foo ',
- expect => { words => ['foo'] },
- );
- };
- frame {
- proclaim parser => ...;
- };
- had_no_warnings;
- done_testing;
- sub expect_parser {
- my ($msg, %args) = @_;
- my $parser = deduce 'parser';
- local $Test::Builder::Level = $Test::Builder::Level + 1;
- my $res = $parser->process($args{with_query});
- if (exists $res->{errors}) {
- my $rv = fail $msg;
- diag "Expected success but error was reported:\n\t$res->{errors}";
- return $rv;
- }
- is_deeply( $res, $args{expect}, $msg)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement