This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don’t let method-BLOCK read beyond the stack
[perl5.git] / t / uni / cache.t
CommitLineData
c49d5ed7
JS
1BEGIN {
2 chdir 't' if -d 't';
3 @INC = qw(../lib .);
4 require "test.pl";
5}
6
7plan tests => 1;
8
90412e3e
KW
9# Looks to see if a "do 'unicore/lib/Sc/Hira.pl'" is called more than once, by
10# putting a compile sub first on the libary path;
11# XXX Kludge: requires exact path, which might change, and has deep knowledge
12# of how utf8_heavy.pl works, which might also change.
13
14BEGIN { # Make sure catches compile time references
15 $::count = 0;
16 unshift @INC, sub {
17 $::count++ if $_[1] eq 'unicore/lib/Sc/Hira.pl';
18 };
19}
c49d5ed7
JS
20
21my $s = 'foo';
22
88d45d28
KW
23# The second value is to prevent an optimization that exists at the time this
24# is written to re-use a property without trying to look it up if it is the
25# only thing in a character class. They differ in order to make sure that any
26# future optimizations that don't re-use identical character classes don't come
27# into play
28$s =~ m/[\p{Hiragana}\x{101}]/;
29$s =~ m/[\p{Hiragana}\x{102}]/;
30$s =~ m/[\p{Hiragana}\x{103}]/;
31$s =~ m/[\p{Hiragana}\x{104}]/;
c49d5ed7 32
90412e3e 33is($::count, 1, "Swatch hash caching kept us from reloading swatch hash.");