### ----------------------------------------------------
### -- RakuDoc::Load
### -- Licenses: Artistic-2.0
### -- Authors: Tom Browder
### -- File: t/2-metadata.rakutest
### ----------------------------------------------------
use Test;
use RakuDoc::Load;

diag "Testing strings with metadata";
my $string-with-rakudoc = q:to/HERE/;
=begin rakudoc :ver(3) :skip-test<Chunk>
This ordinary paragraph introduces a code block:
    $this = 1 * code('block');
    $which.is_specified(:by<indenting>);
=end rakudoc
HERE

my @rakudoc = load( $string-with-rakudoc );
ok( @rakudoc, "String load returns something" );
like( @rakudoc[0].^name, /Pod\:\:/, "The first element of that is a Pod");
is( @rakudoc[0].config, {:ver(3), :skip-test<Chunk>}, "Config passed" );

my $bare-rakudoc = "Z<this is a comment>";
@rakudoc = load-rakudoc( $bare-rakudoc );
is( @rakudoc[0].contents[0].contents[0].type, "Z", "Comment passed on successfully");

# test alias 'load-pod' works
my @pod = load-pod( $bare-rakudoc );
is( @pod[0].contents[0].contents[0].type, "Z", "Comment passed on successfully");

my $string-with-Z = qq:to/HERE/;
=begin rakudoc
$bare-rakudoc
=end rakudoc
HERE

@rakudoc = load( $string-with-Z );
ok( @rakudoc, "String with comment returns something" );
is( @rakudoc[0].contents[0].contents[0].type, "Z", "Comment passed on successfully");

@rakudoc = load("=begin rakudoc\nThis could be a comment with C<code>\n=end rakudoc");
ok( @rakudoc[0].contents[0].contents.grep( { .?type ~~ 'C' } ), "There's a code block");

done-testing;


