view t/02-rakudo/08-repeat.t @ 0:c341f82e7ad7 default tip

Rakudo branch in cr.ie.u-ryukyu.ac.jp
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 26 Dec 2019 16:50:27 +0900
parents
children
line wrap: on
line source

use v6;
use Test;

plan 5;

# RT #127971,130924
{
    dies-ok { my $a = "a" x 2**30; my $b = "b" x 2**30; my $c = $a ~ $b; my $d = $b ~ $a; my $e = $c ~ $d; },
        'concatenating strings with `~` that would create a too large result dies';
    dies-ok { (('a' x 1000000) x 1000000) },
        'repeating strings with `x` that would create a too large result dies';
}

# RT #128035
#?rakudo.jvm skip 'OutOfMemoryError: Java heap space'
{
    my $a;
    lives-ok({ $a = 'a' x 1073741824 }, 'repeat count equal to the NQP limit works');
    is($a.chars, 1073741824, 'correct result for count equal to the NQP limit');

    throws-like({ $a = 'a' x 9999999999999999999 }, Exception, 'too large repeat count throws instead of going negative');
}