#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Test::More tests => 30;
use Text::Dokuwiki::Regexps;
my $rx = $Text::Dokuwiki::Regexps::regexps;
my $text = <<'TEXT';
>> are you ok?
> sure!
> not matched
TEXT
my $matched = <<'TEXT';
>> are you ok?
> sure!
TEXT
my @matches = ($text =~ $rx->{blockquote});
is(scalar @matches, 1);
is($matches[0], $matched);
is($+{block}, $matched);
$text = <<'TEXT';
some code here
TEXT
$matched = <<'TEXT';
some code here
TEXT
@matches = ($text =~ $rx->{codeblock});
is(scalar @matches, 4);
is($matches[0], 'code'); # tag name
is($matches[1], undef); # syntax (missing)
is($matches[2], undef); # filename (missing)
is($matches[3], $matched);
is($+{tag}, 'code');
is($+{block}, $matched);
is($+{syntax}, undef);
is($+{filename}, undef);
$text = <<'TEXT';
--- pgp block start ---
0YXRg9C5
--- pgp block end ---
TEXT
$matched = <<'TEXT';
--- pgp block start ---
0YXRg9C5
--- pgp block end ---
TEXT
@matches = ($text =~ $rx->{codeblock});
is(scalar @matches, 4);
is($matches[0], 'file'); # tag name
is($matches[1], undef); # syntax (missing)
is($matches[2], 'pubkey.asc'); # filename
is($matches[3], $matched);
is($+{tag}, 'file');
is($+{block}, $matched);
is($+{syntax}, undef);
is($+{filename}, 'pubkey.asc');
$text = <<'TEXT';
int main() { return 0; }
TEXT
$ matched = "int main() { return 0; }\n";
@matches = ($text =~ $rx->{codeblock});
is(scalar @matches, 4);
is($matches[0], 'code'); # tag name
is($matches[1], 'c'); # syntax
is($matches[2], 'main.c'); # filename
is($matches[3], $matched);
is($+{tag}, 'code');
is($+{block}, $matched);
is($+{syntax}, 'c');
is($+{filename}, 'main.c');
exit 0;