This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
rt #72398 - get magic before downgrading in SvPVbyte()
[perl5.git] / ext / XS-APItest / t / svpv_magic.t
1 #!perl -w
2 BEGIN {
3     require '../../t/test.pl';
4     plan(5);
5     use_ok('XS::APItest')
6 };
7
8 $b = "\303\244"; # or encode_utf8("\x{e4}");
9
10 is(XS::APItest::first_byte($b), 0303,
11     "test function first_byte works");
12
13 $b =~ /(.)/;
14 is(XS::APItest::first_byte($1), 0303,
15     "matching works correctly");
16
17 $a = qq[\x{263a}]; # utf8 flag is set
18
19 $a =~ s/(.)/$1/;      # $1 now has the utf8 flag set too
20 $b =~ /(.)/;          # $1 shouldn't have the utf8 flag anymore
21
22 is(XS::APItest::first_byte("$1"), 0303,
23     "utf8 flag in match fetched correctly when stringified first");
24
25 $a =~ s/(.)/$1/;      # $1 now has the utf8 flag set too
26 $b =~ /(.)/;          # $1 shouldn't have the utf8 flag anymore
27
28 is(eval { XS::APItest::first_byte($1) } || $@, 0303,
29     "utf8 flag fetched correctly without stringification");