xref: /openbsd-src/gnu/usr.bin/perl/t/bigmem/pos.t (revision b8851fcc53cbe24fd20b090f26dd149e353f6174)
16fb12b70Safresh1#!perl
26fb12b70Safresh1BEGIN {
3*b8851fccSafresh1    chdir 't' if -d 't';
4*b8851fccSafresh1    @INC = "../lib";
56fb12b70Safresh1    require './test.pl';
66fb12b70Safresh1}
76fb12b70Safresh1
86fb12b70Safresh1use Config qw(%Config);
96fb12b70Safresh1
106fb12b70Safresh1$ENV{PERL_TEST_MEMORY} >= 2
116fb12b70Safresh1    or skip_all("Need ~2Gb for this test");
126fb12b70Safresh1$Config{ptrsize} >= 8
136fb12b70Safresh1    or skip_all("Need 64-bit pointers for this test");
146fb12b70Safresh1
156fb12b70Safresh1plan(3);
166fb12b70Safresh1
176fb12b70Safresh1# [perl #116907]
186fb12b70Safresh1# ${\2} to defeat constant folding, which in this case actually slows
196fb12b70Safresh1# things down
206fb12b70Safresh1my $x=" "x(${\2}**31+20);
216fb12b70Safresh1pos $x = 2**31-5;
226fb12b70Safresh1is pos $x, 2147483643, 'setting pos on large string';
236fb12b70Safresh1pos $x += 10;
246fb12b70Safresh1is pos $x, 2147483653, 'reading lvalue pos after setting it > 2**31';
256fb12b70Safresh1is scalar(pos $x), 2147483653, 'reading it with pos() in rvalue context';
26