Acme-Pythonic

 view release on metacpan or  search on metacpan

t/if.t  view on Meta::CPAN

# -*- Mode: Python -*-

use strict;
use warnings;

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

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

my $x = 1
if $x:
    $x += 1
    $x *= 3

is($x, 6)

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

if $x == 6 ? 1 : 0:
    $x *= 2

is($x, 12)

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

my $z = 9
if $z:
    $z = 3
else:
    $z = 1

is($z, 3)

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

if $z == 2:
    $z = $z % 7
elsif $z == 1:
    $z = "foo"
    $z .= q(bar)
    $z =~ s/foreach foo in \@bar//
elsif $z == 3:
    $z = $z % 2
    $z *= 4
    # comment
else:
    $z = 21

is($z, 4)

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

do:
    $z *= 2
    $z += 1
if $z == 4

is $z, 9

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

package foo
our $bar = 3
$bar = 5 if keys %foo::
Test::More::is($bar, 5)
package main



( run in 0.690 second using v1.01-cache-2.11-cpan-8450f2e95f3 )