Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Test2/Tools/Mock.pm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ sub _generate_class {
my $prefix = __PACKAGE__;

for (1 .. 100) {
my $postfix = join '', map { chr(rand(26) + 65) } 1 .. 32;
my $postfix = join '', map { chr(utf8::unicode_to_native(rand(26) + 65))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to insure the utf8 package is loaded first, is there a minimum perl version this works for?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing and it looks like we do not need to load utf8, and that this works back to 5.8. I will merge, then add some logic to skip the call on 5.6, but only cause it is not difficult, and there are still people using modern Test2 on 5.6 (yikes)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it utf8: is always loaded, since 5.8. It's fine to not support EBCDIC before then. I haven't looked at what you may have done about 5.6, but I would just create a sub, say to_native that is defined to return its input for earlier than 5.8, and calls unicode_to_native for later. Hence no conditionals are added except for setup.

} 1 .. 32;
my $class = $prefix . '::__TEMP__::' . $postfix;
my $file = $class;
$file =~ s{::}{/}g;
Expand Down
4 changes: 2 additions & 2 deletions t/modules/Tools/Compare.t
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ subtest is => sub {

fail_table(
header => [qw/GOT OP CHECK/],
rows => [["\N{U+1}\N{U+2}\N{U+3}", 'eq', "\N{U+1}\N{U+2}\N{U+4}"]],
rows => [["\x{01}\x{02}\x{03}", 'eq', "\x{01}\x{02}\x{04}"]],
);

fail_table(
header => [qw/PATH GOT OP CHECK/],
rows => [['$*', "\N{U+1}\N{U+2}\N{U+3}", 'eq', "\N{U+1}\N{U+2}\N{U+4}"]],
rows => [['$*', "\x{01}\x{02}\x{03}", 'eq', "\x{01}\x{02}\x{04}"]],
);

event Ok => sub {
Expand Down
Loading