Skip to content

Commit cff801d

Browse files
committed
Add leading/trailing checks to why-both.t
1 parent 2439f03 commit cff801d

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

S26-documentation/why-both.t

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use Test;
2-
plan 14;
2+
plan 36;
33

44
#| simple case
55
class Simple {
66
#= not so simple now!
77
}
88

9-
is Simple.WHY.content, "simple case\nnot so simple now!";
9+
is Simple.WHY.content, "simple case\nnot so simple now!";
10+
is Simple.WHY.leading, "simple case";
11+
is Simple.WHY.trailing, "not so simple now!";
1012
is ~Simple.WHY, "simple case\nnot so simple now!", 'stringifies correctly';
1113

1214
#| a module
@@ -22,18 +24,28 @@ module foo {
2224
}
2325
}
2426

25-
is foo.WHY.content, "a module\nmoar module stuff";
26-
is foo::bar.WHY.content, "a package\nmore package stuff";
27-
is foo::bar::baz.WHY.content, "and a class\nmore class stuff";
27+
is foo.WHY.content, "a module\nmoar module stuff";
28+
is foo.WHY.leading, "a module";
29+
is foo.WHY.trailing, "moar module stuff";
30+
is foo::bar.WHY.content, "a package\nmore package stuff";
31+
is foo::bar.WHY.leading, "a package";
32+
is foo::bar.WHY.trailing, "more package stuff";
33+
is foo::bar::baz.WHY.content, "and a class\nmore class stuff";
34+
is foo::bar::baz.WHY.leading, "and a class";
35+
is foo::bar::baz.WHY.trailing, "more class stuff";
2836

2937
#| yellow
3038
sub marine {}
3139
#= submarine
32-
is &marine.WHY.content, "yellow\nsubmarine";
40+
is &marine.WHY.content, "yellow\nsubmarine";
41+
is &marine.WHY.leading, "yellow";
42+
is &marine.WHY.trailing, "submarine";
3343

3444
#| pink
3545
sub panther {} #= panther
36-
is &panther.WHY.content, "pink\npanther";
46+
is &panther.WHY.content, "pink\npanther";
47+
is &panther.WHY.leading, "pink";
48+
is &panther.WHY.trailing, "panther";
3749

3850
#| a sheep
3951
class Sheep {
@@ -46,12 +58,16 @@ class Sheep {
4658

4759
is Sheep.WHY.content, 'a sheep';
4860
is Sheep.^attributes.grep({ .name eq '$!wool' })[0].WHY, "usually white\nnot very dirty";
61+
is Sheep.^attributes.grep({ .name eq '$!wool' })[0].WHY.leading, "usually white";
62+
is Sheep.^attributes.grep({ .name eq '$!wool' })[0].WHY.trailing, "not very dirty";
4963
is Sheep.^find_method('roar').WHY.content, 'not too scary';
5064

5165
#| trailing space here
5266
sub third {}
5367
#= leading space here
54-
is &third.WHY.content, "trailing space here\nleading space here";
68+
is &third.WHY.content, "trailing space here\nleading space here";
69+
is &third.WHY.leading, "trailing space here";
70+
is &third.WHY.trailing, "leading space here";
5571

5672
sub has-parameter(
5773
#| before
@@ -60,13 +76,17 @@ sub has-parameter(
6076
) {}
6177

6278
is &has-parameter.signature.params[0].WHY, "before\nafter";
79+
is &has-parameter.signature.params[0].WHY.leading, "before";
80+
is &has-parameter.signature.params[0].WHY.trailing, "after";
6381

6482
sub has-parameter-as-well(
6583
#| preceding
6684
Str $param #= following
6785
) {}
6886

6987
is &has-parameter-as-well.signature.params[0].WHY, "preceding\nfollowing";
88+
is &has-parameter-as-well.signature.params[0].WHY.leading, "preceding";
89+
is &has-parameter-as-well.signature.params[0].WHY.trailing, "following";
7090

7191
sub so-many-params(
7292
#| next param
@@ -75,3 +95,5 @@ sub so-many-params(
7595
) {}
7696

7797
is &so-many-params.signature.params[0].WHY, "next param\nfirst param";
98+
is &so-many-params.signature.params[0].WHY.leading, "next param";
99+
is &so-many-params.signature.params[0].WHY.trailing, "first param";

0 commit comments

Comments
 (0)