1nickt has asked for the wisdom of the Perl Monks concerning the following question:
Update: solved, ++Athanasius
Hello learned friends,
I have a module that outputs encoded data. I am testing the output. The tests pass on newer Perl versions, but fail on some old ones. I cannot spot the reason, since the test output appears to be the same, when reported as different. Can anyone please help me spot the issue?
Test code:
use strict; use warnings;
use Test::More; use Test::More::UTF8;
use Encode;
use Capture::Tiny 'capture_stderr';
use FindBin '$RealBin';
my $expected = q!{
'i中文' => '也許你的生活很有趣',
'Ελληνικά' => 'ἓν οἶδα ὅτι οὐδὲν οἶδα',
'русский' => 'доверяй, но проверяй',
}
!;
subtest 'imported via class function' => sub {
my $dump = capture_stderr(sub {
qx{perl $RealBin/import-via-class-function.pl}
});
is( decode_utf8($dump), $expected, 'output ok' );
};
done_testing;
__END__
Output:
# Failed test 'output ok'
# at t/import-via-class-function.t line 21.
# got: '{
# 'i中文' => '也許你的生活很有趣',
# 'Ελληνικά' => 'ἓν οἶδα ὅτι οὐδὲν οἶδα',
# 'русский' => 'доверяй, но проверяй'
# }
# '
# expected: '{
# 'i中文' => '也許你的生活很有趣',
# 'Ελληνικά' => 'ἓν οἶδα ὅτι οὐδὲν οἶδα',
# 'русский' => 'доверяй, но проверяй',
# }
# '
Thank you for any assistance!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test output diff ?
by Athanasius (Archbishop) on Apr 14, 2020 at 15:11 UTC | |
by 1nickt (Canon) on Apr 14, 2020 at 15:21 UTC |