summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2011-07-22 10:10:34 -0300
committerFather Chrysostomos <sprout@cpan.org>2011-10-06 13:01:14 -0700
commitce139e02098c388fe219b05275fb3063b39a4113 (patch)
tree0b12845b1dd5d09267dd1df8b280558cac716cb9
parent2e7cc76369120cbd78a8cefcb1b256b5b27bd6f7 (diff)
downloadperl-ce139e02098c388fe219b05275fb3063b39a4113.tar.gz
Tests for package; declarations in UTF-8
-rw-r--r--MANIFEST1
-rw-r--r--t/uni/package.t94
2 files changed, 95 insertions, 0 deletions
diff --git a/MANIFEST b/MANIFEST
index f3a27c66b3..e2d8b25cd7 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5284,6 +5284,7 @@ t/uni/lex_utf8.t See if Unicode in lexer works
t/uni/lower.t See if Unicode casing works
t/uni/method.t See if Unicode methods work
t/uni/overload.t See if Unicode overloading works
+t/uni/package.t See if Unicode in package declarations works
t/uni/parser.t See if Unicode in the parser works in edge cases.
t/uni/sprintf.t See if Unicode sprintf works
t/uni/tie.t See if Unicode tie works
diff --git a/t/uni/package.t b/t/uni/package.t
new file mode 100644
index 0000000000..317ddd4b7a
--- /dev/null
+++ b/t/uni/package.t
@@ -0,0 +1,94 @@
+#!./perl
+
+# Checks if 'package' work as intended.
+
+BEGIN {
+ require './test.pl';
+}
+
+plan (tests => 16);
+
+use utf8;
+use open qw( :utf8 :std );
+
+package Føø::Bær { }
+
+package クラス { }
+
+package ฟọ::バッズ { }
+
+ok 1, "sanity check. If we got this far, UTF-8 in package names is legal.";
+
+#The next few come from comp/package.t
+{
+
+ $ㄅĽuṞfⳐ = 123;
+
+ package ꑭʑ;
+
+ sub ニュー {bless [];}
+ $bar = 4;
+ {
+ package 압Ƈ;
+ $ㄅĽuṞfⳐ = 5;
+ }
+
+ $압Ƈ'd읯ⱪ = 6; #'
+
+ $ꑭʑ = 2;
+
+ $ꑭʑ = join(':', sort(keys %ꑭʑ::));
+ $압Ƈ = join(':', sort(keys %압Ƈ::));
+
+ ::is $ꑭʑ, 'bar:ニュー:ꑭʑ:압Ƈ', "comp/stash.t test 1";
+ ::is $압Ƈ, "d읯ⱪ:ㄅĽuṞfⳐ", "comp/stash.t test 2";
+ ::is $main'ㄅĽuṞfⳐ, 123, "comp/stash.t test 3";
+
+ package 압Ƈ;
+
+ ::is $ㄅĽuṞfⳐ, 5, "comp/stash.t test 4";
+ eval '::is $ㄅĽuṞfⳐ, 5, "comp/stash.t test 5";';
+ eval 'package main; is $ㄅĽuṞfⳐ, 123, "comp/stash.t test 6";';
+ ::is $ㄅĽuṞfⳐ, 5, "comp/stash.t test 7";
+
+ #This is actually pretty bad, as caller() wasn't clean to begin with.
+ package main;
+ sub ㄘ { caller(0) }
+
+ sub ƒஓ {
+ my $s = shift;
+ if ($s) {
+ package ᛔQR;
+ main::ㄘ();
+ }
+ }
+
+ is((ƒஓ(1))[0], 'ᛔQR', "comp/stash.t test 8");
+
+ my $Q = ꑭʑ->ニュー();
+ undef %ꑭʑ::;
+ eval { $a = *ꑭʑ::ニュー{PACKAGE}; };
+ is $a, "__ANON__", "comp/stash.t test 9";
+
+ {
+ local $@;
+ eval { $Q->param; };
+ like $@, qr/^Can't use anonymous symbol table for method lookup/, "comp/stash.t test 10";
+ }
+
+ like "$Q", qr/^__ANON__=/, "comp/stash.t test 11";
+
+ is ref $Q, "__ANON__", "comp/stash.t test 12";
+
+ package bugⅲⅱⅴⅵⅱ { #not really latin, but bear with me, I'm not Damian.
+ ::is( __PACKAGE__, 'bugⅲⅱⅴⅵⅱ', "comp/stash.t test 13");
+ ::is( eval('__PACKAGE__'), 'bugⅲⅱⅴⅵⅱ', "comp/stash.t test 14");
+ }
+}
+
+#This comes from comp/package_block.t
+{
+ local $@;
+ eval q[package ᕘ {];
+ like $@, qr/\AMissing right curly /, "comp/package_block.t test";
+}