Skip to content

Commit

Permalink
[coverage] cover all non-CAPS methods in Any.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Sep 18, 2016
1 parent a176e08 commit e427332
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
47 changes: 47 additions & 0 deletions S29-any/deg-trans.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use v6;
use Test;

plan 33;

# Degenerate and Transformative Any methods
# -----
# This file covers methods on Any that are normally provided by other types
# and the Any version simply translates the object to that type, throws,
# or returns a degenerate result

{ # coverage; 2016-09-18
throws-like { 42.classify }, Exception, '.classify() on Any throws';
throws-like { 42.classify: * }, Exception, '.classify(*) on Any throws';
throws-like { 42.categorize }, Exception, '.categorize() on Any throws';
throws-like { 42.categorize: * }, Exception, '.categorize(*) on Any throws';

throws-like { 42.Map }, X::Hash::Store::OddNumber, '.Map [odd num of els]';
is-deeply (42, 'a').Map, Map.new(("42" => "a")), '.Map [even num of els]';

is-deeply Any.kv, (), 'Any:U.kv returns empty list';
is-deeply Any.pairs, (), 'Any:U.pairs returns empty list';
is-deeply Any.antipairs, (), 'Any:U.antipairs returns empty list';

my @exp = 1, 2, "foo";
my class AnyU {
method append (*@got) { is-deeply @got, @exp, 'append called' ; 1; }
method prepend (*@got) { is-deeply @got, @exp, 'prepend called'; 1; }
method unshift (*@got) { is-deeply @got, @exp, 'unshift called'; 1; }
method push (*@got) { is-deeply @got, @exp, 'push called' ; 1; }
}
my class AnyUPos is AnyU does Positional {}

for <append prepend unshift push> -> $m {
is AnyU."$m"( @exp), 1, ".$m on custom Any:U";
is AnyUPos."$m"(@exp), 1, ".$m on custom Any:U does Positonal";
}

is-deeply $ .unshift(@exp), [@exp,], '.unshift on Any:U';
is-deeply $ .prepend(@exp), @exp, '.prepend on Any:U';
is-deeply $ .append( @exp), @exp, '.append on Any:U';
is-deeply $ .push( @exp), [@exp,], '.push on Any:U';
is-deeply @ .prepend(@exp), @exp, '.prepend on Any:U [Positional]';
is-deeply @ .append( @exp), @exp, '.append on Any:U [Positional]';
is-deeply @ .unshift(@exp), [@exp,], '.unshift on Any:U [Positional]';
is-deeply @ .push( @exp), [@exp,], '.push on Any:U [Positional]';
}
7 changes: 1 addition & 6 deletions S32-list/categorize.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Test;

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

plan 30;
plan 28;

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

{ # coverage; 2016-09-18
throws-like { 42.categorize }, Exception, '.categorize() on Any throws';
throws-like { 42.categorize: * }, Exception, '.categorize(*) on Any throws';
}

# vim: ft=perl6
7 changes: 1 addition & 6 deletions S32-list/classify.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Test;

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

plan 43;
plan 41;

{
my @list = 1, 2, 3, 4;
Expand Down Expand Up @@ -135,9 +135,4 @@ subtest 'classify works with Junctions' => {
%expected, 'sub form';
}

{ # coverage; 2016-09-18
throws-like { 42.classify }, Exception, '.classify() on Any throws';
throws-like { 42.classify: * }, Exception, '.classify(*) on Any throws';
}

# vim: ft=perl6

0 comments on commit e427332

Please sign in to comment.