Skip to content

Commit e427332

Browse files
committed
[coverage] cover all non-CAPS methods in Any.pm
1 parent a176e08 commit e427332

File tree

3 files changed

+49
-12
lines changed

3 files changed

+49
-12
lines changed

S29-any/deg-trans.t

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use v6;
2+
use Test;
3+
4+
plan 33;
5+
6+
# Degenerate and Transformative Any methods
7+
# -----
8+
# This file covers methods on Any that are normally provided by other types
9+
# and the Any version simply translates the object to that type, throws,
10+
# or returns a degenerate result
11+
12+
{ # coverage; 2016-09-18
13+
throws-like { 42.classify }, Exception, '.classify() on Any throws';
14+
throws-like { 42.classify: * }, Exception, '.classify(*) on Any throws';
15+
throws-like { 42.categorize }, Exception, '.categorize() on Any throws';
16+
throws-like { 42.categorize: * }, Exception, '.categorize(*) on Any throws';
17+
18+
throws-like { 42.Map }, X::Hash::Store::OddNumber, '.Map [odd num of els]';
19+
is-deeply (42, 'a').Map, Map.new(("42" => "a")), '.Map [even num of els]';
20+
21+
is-deeply Any.kv, (), 'Any:U.kv returns empty list';
22+
is-deeply Any.pairs, (), 'Any:U.pairs returns empty list';
23+
is-deeply Any.antipairs, (), 'Any:U.antipairs returns empty list';
24+
25+
my @exp = 1, 2, "foo";
26+
my class AnyU {
27+
method append (*@got) { is-deeply @got, @exp, 'append called' ; 1; }
28+
method prepend (*@got) { is-deeply @got, @exp, 'prepend called'; 1; }
29+
method unshift (*@got) { is-deeply @got, @exp, 'unshift called'; 1; }
30+
method push (*@got) { is-deeply @got, @exp, 'push called' ; 1; }
31+
}
32+
my class AnyUPos is AnyU does Positional {}
33+
34+
for <append prepend unshift push> -> $m {
35+
is AnyU."$m"( @exp), 1, ".$m on custom Any:U";
36+
is AnyUPos."$m"(@exp), 1, ".$m on custom Any:U does Positonal";
37+
}
38+
39+
is-deeply $ .unshift(@exp), [@exp,], '.unshift on Any:U';
40+
is-deeply $ .prepend(@exp), @exp, '.prepend on Any:U';
41+
is-deeply $ .append( @exp), @exp, '.append on Any:U';
42+
is-deeply $ .push( @exp), [@exp,], '.push on Any:U';
43+
is-deeply @ .prepend(@exp), @exp, '.prepend on Any:U [Positional]';
44+
is-deeply @ .append( @exp), @exp, '.append on Any:U [Positional]';
45+
is-deeply @ .unshift(@exp), [@exp,], '.unshift on Any:U [Positional]';
46+
is-deeply @ .push( @exp), [@exp,], '.push on Any:U [Positional]';
47+
}

S32-list/categorize.t

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use Test;
33

44
# L<S32::Containers/"List"/"=item categorize">
55

6-
plan 30;
6+
plan 28;
77

88
{ # basic categorize with all possible mappers
99
my @list = 29, 7, 12, 9, 18, 23, 3, 7;
@@ -100,9 +100,4 @@ plan 30;
100100
), 'multi-level categorize' );
101101
}
102102

103-
{ # coverage; 2016-09-18
104-
throws-like { 42.categorize }, Exception, '.categorize() on Any throws';
105-
throws-like { 42.categorize: * }, Exception, '.categorize(*) on Any throws';
106-
}
107-
108103
# vim: ft=perl6

S32-list/classify.t

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use Test;
33

44
# L<S32::Containers/"List"/"=item classify">
55

6-
plan 43;
6+
plan 41;
77

88
{
99
my @list = 1, 2, 3, 4;
@@ -135,9 +135,4 @@ subtest 'classify works with Junctions' => {
135135
%expected, 'sub form';
136136
}
137137

138-
{ # coverage; 2016-09-18
139-
throws-like { 42.classify }, Exception, '.classify() on Any throws';
140-
throws-like { 42.classify: * }, Exception, '.classify(*) on Any throws';
141-
}
142-
143138
# vim: ft=perl6

0 commit comments

Comments
 (0)