This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Spelling correction for consistency with pod/perldebguts.pod.
[perl5.git] / t / porting / re_context.t
1 #!./perl -w
2 #
3 # Check that utf8.pm and its dependencies only use the subset of the
4 # $1..$n capture vars that Perl_save_re_context() is hard-coded to
5 # localise, because that function has no efficient way of determining at
6 # runtime what vars to localise.
7 #
8 # Note that this script tests for the existence of symbol table entries in
9 # %::, so @4 etc would trigger a failure as well as $4.
10 #
11 # If tests start to fail, either (in order of descending preference):
12 #
13 # * fix utf8.pm or its dependencies so that any recent change no longer
14 #   uses more special vars (ideally it would use no vars);
15 #
16 # * fix Perl_save_re_context() so that it localises more vars, then
17 #   update this test script with the new relaxed var list.
18
19
20 use warnings;
21 use strict;
22
23 # trigger the dependency loading
24
25 my $x = lc "\x{411}";
26
27 # determine which relevant vars those dependencies accessed
28
29 my @vars =
30         grep !/^[0123]$/, # $0, and $1, ..$3 allowed
31         grep /^(?:\d+|[`'&])$/,  # numeric and $`, $&, $' vars
32         sort keys %::;
33
34 # load any other modules *after* calculating @vars
35
36 require './test.pl';
37
38 plan(1);
39
40 is(scalar @vars, 0, "extraneous vars")
41     or diag("extra vars seen: " . join(", ", map "*$_", @vars));
42
43 exit 0;