xref: /openbsd/gnu/usr.bin/perl/t/bigmem/pos.t (revision 5af055cd)
1#!perl
2BEGIN {
3    chdir 't';
4    unshift @INC, "../lib";
5    require './test.pl';
6}
7
8use Config qw(%Config);
9
10$ENV{PERL_TEST_MEMORY} >= 2
11    or skip_all("Need ~2Gb for this test");
12$Config{ptrsize} >= 8
13    or skip_all("Need 64-bit pointers for this test");
14
15plan(3);
16
17# [perl #116907]
18# ${\2} to defeat constant folding, which in this case actually slows
19# things down
20my $x=" "x(${\2}**31+20);
21pos $x = 2**31-5;
22is pos $x, 2147483643, 'setting pos on large string';
23pos $x += 10;
24is pos $x, 2147483653, 'reading lvalue pos after setting it > 2**31';
25is scalar(pos $x), 2147483653, 'reading it with pos() in rvalue context';
26