Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for =defn implementation #457

Merged
merged 1 commit into from
Aug 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 90 additions & 0 deletions S26-documentation/14-defn.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
use v6;
use Test;

plan 30;

my $o;
my $o1;
my $p = -1;

#=== valid ways to write a =defn block:

# delimited, uses %config
=begin defn :numbered
B<term 1>
B<def 1>
=end defn

$o = $=pod[++$p];
isa-ok $o, 'Pod::Defn';
ok $o.config<numbered>:exists;
is $o.term, 'B<term 1>';
isa-ok $o.contents[0], 'Pod::Block::Para';
is $o.contents[0].contents[0], 'B<def 1>';

# abbreviated, no %config, uses data on first line for term
=defn term 2
def 2 line1
def 2 line2

$o = $=pod[++$p];
isa-ok $o, 'Pod::Defn';
is $o.term, 'term 2';
isa-ok $o.contents[0], 'Pod::Block::Para';
is $o.contents[0].contents[0], 'def 2 line1 def 2 line2';

# abbreviated, no %config, uses data on first line for term
# hash on first line is alias for %config ':numbered'
=defn # term 3
def 3 line1
def 3 line2

$o = $=pod[++$p];
isa-ok $o, 'Pod::Defn';
ok $o.config<numbered>:exists;
is $o.term, 'term 3';
isa-ok $o.contents[0], 'Pod::Block::Para';
is $o.contents[0].contents[0], 'def 3 line1 def 3 line2';


# paragraph, uses %config
=for defn
term 4
def 4 line1
def 4 line2

$o = $=pod[++$p];
isa-ok $o, 'Pod::Defn';
is $o.term, 'term 4';
isa-ok $o.contents[0], 'Pod::Block::Para';
is $o.contents[0].contents[0], 'def 4 line1 def 4 line2';

# paragraph, uses %config
=for defn :numbered(0)
term 5
def 5 line1
def 5 line2

$o = $=pod[++$p];
isa-ok $o, 'Pod::Defn';
is $o.config<numbered>, 0;
is $o.term, 'term 5';
isa-ok $o.contents[0], 'Pod::Block::Para';
is $o.contents[0].contents[0], 'def 5 line1 def 5 line2';

# delimited, uses %config, multiple paragraphs
=begin defn :numbered
term 6
def 6 line 1

def 6 line 2 after blank line
=end defn

$o = $=pod[++$p];
isa-ok $o, 'Pod::Defn';
is $o.config<numbered>, True;
is $o.term, 'term 6';
isa-ok $o.contents[0], 'Pod::Block::Para';
is $o.contents[0].contents[0], 'def 6 line 1';
isa-ok $o.contents[1], 'Pod::Block::Para';
is $o.contents[1].contents[0], 'def 6 line 2 after blank line';