Skip to content

Commit

Permalink
Add tests for List.tail()
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 26, 2015
1 parent d430474 commit b599905
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions S32-list/tail.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 19;
plan 24;

=begin description
Expand All @@ -12,18 +12,32 @@ This test tests the C<tail> builtin.

{
my $list = <a b b c d e b b e b b f b>;
is $list.tail(5).List, <e b b f b>, "List.tail works";
is $list.tail.List, ("b",), "List.tail works";
my @array = <a b b c d e b b e b b f b>;
is @array.tail(5).List, <e b b f b>, "Array.tail works";
my $scalar = 42;
is $scalar.tail(5).List, (42,), "Scalar.tail works";
is $scalar.tail.List, (42,), "Scalar.tail works";
my $range = ^10;
is $range.tail(5).List, (5,6,7,8,9), "Range.tail works";
throws-like { ^Inf .tail(5) }, X::Cannot::Lazy,
is $range.tail.List, (9,), "Range.tail works";
throws-like { ^Inf .tail }, X::Cannot::Lazy,
:action<tail>,
'Range.tail on lazy list does not work';
} #5

{
my $list = <a b b c d e b b e b b f b>;
is $list.tail(5).List, <e b b f b>, "List.tail(5) works";
my @array = <a b b c d e b b e b b f b>;
is @array.tail(5).List, <e b b f b>, "Array.tail(5) works";
my $scalar = 42;
is $scalar.tail(5).List, (42,), "Scalar.tail(5) works";
my $range = ^10;
is $range.tail(5).List, (5,6,7,8,9), "Range.tail(5) works";
throws-like { ^Inf .tail(5) }, X::Cannot::Lazy,
:action<tail>,
'Range.tail(5) on lazy list does not work';
} #5

{
for 0, -1 {
my $list = <a b b c d e b b e b b f b>;
Expand Down

0 comments on commit b599905

Please sign in to comment.