App-sdview

 view release on metacpan or  search on metacpan

t/30output-plain.t  view on Meta::CPAN

#!/usr/bin/perl

use v5.26;
use warnings;
use utf8;
use experimental 'signatures';

use Test2::V0;

# We don't have a "plain" input, but we can input from Pod or Markdown and test
# that we get some expected output
use App::sdview::Parser::Pod;
use App::sdview::Parser::Markdown;
use App::sdview::Output::Plain;

sub dotest ( $name, $format, $in, $out_text )
{
   my $parserclass = "App::sdview::Parser::" . ucfirst($format);
   my @p = $parserclass->new->parse_string( $in );
   my $output = App::sdview::Output::Plain->new;
   my $text = $output->generate( @p );

   is( $text, $out_text, "Generated text for $name" ) or
      diag( sprintf "Got: %v02X\nExp: %v02X\n", $text, $out_text );
}

dotest "Headings", pod => <<"EOPOD",
=head1 Head1

=head2 Head2

Contents here
EOPOD
<<"EOF";
Head1
  Head2
      Contents here
EOF

dotest "Formatting", pod => <<"EOPOD",
=pod

B<bold> B<< <bold> >>

I<italic>

C<code> C<< code->with->arrows >>

L<link|target://> L<Module::Here>
EOPOD
<<"EOF";
      bold <bold>

      italic

      code code->with->arrows

      link Module::Here
EOF

dotest "Verbatim", pod => <<"EOPOD",
=head1 EXAMPLE

    use v5.14;
    use warnings;
    say "Hello, world";
EOPOD
<<"EOF";
EXAMPLE
        use v5.14;         
        use warnings;      
        say "Hello, world";
EOF

dotest "Bullet lists", pod => <<"EOPOD",
=over 4

=item *

First

=item *

Second

=item *

Third

=back
EOPOD
<<"EOF";
      •   First

      •   Second

      •   Third
EOF

dotest "Numbered lists", pod => <<"EOPOD",
=over 4

=item 1.

First

=item 2.

Second

=item 3.



( run in 0.872 second using v1.01-cache-2.11-cpan-39bf76dae61 )