This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/inc.t: Test incrementing UV with and without upgrading to NV.
[perl5.git] / t / bigmem / vec.t
1 #!perl
2 BEGIN {
3     chdir 't' if -d 't';
4     @INC = "../lib";
5 }
6
7 use strict;
8 require './test.pl';
9 use Config qw(%Config);
10
11 $ENV{PERL_TEST_MEMORY} >= 1
12     or skip_all("Need ~1Gb for this test");
13 $Config{ptrsize} >= 8
14     or skip_all("Need 64-bit pointers for this test");
15
16 plan(7);
17
18 # RT #111730: Negative offset to vec in lvalue context
19
20 my $v = "";
21 ok(scalar eval { vec($v, 0x80000000, 1) = 1 }, "set a bit at a large offset");
22 ok(vec($v, 0x80000000, 1), "check a bit at a large offset");
23
24 ok(scalar eval { vec($v, 0x100000000, 1) = 1 },
25    "set a bit at a larger offset");
26 ok(vec($v, 0x100000000, 1), "check a bit at a larger offset");
27
28 # real out of range values
29 ok(!eval { vec($v, -0x80000000, 1) = 1 },
30    "shouldn't be able to set at a large negative offset");
31 ok(!eval { vec($v, -0x100000000, 1) = 1 },
32    "shouldn't be able to set at a larger negative offset");
33
34 ok(!vec($v, 0, 1), "make sure we didn't wrap");