Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 50 lines (34 sloc) 1.114 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!./parrot nqp.pbc

# combination of conditional modifier and loop modifier

plan(11);

my $a; my $s;


$a := 0; $s := 0;
$s := 5 if $a > 7 while $a++ < 9;
ok( $s == 5 && $a == 10, 'true if + while');

$a := 0; $s := 0;
$s := 5 if $a > 17 while $a++ < 9;
ok( $s == 0 && $a == 10, 'false if + while');

$a := 0; $s := 0;
$s := 5 if $a > 7 until $a++ > 9;
ok( $s == 5 && $a == 11, 'true if + until');

$a := 0; $s := 0;
$s := 5 if $a > 17 until $a++ > 9;
ok( $s == 0 && $a == 11, 'false if + until');

$a := 0; $s := 0;
$s := 5 unless $a > 0 while $a++ < 9;
ok( $s == 0 && $a == 10, 'true unless + while');

$a := 0; $s := 0;
$s := 5 unless $a < 0 while $a++ < 9;
ok( $s == 5 && $a == 10, 'false unless + while');

$a := 0; $s := 0;
$s := 5 if $a > 0 until $a++ > 9;
ok( $s == 5 && $a == 11, 'true if + until');

$a := 0; $s := 0;
$s := 5 if $a < 0 until $a++ > 9;
ok( $s == 0 && $a == 11, 'false if + until');

# Ensure that close curly can end a statement
{ ok(1, "correct parse"); $a := 10; }
while $a == 10 { ok($a == 10, 'while still works'); $a++; }

$a := 1;
$a := $a * $_ for <1 2 3>;
ok( $a == 6 , 'for');

Something went wrong with that request. Please try again.