Skip to content

Commit 8c05864

Browse files
committed
uni/method.t: Update, and don't test specific garbage
The modern way to change UTF-8 to its component bytes is to use utf8::encode Some of the tests are making sure that those component bytes aren't mistaken for being UTF-8. What those component bytes are is not actually relevant, but the tests were looking at the specific expected values of them. The problem is that these differ on EBCDIC vs ASCII platforms. Several commits had been added to try to get the correct values on both types, but EBCDIC still was getting failures. And, there is no need to test for the specific values of these irrelevant bytes. What is important is that they were not misinterpreted as if they were UTF-8. This commit goes back to the original tests before those other commits were added, and changes the matching pattern to not look for the specific irrelevant byte values. Doing so makes the tests pass on both types of platforms.
1 parent 49ca100 commit 8c05864

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

t/uni/method.t

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ like( Føø::Bær->nèw, qr/Føø::Bær=HASH/u, 'Can access nèw as a method thr
111111
is( ref Føø::Bær->new, 'Føø::Bær');
112112
113113
my $new_ascii = "new";
114-
my $new_latin = "nèw";
115-
my $e_with_grave = byte_utf8a_to_utf8n("\303\250");
116-
my $e_with_grave_escaped= $e_with_grave=~s/\x{a8}/\\\\x\\{a8\\}/r;
117-
my $new_utf8 = "n${e_with_grave}w";
118-
my $newoct = "n${e_with_grave}w";
119-
utf8::decode($new_utf8);
114+
my $new_utf8 = "nèw";
115+
my $new_latin = $new_utf8;
116+
utf8::downgrade($new_latin);
117+
118+
my $newoct = $new_utf8;
119+
utf8::encode($newoct);
120120
121121
like( Føø::Bær->$new_ascii, qr/Føø::Bær=HASH/u, "Can access \$new_ascii, [$new_ascii], stored in a scalar, as a method, through a UTF-8 package." );
122122
like( Føø::Bær->$new_latin, qr/Føø::Bær=HASH/u, "Can access \$new_latin, [$new_latin], stored in a scalar, as a method, through a UTF-8 package." );
123123
like( Føø::Bær->$new_utf8, qr/Føø::Bær=HASH/u, "Can access \$new_utf8, [$new_utf8], stored in a scalar, as a method, through a UTF-8 package." );
124124
{
125125
local $@;
126126
eval { Føø::Bær->$newoct };
127-
like($@, qr/Can't locate object method "n${e_with_grave_escaped}w" via package "Føø::Bær"/u,
127+
like($@, qr/Can't locate object method "[^"]+" via package "Føø::Bær"/u,
128128
"Can't access [$newoct], stored in a scalar, as a method through a UTF-8 package." );
129129
}
130130
@@ -143,7 +143,7 @@ like( $pkg_latin_1->$new_utf8, qr/Føø::Bær=HASH/u, "Can access \$new_utf8, [$
143143
local $@;
144144
145145
eval { $pkg_latin_1->$newoct };
146-
like($@, qr/Can't locate object method "n${e_with_grave_escaped}w" via package "Føø::Bær"/u,
146+
like($@, qr/Can't locate object method "[^"]*" via package "Føø::Bær"/u,
147147
"Can't access [$newoct], stored in a scalar, as a method, when the UTF-8 package name is also in a scalar.");
148148
}
149149

0 commit comments

Comments
 (0)