Skip to content

Commit ae478c6

Browse files
committed
Handle testing Array methods on List/Range similarly
1 parent daaa141 commit ae478c6

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

S02-types/list.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use v6;
22
use Test;
33

4-
plan 59;
4+
plan 61;
55

66
isa-ok (5, 7, 8), List, '(5, 7, 8) is List';
77
is +(5, 7, 8), 3, 'prefix:<+> on a List';
@@ -113,7 +113,7 @@ is $(;).elems, 0, '$(;) parses, and is empty';
113113
}
114114

115115
{
116-
for <push pop shift unshift> -> $method {
116+
for <push pop shift unshift append prepend> -> $method {
117117
throws-like { (1,2,3)."$method"(42) }, X::Immutable,
118118
method => $method,
119119
typename => 'List',

S02-types/range.t

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,13 @@ is(+Range, 0, 'type numification');
9090
{
9191
my $r = 1..5;
9292

93-
throws-like { $r.push(42) }, X::Immutable,
94-
:typename<Range>, :method<push>, 'range is immutable (push)';
95-
throws-like { $r.append(42) }, X::Immutable,
96-
:typename<Range>, :method<append>, 'range is immutable (append)';
97-
throws-like { $r.unshift(42) }, X::Immutable,
98-
:typename<Range>, :method<unshift>, 'range is immutable (unshift)';
99-
throws-like { $r.prepend(42) }, X::Immutable,
100-
:typename<Range>, :method<prepend>, 'range is immutable (prepend)';
101-
throws-like { $r.shift }, X::Immutable,
102-
:typename<Range>, :method<shift>, 'range is immutable (shift)';
103-
throws-like { $r.pop }, X::Immutable,
104-
:typename<Range>, :method<pop>, 'range is immutable (pop)';
93+
for <push pop shift unshift append prepend> -> $method {
94+
throws-like { $r."$method"(42) }, X::Immutable,
95+
method => $method,
96+
typename => 'Range',
97+
"range is immutable ($method)",
98+
;
99+
}
105100

106101
my $s = 1..5;
107102
is $r, $s, 'range has not changed';

0 commit comments

Comments
 (0)