Browse Source

* t/regexps-misc.t

master
Alex 'AdUser' Z 10 years ago
parent
commit
b554ec7b0e
  1. 2
      lib/Text/Dokuwiki/Regexps.pm
  2. 45
      t/regexps-misc.t

2
lib/Text/Dokuwiki/Regexps.pm

@ -10,7 +10,7 @@ our $regexps = {};
$regexps->{header} = qr{ $regexps->{header} = qr{
^ (?<header> .+ ) $EOL ^ (?<header> .+ ) $EOL
^ (?:<line> [=-]+ )(?: $EOL | $) ^ (?<line> [=-]+ ) (?: $EOL | $)
}mx; }mx;
$regexps->{codeblock} = qr% $regexps->{codeblock} = qr%

45
t/regexps-misc.t

@ -0,0 +1,45 @@
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Test::More tests => 10;
use Text::Dokuwiki::Regexps;
my $rx = $Text::Dokuwiki::Regexps::regexps;
use re 'debugcolor';
my $text = <<'TEXT';
Header 1st level
=================
TEXT
my $matched = 'Header 1st level';
my @matches = $text =~ m/$rx->{header}/;
is(scalar @matches, 2);
is($+{header}, $matched);
is($+{line}, '=================');
is($matches[0], $matched);
is($matches[1], '=================');
$text = <<'TEXT';
Header 2nd level
-----------------
TEXT
$matched = 'Header 2nd level';
@matches = $text =~ m/$rx->{header}/;
is(scalar @matches, 2);
is($matches[0], $matched);
is($matches[1], '-----------------');
$text = "Header only\n-------------";
$matched = 'Header only';
@matches = $text =~ m/$rx->{header}/;
is($matches[0], $matched);
is($matches[1], '-------------');
exit 0;
Loading…
Cancel
Save