Text-Xatena

 view release on metacpan or  search on metacpan

t/80_internal.t  view on Meta::CPAN

use strict;
use Test::More tests => 13;
use Text::Xatena;
use Data::Dumper;

sub p ($) { warn Dumper shift }

my $thx = Text::Xatena->new;
my $res;
sub same ($$) {
	my ($got, $expected) = @_;
	my $r = is_deeply $got, $expected;
	unless ($r) {
		p $got;
	}
}

$res = $thx->_parse(<<EOS);
foo
bar
EOS

same $res, {
	children => [
		"foo",
		"bar",
	]
};

$res = $thx->_parse(<<EOS);
foo
bar

baz
EOS

same $res, {
	children => [
		"foo",
		"bar",
		"",
		"baz",
	]
};

$res = $thx->_parse(<<EOS);
- foo
- bar
- baz
EOS

same $res, {
	children => [
		{
			children => [
				[ "- foo", "-", "foo"],
				[ "- bar", "-", "bar"],
				[ "- baz", "-", "baz"],
			]
		}
	]
};

$res = $thx->_parse(<<EOS);
- foo
- bar



( run in 2.160 seconds using v1.01-cache-2.11-cpan-364913b4093 )