You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
924 B
62 lines
924 B
10 years ago
|
#!/usr/bin/env perl
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
use utf8;
|
||
|
|
||
|
use Test::More tests => 8;
|
||
|
use Text::Dokuwiki::Regexps;
|
||
|
|
||
|
my $rx = $Text::Dokuwiki::Regexps::regexps;
|
||
|
my $text = <<'TEXT';
|
||
|
|
||
|
- item 1
|
||
|
- item 2
|
||
|
* item 1 level 2
|
||
|
* item 2 level 2
|
||
|
- item 3
|
||
|
|
||
|
TEXT
|
||
|
|
||
|
my $matched = <<'TEXT';
|
||
|
- item 1
|
||
|
- item 2
|
||
|
* item 1 level 2
|
||
|
* item 2 level 2
|
||
|
- item 3
|
||
|
TEXT
|
||
|
|
||
|
my @matches = $text =~ m/$rx->{list}/;
|
||
|
is($+{list}, $matched);
|
||
|
is(scalar @matches, 1);
|
||
|
|
||
|
$text = <<'TEXT';
|
||
|
|
||
|
- not enough identation
|
||
|
|
||
|
TEXT
|
||
|
@matches = $text =~ m/$rx->{list}/;
|
||
|
is(scalar @matches, 0);
|
||
|
|
||
|
$text = <<'TEXT';
|
||
|
- item
|
||
|
* item
|
||
|
TEXT
|
||
|
@matches = $text =~ m/$rx->{list}/;
|
||
|
is(scalar @matches, 1);
|
||
|
is($matches[0], $text);
|
||
|
|
||
|
$text = <<'TEXT';
|
||
|
+ wrong item marker
|
||
|
|
||
|
TEXT
|
||
|
@matches = $text =~ m/$rx->{list}/;
|
||
|
is(scalar @matches, 0);
|
||
|
|
||
|
$text = ' * missing newline';
|
||
|
@matches = $text =~ m/$rx->{list}/;
|
||
|
is(scalar @matches, 1);
|
||
|
is($matches[0], $text);
|
||
|
|
||
|
exit 0;
|