range.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl
print "1..15\n";
@foo = (1,2,3,4,5,6,7,8,9);
$x = 0;
for (1..100) {
$x += $_;
}
print $x == 5050 ? "ok 5\n" : "not ok 5 $x\n";
$x = 0;
for ((100,2..99,1)) {
$x += $_;
}
print $x == 5050 ? "ok 6\n" : "not ok 6 $x\n";
@x = 'A'..'ZZ';
print @x == 27 * 26 ? "ok 8\n" : "not ok 8\n";
@x = '09' .. '08'; # should produce '09', '10',... '99' (strange but true)
print "ok 9\n";
# same test with foreach (which is a separate implementation)
@y = ();
foreach ('09'..'08') {
}
print "ok 10\n";
# check bounds
@a = 0x7ffffffe..0x7fffffff;
print "ok 11\n";
@a = -0x7fffffff..-0x7ffffffe;
print "ok 12\n";
# check magic
{
my $bad = 0;
my $x = 'a-e';
}
# Should use magical autoinc only when both are strings
print "ok 14\n";
for my $x ("0"..-1) {
print "not ";
}
print "ok 15\n";