Acme-Pythonic

 view release on metacpan or  search on metacpan

t/jlines.t  view on Meta::CPAN

# -*- Mode: Python -*-

use warnings;

use Test::More 'no_plan';
use Acme::Pythonic debug => 0;

# ----------------------------------------------------------------------

sub foo:
    my $i = \
       7
    return $i

is foo, 7

# ----------------------------------------------------------------------

$n = 0
$n = $n + \    # this is a comments but it should not matter
   4 \     # check this one too
                        + 5 # now this ends the sum

is $n, 9

# ----------------------------------------------------------------------

sub mygrep (&@):
    my $code = shift
    my @result         # comment ending in a backslash \
    foreach @_:
        push @result, \
             $_ \      # comment here as well, we support this from 0.20
             if \
             &$code
    return @result

my @array = mygrep { $_ % 2 } 0..5
is_deeply \@array, [1, 3, 5]

# ----------------------------------------------------------------------

my $coderef = sub:   # do not be fooled by this , #, we're not joining
    my $n = \
       shift
    $n *= \
       3

is $coderef->(3), 9

# ----------------------------------------------------------------------

my $fib
$fib = sub:
    my $n = shift
    die if $n < 0
    $n < 2 ? \
       $n : \
       $fib->($n - 1) \
       + $fib->\
       ($n - 2)

is $fib->(5), 5

# ----------------------------------------------------------------------



( run in 2.704 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )