1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
use strict;
use warnings;
use Test2::V0 0.000081;
use Markdent::Dialect::Theory::BlockParser;
use Markdent::Handler::MinimalTree;
use Markdent::Parser;
use FindBin qw( $Bin );
use lib "$Bin/../t/lib";
my $handler = Markdent::Handler::MinimalTree->new();
{
my $parser = Markdent::Parser->new(
dialects => 'Theory',
handler => $handler,
);
ok(
$parser->_block_parser()->meta()
->does_role('Markdent::Dialect::Theory::BlockParser'),
'$parser->_block_parser() with dialects = Theory'
);
ok(
$parser->_span_parser()->meta()
->does_role('Markdent::Dialect::Theory::SpanParser'),
'$parser->_span_parser() with dialects = Theory'
);
}
{
my $parser = Markdent::Parser->new(
dialects => ['Theory'],
handler => $handler,
);
ok(
$parser->_block_parser()->meta()
->does_role('Markdent::Dialect::Theory::BlockParser'),
'$parser->_block_parser() with dialects = [Theory]'
);
ok(
$parser->_span_parser()->meta()
->does_role('Markdent::Dialect::Theory::SpanParser'),
'$parser->_span_parser() with dialects = [Theory]'
);
}
{
is(
dies {
my $parser = Markdent::Parser->new(
dialects => 'Theory',
block_parser_class => 'Markdent::Parser::BlockParser',
handler => $handler,
);
},
undef,
'Can combine an explicit block_parser_class with a dialect'
);
}
{
my $parser = Markdent::Parser->new(
dialects => ['Example::Dialect'],
handler => $handler,
);
ok(
$parser->_block_parser()->meta()
->does_role('Example::Dialect::BlockParser'),
'$parser->_block_parser() with dialects = Example::Dialect'
);
ok(
$parser->_span_parser()->meta()
->does_role('Example::Dialect::SpanParser'),
'$parser->_span_parser() with dialects = Example::Dialect'
);
}
{
my $parser = Markdent::Parser->new(
dialects => ['Example::Dialect2'],
handler => $handler,
);
ok(
$parser->_span_parser()->meta()
->does_role('Example::Dialect2::SpanParser'),
'$parser->_span_parser() with dialects = Example::Dialect2 - only provides a SpanParser class'
);
}
{
my $parser = Markdent::Parser->new(
dialect => 'Theory',
handler => $handler,
);
ok(
$parser->_block_parser()->meta()
->does_role('Markdent::Dialect::Theory::BlockParser'),
'$parser->_block_parser() with dialect = Theory (dialect as synonym for dialects)'
);
ok(
$parser->_span_parser()->meta()
->does_role('Markdent::Dialect::Theory::SpanParser'),
'$parser->_span_parser() with dialect = Theory (dialect as synonym for dialects)'
);
}
done_testing();
|