Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tests of sequence operator with limit function having arity > 1
Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information
dwhipp authored and moritz committed Feb 25, 2011
1 parent fbafcc2 commit 9100295
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions S03-sequence/limit-arity-2-or-more.t
@@ -0,0 +1,37 @@
use v6;
use Test;

# L<S03/List infix precedence/"the sequence operator">

plan 8;

# sequence with a limit function of arity 2

is (8,*/2 ... abs(*-*) < 2).join(', '), '8, 4, 2, 1', 'arity-2 convergence limit';
is (8,*/2 ...^ abs(*-*) < 2).join(', '), '8, 4, 2', 'arity-2 excluded convergence limit';

# sequence with a limit function of arity 3

{
my $i = -5;
my @seq = { ++$i; $i**3-9*$i } ... { ($^a-$^b) > ($^b-$^c) };
is @seq.join(', '), '-28, 0, 10, 8, 0, -8, -10', 'arity-3 curvature limit';
}

{
my $i = -5;
my @seq = { ++$i; $i**3-9*$i } ...^ { ($^a-$^b) > ($^b-$^c) };
is @seq.join(', '), '-28, 0, 10, 8, 0, -8', 'arity-3 excluded curvature limit';
}

# limit functions that limit sequence exactly at arity limit

is (2, 1, 0.5 ... abs(*-*) < 2).join(', '), '2, 1', 'ASAP arity-2 convergence limit';
is (2, 1, 0.5 ...^ abs(*-*) < 2).join(', '), '2', 'ASAP arity-2 excluded convergence limit';

# limit function that accepts any number of args

is (1 ... { @_ eq "1 2 3" }).join(', '), '1, 2, 3', 'arity-Inf limit';
is (1 ...^ { @_ eq "1 2 3" }).join(', '), '1, 2', 'arity-Inf excluded limit';

done;

0 comments on commit 9100295

Please sign in to comment.