Skip to content

Commit ebcff21

Browse files
tonycoznwc10
authored andcommitted
test the new flags behaviour, to prevent accidental breakage
1 parent 6437968 commit ebcff21

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5995,6 +5995,7 @@ t/op/sub.t See if subroutines work
59955995
t/op/sub_lval.t See if lvalue subroutines work
59965996
t/op/substr.t See if substr works
59975997
t/op/substr_thr.t See if substr works in another thread
5998+
t/op/svflags.t See if POK is set as expected.
59985999
t/op/svleak.pl Test file for svleak.t
59996000
t/op/svleak.t See if stuff leaks SVs
60006001
t/op/switch.t See if switches (given/when) work

t/op/svflags.t

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!./perl
2+
3+
BEGIN {
4+
chdir 't' if -d 't';
5+
require './test.pl';
6+
set_up_inc('../lib');
7+
skip_all("need B, need full perl") if is_miniperl();
8+
}
9+
10+
# Tests the new documented mechanism for determining the original type
11+
# of an SV.
12+
13+
plan tests => 4;
14+
use strict;
15+
use B qw(svref_2object SVf_IOK SVf_NOK SVf_POK);
16+
17+
my $x = 10;
18+
my $xobj = svref_2object(\$x);
19+
is($xobj->FLAGS & (SVf_IOK | SVf_POK), SVf_IOK, "correct base flags on IV");
20+
21+
my $y = $x . "";
22+
23+
is($xobj->FLAGS & (SVf_IOK | SVf_POK), SVf_IOK, "POK not set on IV used as string");
24+
25+
$x = "10";
26+
is($xobj->FLAGS & (SVf_IOK | SVf_POK), SVf_POK, "correct base flags on PV");
27+
28+
$y = $x + 10;
29+
30+
is($xobj->FLAGS & (SVf_IOK | SVf_POK), (SVf_IOK | SVf_POK), "POK still set on PV used as number");

0 commit comments

Comments
 (0)