Skip to content

Commit acb9760

Browse files
committed
GLR-ify squish.t
1 parent a554c9f commit acb9760

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

S32-list/squish.t

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 37;
5+
plan 38;
66

77
=begin description
88
@@ -13,9 +13,9 @@ This test tests the C<squish> builtin and .squish method on Any/List.
1313
#?niecza skip 'NYI'
1414
{
1515
my @array = <a b b c d e f f a>;
16-
is-deeply @array.squish, <a b c d e f a>.list.item,
16+
is-deeply @array.squish.list, <a b c d e f a>,
1717
"method form of squish works";
18-
is-deeply squish(@array), <a b c d e f a>.list.item,
18+
is-deeply squish(@array).list, <a b c d e f a>,
1919
"subroutine form of squish works";
2020
is-deeply @array .= squish, [<a b c d e f a>],
2121
"inplace form of squish works";
@@ -24,8 +24,8 @@ This test tests the C<squish> builtin and .squish method on Any/List.
2424
} #4
2525

2626
{
27-
is-deeply squish(Any,'a', 'b', 'b', 'c', 'd', 'e', 'f', 'f', 'a'),
28-
(Any, <a b c d e f a>.list).list.item,
27+
is-deeply squish(Any,'a', 'b', 'b', 'c', 'd', 'e', 'f', 'f', 'a').list,
28+
(flat Any, <a b c d e f a>),
2929
'slurpy subroutine form of squish works';
3030
} #1
3131

@@ -50,17 +50,18 @@ This test tests the C<squish> builtin and .squish method on Any/List.
5050

5151
#?niecza skip 'NYI'
5252
{
53-
my @a := squish( 1..Inf );
54-
is @a[3], 4, "make sure squish is lazy";
53+
my \a := squish( 1..Inf );
54+
ok a.is-lazy, 'squish knows itself to be lazy';
55+
is a[3], 4, '... can access elements from lazy iterator';
5556
} #1
5657

5758
#?niecza skip 'NYI'
5859
{
5960
my @array = <a b bb c d e f f a>;
6061
my $as = *.substr: 0,1;
61-
is-deeply @array.squish(:$as), <a b c d e f a>.list.item,
62+
is-deeply @array.squish(:$as).list, <a b c d e f a>,
6263
"method form of squish with :as works";
63-
is-deeply squish(@array,:$as), <a b c d e f a>.list.item,
64+
is-deeply squish(@array,:$as).list, <a b c d e f a>,
6465
"subroutine form of squish with :as works";
6566
is-deeply @array .= squish(:$as), [<a b c d e f a>],
6667
"inplace form of squish with :as works";
@@ -72,14 +73,14 @@ This test tests the C<squish> builtin and .squish method on Any/List.
7273
{
7374
my @rt124204 = ('', '', Any, Any);
7475
#?rakudo todo 'RT #124204'
75-
is-deeply @rt124204.squish(:as(-> $x {$x})), ('', Any).list.item,
76+
is-deeply @rt124204.squish(:as(-> $x {$x})).list, ('', Any),
7677
"method form of squish with :as does not needlessly stringify";
77-
is-deeply @rt124204.squish, ('', Any).list.item,
78+
is-deeply @rt124204.squish.list, ('', Any),
7879
"method form of squish without :as does not needlessly stringify";
7980
#?rakudo todo 'RT #124204'
80-
is-deeply @rt124204.squish(:as(-> $x {$x}), :with({$^b === $^a})), ('', Any).list.item,
81+
is-deeply @rt124204.squish(:as(-> $x {$x}), :with({$^b === $^a})).list, ('', Any),
8182
"method form of squish with :as and :with does not needlessly stringify";
82-
is-deeply @rt124204.squish(:with({$^b === $^a})), ('', Any).list.item,
83+
is-deeply @rt124204.squish(:with({$^b === $^a})).list, ('', Any),
8384
"method form of squish with :with does not needlessly stringify";
8485
} #4
8586

@@ -88,19 +89,19 @@ This test tests the C<squish> builtin and .squish method on Any/List.
8889
{
8990
my @rt124205 = <a a>;
9091

91-
is-deeply @rt124205.squish(:as(-> $x {1}), :with(-> $a, $b {1})), <a>.list.item,
92+
is-deeply @rt124205.squish(:as(-> $x {1}), :with(-> $a, $b {1})).list, <a>.list,
9293
"method form of squish with :as and :with always returns at least the first element";
93-
is-deeply @rt124205.squish(:with(-> $a, $b {1})), <a>.list.item,
94+
is-deeply @rt124205.squish(:with(-> $a, $b {1})).list, <a>.list,
9495
"method form of squish with :with always returns at least the first element";
9596

9697
# somewhat more real-world examples:
9798

9899
my @rt124205_b = '', '', <b b B B>;
99100

100-
is-deeply @rt124205_b.squish(:with(*.Str eq *.Str)), ('', 'b', 'B').list.item,
101+
is-deeply @rt124205_b.squish(:with(*.Str eq *.Str)).list, ('', 'b', 'B'),
101102
"method form of squish with :with preserves the first element even if it stringifies to ''";
102103

103-
is-deeply @rt124205_b.squish(:as(*.Str), :with(&infix:<eq>)), ('', 'b', 'B').list.item,
104+
is-deeply @rt124205_b.squish(:as(*.Str), :with(&infix:<eq>)).list, ('', 'b', 'B'),
104105
"method form of squish with :as and :with preserves the first element even if it stringifies to ''";
105106

106107
} #4
@@ -109,9 +110,9 @@ This test tests the C<squish> builtin and .squish method on Any/List.
109110
{
110111
my @array = <a aa b bb c d e f f a>;
111112
my $with = { substr($^a,0,1) eq substr($^b,0,1) }
112-
is-deeply @array.squish(:$with), <a b c d e f a>.list.item,
113+
is-deeply @array.squish(:$with).list, <a b c d e f a>,
113114
"method form of squish with :with works";
114-
is-deeply squish(@array,:$with), <a b c d e f a>.list.item,
115+
is-deeply squish(@array,:$with).list, <a b c d e f a>,
115116
"subroutine form of squish with :with works";
116117
is-deeply @array .= squish(:$with), [<a b c d e f a>],
117118
"inplace form of squish with :with works";
@@ -124,9 +125,9 @@ This test tests the C<squish> builtin and .squish method on Any/List.
124125
my @array = <a aa b bb c d e f f a>;
125126
my $as = *.substr(0,1).ord;
126127
my $with = &[==];
127-
is-deeply @array.squish(:$as, :$with), <a b c d e f a>.list.item,
128+
is-deeply @array.squish(:$as, :$with).list, <a b c d e f a>,
128129
"method form of squish with :as and :with works";
129-
is-deeply squish(@array,:$as, :$with), <a b c d e f a>.list.item,
130+
is-deeply squish(@array,:$as, :$with).list, <a b c d e f a>,
130131
"subroutine form of squish with :as and :with works";
131132
is-deeply @array .= squish(:$as, :$with), [<a b c d e f a>],
132133
"inplace form of squish with :as and :with works";
@@ -138,9 +139,9 @@ This test tests the C<squish> builtin and .squish method on Any/List.
138139
{
139140
my @array = ({:a<1>}, {:a<1>}, {:b<1>});
140141
my $with = &[eqv];
141-
is-deeply @array.squish(:$with), ({:a<1>}, {:b<1>}).list.item,
142+
is-deeply @array.squish(:$with).list, ({:a<1>}, {:b<1>}),
142143
"method form of squish with [eqv] and objects works";
143-
is-deeply squish(@array,:$with), ({:a<1>}, {:b<1>}).list.item,
144+
is-deeply squish(@array,:$with).list, ({:a<1>}, {:b<1>}),
144145
"subroutine form of squish with [eqv] and objects works";
145146
is-deeply @array .= squish(:$with), [{:a<1>}, {:b<1>}],
146147
"inplace form of squish with [eqv] and objects works";
@@ -152,11 +153,11 @@ This test tests the C<squish> builtin and .squish method on Any/List.
152153
{
153154
my $a = <a b b c>;
154155
$a .= squish;
155-
is-deeply( $a, <a b c>.list.item, '.= squish in sink context works on $a' );
156+
is-deeply( $a.list, <a b c>, '.= squish in sink context works on $a' );
156157
my @a = <a b b c>;
157158
@a .= squish;
158159
is-deeply( @a, [<a b c>], '.= squish in sink context works on @a' );
159160
} #2
160161

161-
is ((3,3,1),(1,2),(1,2)).squish, '3 3 1 1 2', ".squish doesn't flatten";
162+
is ((3,3,1),(1,2),(1,2)).squish.list.Str, '3 3 1 1 2', ".squish doesn't flatten";
162163
# vim: ft=perl6

0 commit comments

Comments
 (0)