summaryrefslogtreecommitdiff
path: root/ext/XS-APItest/t/pmflag.t
blob: 269b6bc64bbf4cc421ff06d122a0afb81da25460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!perl
use strict;
use Test::More 'no_plan';

my @warnings;
$SIG{__WARN__} = sub {
    push @warnings, "@_";
};

use XS::APItest 'pmflag';

foreach (["\0", 0],
	 ['Q', 0],
	 ['c', 0x00004000],
	) {
    my ($char, $val) = @$_;
    my $ord = ord $char;
    foreach my $before (0, 1) {
	my $got = pmflag($ord, $before);
	is($got, $before | $val, "Flag $ord, before $before");
	is(@warnings, 1);
	like($warnings[0],
	     qr/^Perl_pmflag\(\) is deprecated, and will be removed from the XS API/);
	@warnings = ();

	no warnings 'deprecated';

	$got = pmflag($ord, $before);
	is($got, $before | $val, "Flag $ord, before $before");
	is(@warnings, 0);
	@warnings = ();

	use warnings;
	$got = pmflag($ord, $before);
	is($got, $before | $val, "Flag $ord, before $before");
	is(@warnings, 1);
	like($warnings[0],
	     qr/^Perl_pmflag\(\) is deprecated, and will be removed from the XS API/);
	@warnings = ();
    }
}