Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; |