Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check $=pod for trailing comments
  • Loading branch information
hoelzro committed Aug 1, 2014
1 parent 01725c6 commit 503754b
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion S26-documentation/why-trailing.t
@@ -1,10 +1,14 @@
use Test;
plan 85;
plan 108;

my $pod_index = 0;

class Simple {
#= simple case
}

is $=pod[$pod_index++], 'simple case';

is Simple.WHY.contents, 'simple case', 'Class comment';
ok Simple.WHY.WHEREFORE === Simple, 'class WHEREFORE matches';
is Simple.WHY.trailing, 'simple case', 'Class comment';
Expand All @@ -18,6 +22,9 @@ class Outer {
}
}

is $=pod[$pod_index++], 'giraffe';
is $=pod[$pod_index++], 'zebra';

is Outer.WHY.contents, 'giraffe', 'Outer class comment';
ok Outer.WHY.WHEREFORE === Outer, 'outer class WHEREFORE matches';
is Outer.WHY.trailing, 'giraffe', 'Outer class comment';
Expand All @@ -37,6 +44,10 @@ module foo {
}
}

is $=pod[$pod_index++], 'a module';
is $=pod[$pod_index++], 'a package';
is $=pod[$pod_index++], 'and a class';

is foo.WHY.contents, 'a module', 'module comment';
ok foo.WHY.WHEREFORE === foo, 'module WHEREFORE matches';
is foo.WHY.trailing, 'a module', 'module comment';
Expand All @@ -51,13 +62,19 @@ is foo::bar::baz.WHY.trailing, 'and a class', 'module > package > class comment'
ok !foo::bar::baz.WHY.leading.defined;

sub marine {} #= yellow

is $=pod[$pod_index++], 'yellow';

is &marine.WHY.contents, 'yellow', 'sub comment';
ok &marine.WHY.WHEREFORE === &marine, 'sub WHEREFORE matches';
is &marine.WHY.trailing, 'yellow', 'sub comment';
ok !&marine.WHY.leading.defined;

sub panther {}
#= pink

is $=pod[$pod_index++], 'pink';

is &panther.WHY.contents, 'pink', 'sub comment (the remix!)';
ok &panther.WHY.WHEREFORE === &panther, 'sub WHEREFORE matches';
is &panther.WHY.trailing, 'pink', 'sub comment (the remix!)';
Expand All @@ -71,6 +88,10 @@ class Sheep {
#= not too scary
}

is $=pod[$pod_index++], 'a sheep';
is $=pod[$pod_index++], 'usually white';
is $=pod[$pod_index++], 'not too scary';

is Sheep.WHY.contents, 'a sheep', 'class comment (again)';
ok Sheep.WHY.WHEREFORE === Sheep, 'class WHEREFORE matches';
is Sheep.WHY.trailing, 'a sheep', 'class comment (again)';
Expand All @@ -91,6 +112,9 @@ is &routine.WHY.defined, False, 'lack of sub comment';

our sub oursub {}
#= our works too

is $=pod[$pod_index++], 'our works too';

is &oursub.WHY, 'our works too', 'works for our subs';
ok &oursub.WHY.WHEREFORE === &oursub, 'our sub WHEREFORE matches';
is &oursub.WHY.trailing, 'our works too', 'works for our subs';
Expand All @@ -103,6 +127,10 @@ sub one {}

sub two {}
#= two

is $=pod[$pod_index++], 'one';
is $=pod[$pod_index++], 'two';

is &one.WHY.contents, 'one', 'another sub comment';
ok &one.WHY.WHEREFORE === &one, 'sub WHEREFORE matches';
is &one.WHY.trailing, 'one', 'another sub comment';
Expand All @@ -118,6 +146,9 @@ sub first {}
sub second {}
#= that will break

is $=pod[$pod_index++], 'that will break';
is $=pod[$pod_index++], 'that will break';

is &first.WHY.contents, 'that will break', 'even more sub comments!';
ok &first.WHY.WHEREFORE === &first, 'sub WHEREFORE matches';
is &first.WHY.trailing, 'that will break', 'even more sub comments!';
Expand All @@ -129,6 +160,9 @@ ok !&second.WHY.leading.defined;

sub third {}
#= leading space here

is $=pod[$pod_index++], 'leading space here';

is &third.WHY.contents, 'leading space here', 'sub comment - leading space';
ok &third.WHY.WHEREFORE === &third, 'sub WHEREFORE matches';
is &third.WHY.trailing, 'leading space here', 'sub comment - leading space';
Expand All @@ -139,6 +173,8 @@ sub has-parameter(
#= documented
) {}

is $=pod[$pod_index++], 'documented';

my $param = &has-parameter.signature.params[0];
is $param.WHY, 'documented', 'parameter comment';
ok $param.WHY.WHEREFORE === $param, 'param WHEREFORE matches';
Expand All @@ -149,6 +185,8 @@ sub has-parameter-as-well(
Str $param #= documented as well
) {}

is $=pod[$pod_index++], 'documented as well';

$param = &has-parameter-as-well.signature.params[0];
is $param.WHY, 'documented as well', 'parameter comment - same line';
ok $param.WHY.WHEREFORE === $param, 'param WHEREFORE matches';
Expand All @@ -160,6 +198,8 @@ sub so-many-params(
Int $other-param
) {}

is $=pod[$pod_index++], 'first param';

$param = &so-many-params.signature.params[0];
is $param.WHY, 'first param', 'parameter comment - same line, but after comma';
ok $param.WHY.WHEREFORE === $param, 'param WHEREFORE matches';
Expand All @@ -174,6 +214,8 @@ sub has-anon-param(
#= trailing
) {}

is $=pod[$pod_index++], 'trailing';

$param = &has-anon-param.signature.params[0];

is $param.WHY, 'trailing', 'anonymous parameters should work';
Expand All @@ -186,5 +228,9 @@ class DoesntMatter {
) {}
}

is $=pod[$pod_index++], 'invocant comment';

$param = DoesntMatter.^find_method('m').signature.params[0];
is $param.WHY, 'invocant comment', 'invocant comments should work';

is $=pod.elems, $pod_index;

0 comments on commit 503754b

Please sign in to comment.