summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-11-20 19:10:19 -0700
committerKarl Williamson <public@khwilliamson.com>2012-01-11 08:43:59 -0700
commit80b85d75d47c9f5e9ead696b9969395f150156a1 (patch)
tree4e35a2a1decc821ac0d8eca0ed7387bc1d27095c
parentf60db8f614fff2dd2e069886a7700ea387e7ab87 (diff)
downloadperl-80b85d75d47c9f5e9ead696b9969395f150156a1.tar.gz
uni/cache.t: Fix to handle regex compile time Uni props
Future commits are planned to move the resolution of Unicode properties from regex execution time to compile time. By moving the code into a BEGIN block, this .t can now handle both types. Before this patch, it wouldn't show any activity at all if things are done at compile time.
-rw-r--r--t/uni/cache.t18
1 files changed, 12 insertions, 6 deletions
diff --git a/t/uni/cache.t b/t/uni/cache.t
index df12f33ba2..74ce1f084a 100644
--- a/t/uni/cache.t
+++ b/t/uni/cache.t
@@ -6,11 +6,17 @@ BEGIN {
plan tests => 1;
-my $count = 0;
-unshift @INC, sub {
- # XXX Kludge requires exact path, which might change
- $count++ if $_[1] eq 'unicore/lib/Sc/Hira.pl';
-};
+# Looks to see if a "do 'unicore/lib/Sc/Hira.pl'" is called more than once, by
+# putting a compile sub first on the libary path;
+# XXX Kludge: requires exact path, which might change, and has deep knowledge
+# of how utf8_heavy.pl works, which might also change.
+
+BEGIN { # Make sure catches compile time references
+ $::count = 0;
+ unshift @INC, sub {
+ $::count++ if $_[1] eq 'unicore/lib/Sc/Hira.pl';
+ };
+}
my $s = 'foo';
@@ -19,4 +25,4 @@ $s =~ m/[\p{Hiragana}]/;
$s =~ m/[\p{Hiragana}]/;
$s =~ m/[\p{Hiragana}]/;
-is($count, 1, "Swatch hash caching kept us from reloading swatch hash.");
+is($::count, 1, "Swatch hash caching kept us from reloading swatch hash.");