<commit_before>#!perl

# Copyright (C) 2005-2007, The Perl Foundation.
# $Id$

use strict;
use warnings;
use lib qw(t . lib ../lib ../../lib ../../../lib);
use Parrot::Test tests => 3;
use Test::More;

language_output_is( 'punie', <<'CODE', <<'OUT', 'simple loops' );
while (0) {
  print "nok 1\n";
}
print "ok 1\n";

$x = 2;
while($x < 5) {
    print "ok " . $x . "\n";
}
continue {
    $x++;
}

until (1) {
    print "nok 5\n";
}
print "ok " . $x++ . "\n";

until ($x > 10) {
    print "ok " . $x . "\n";
}
continue {
    ++$x;
}

CODE
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
OUT

language_output_is( 'punie', <<'CODE', <<'OUT', 'expr modifiers' );
print "ok 1\n" while 0;

print "ok 2\n";

print "ok 3\n" until 1;<commit_msg>[punie] add tests for while/until condition blocks. + refactor tests a bit.<commit_after>#!perl

# Copyright (C) 2005-2007, The Perl Foundation.
# $Id$

use strict;
use warnings;
use lib qw(t . lib ../lib ../../lib ../../../lib);
use Parrot::Test tests => 5;
use Test::More;

language_output_is( 'punie', <<'CODE', <<'OUT', 'simple loops' );
while (0) {
  print "nok 1\n";
}
print "ok 1\n";


until (1) {
    print "nok 2\n";
}
print "ok 2\n";

CODE
ok 1
ok 2
OUT

language_output_is( 'punie', <<'CODE', <<'OUT', 'loops with a continue block' );
$x = 1;
while($x < 5) {
    print "ok " . $x . "\n";
}
continue {
    $x++;
}

until ($x >= 10) {
    print "ok " . $x . "\n";
}
continue {
    ++$x;
}

CODE
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
OUT

language_output_is( 'punie', <<'CODE', <<'OUT', 'loops with condition blocks' );

$x = 0;
$y = 1;

while { $x; $y; } {
    print "ok 1\n";
    $y = 0;
    $x = 1;
}

until { $x; $y; } {
    print "ok 2\n";
    $x = 0;
    $y = 1;
}

CODE
ok 1
ok 2
OUT

language_output_is( 'punie', <<'CODE', <<'OUT', 'expr modifiers' );
print "ok 1\n" while 0;

print "ok 2\n";

print "ok 3\n" until 1;
{'fraction_non_alphanumeric': 0.22245875465673232, 'fraction_numerical': 0.04204364023416711, 'mean_word_length': 2.622350674373796, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298474', 'n_tokens_mistral': 915, 'n_tokens_neox': 821, 'n_words': 275}