Permalink
Browse files

Enable the fc and unicode_eval features on perl >= 5.16.0

See "perldoc feature" for descriptions of these Perl features.

Fixes GH #2
  • Loading branch information...
1 parent d72befc commit d37a0835d0f5107b8ed7120aefc38280e93b3c7b @doherty committed Sep 13, 2012
Showing with 93 additions and 0 deletions.
  1. +2 −0 Changes
  2. +1 −0 lib/utf8/all.pm
  3. +16 −0 t/fc.t
  4. +39 −0 t/unicode_eval.t
  5. +35 −0 t/unicode_strings.t
View
@@ -2,6 +2,8 @@ Revision history for Perl module {{$dist->name}}
{{$NEXT}}
* Enable unicode_strings (see perldoc feature) [GH #2]
+ * Enable unicode_eval (see perldoc feature) [GH #2]
+ * Enable fc (see perldoc fc) [GH #2]
0.007 2012-08-01
* Use version.pm for comparing versions in the test suite
View
@@ -49,6 +49,7 @@ sub import {
'charnames'->import::into($target, qw{:full :short});
'warnings'->import::into($target, qw{FATAL utf8});
'feature'->import::into($target, qw{unicode_strings}) if $^V >= v5.11.0;
+ 'feature'->import::into($target, qw{unicode_eval fc}) if $^V >= v5.16.0;
# utf8 in @ARGV
state $have_encoded_argv = 0;
View
16 t/fc.t
@@ -0,0 +1,16 @@
+#!perl
+# utf8::all should turn on feature qw(unicode_strings)
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+{
+ no warnings qw(syntax);
+ eval q/fc 'ABC' eq fc 'abc';/;
+ ok $@, 'Got an error using fc without utf8::all...';
+ like $@ => qr/^syntax error/, '...and the error was a syntax error' or diag $@;
+}
+
+eval q/ use utf8::all; fc 'XYZ' eq fc 'xyz'; /;
+ok !$@, 'no error with utf8::all' or diag $@;
View
@@ -0,0 +1,39 @@
+#!perl
+# utf8::all should turn on feature qw(unicode_strings)
+
+use strict;
+use warnings;
+use Test::More tests => 5;
+
+# straight out of t/uni/eval.t
+use utf8::all;
+
+{
+ my $w;
+ $SIG{__WARN__} = sub { $w = shift };
+ use utf8;
+ my $prog = "qq!\x{f9}!";
+
+ eval $prog;
+ ok !$w;
+
+ $w = "";
+ utf8::upgrade($prog);
+ eval $prog;
+ is $w, '';
+}
+
+{
+ use utf8;
+ isnt eval "q!\360\237\220\252!", eval "q!\x{1f42a}!";
+}
+
+{
+ no utf8; #Let's make real sure.
+ my $not_utf8 = "q!\343\203\213!";
+ isnt eval $not_utf8, eval "q!\x{30cb}!";
+ {
+ use utf8;
+ isnt eval $not_utf8, eval "q!\x{30cb}!";
+ }
+}
View
@@ -0,0 +1,35 @@
+#!perl
+# utf8::all should turn on feature qw(unicode_strings)
+
+use strict;
+use warnings;
+use Test::More tests => 13;
+
+# Straight out of t/re/pat.t
+{ # Test that charset modifier work, and are interpolated
+ is(qr/\b\v$/, '(?^:\b\v$)', 'Verify no locale, no unicode_strings gives default modifier');
+ is(qr/(?l:\b\v$)/, '(?^:(?l:\b\v$))', 'Verify infix l modifier compiles');
+ is(qr/(?u:\b\v$)/, '(?^:(?u:\b\v$))', 'Verify infix u modifier compiles');
+ is(qr/(?l)\b\v$/, '(?^:(?l)\b\v$)', 'Verify (?l) compiles');
+ is(qr/(?u)\b\v$/, '(?^:(?u)\b\v$)', 'Verify (?u) compiles');
+
+ my $dual = qr/\b\v$/;
+ use locale;
+ my $locale = qr/\b\v$/;
+ is($locale, '(?^l:\b\v$)', 'Verify has l modifier when compiled under use locale');
+ no locale;
+
+ use utf8::all; # use utf8::all instead of feature qw(unicode_strings);
+ my $unicode = qr/\b\v$/;
+ is($unicode, '(?^u:\b\v$)', 'Verify has u modifier when compiled under unicode_strings');
+ is(qr/abc$dual/, '(?^u:abc(?^:\b\v$))', 'Verify retains d meaning when interpolated under locale');
+ is(qr/abc$locale/, '(?^u:abc(?^l:\b\v$))', 'Verify retains l when interpolated under unicode_strings');
+
+ no feature 'unicode_strings';
+ is(qr/abc$locale/, '(?^:abc(?^l:\b\v$))', 'Verify retains l when interpolated outside locale and unicode strings');
+ is(qr/def$unicode/, '(?^:def(?^u:\b\v$))', 'Verify retains u when interpolated outside locale and unicode strings');
+
+ use locale;
+ is(qr/abc$dual/, '(?^l:abc(?^:\b\v$))', 'Verify retains d meaning when interpolated under locale');
+ is(qr/abc$unicode/, '(?^l:abc(?^u:\b\v$))', 'Verify retains u when interpolated under locale');
+}

0 comments on commit d37a083

Please sign in to comment.