Subject: | uniqint returns unexpected results when output converted to an arrayref |
The attached test demonstrates the problem and a workaround.
my @list = ( 982959698197430273, 982959698218369027, 982959700563013637 );
my $unique = [ uniqint @list ];
# 982959698197430272, 982959698218369024, 982959700563013632
Subject: | uniqint-borked.pl |
#!/usr/bin/env perl
use 5.22.1;
use warnings;
use List::Util qw/uniq uniqint uniqstr/;
use Test::More tests => 4;
my @list = ( 982959698197430273, 982959698218369027, 982959700563013637 );
# 982959708532338688, 982959711925321728, 982959715591192578,
# 982959718497955840, 982959726441906176, 982959728560099328,
# 982959731957350400, 982959732410400769, 982959735501565953,
# 982959736218791936, 982959737066024962, 982959740744380417,
# 982959746444541953, 982959750240522240, 982959750991241217,
# 982959753180733440, 982959761015500800, 982959765335805952,
# 982959765872566273, 982959767109988353, 982959769861238784,
# 982959770884714497, 982959771354615808, 982959772105363456,
# 982959775083388930, 982959777427767296, 982959786923708418,
# 982959791688507392, 982959792183529472, 982959797883625472,
# 982959799364128768, 982959802430214145, 982959806284750848,
# 982959810630045696, 982959811422662656, 982959812773384192,
# 982959814023241728, 982959814144802816, 982959816803954689,
# 982959821321326593, 982959825146597376, 982959825884659713,
# 982959833644072964, 982959834193694720, 982959835712016385,
# 982959835841835008, 982959836236218368, 982959837100298241,
# 982959840124268544, 982959843488055296, 982959843555315712,
# 982959843861381120, 982959846499627013, 982959847405707264,
# 982959852224835585, 982959854561189888, 982959855865495552,
# 982959861448265728, 982959864518529024, 982959869115285509,
# 982959873280241664, 982959877910917120, 982959878556663808,
# 982959879055912961, 982959881975103488, 982959885082968064,
# 982959885624233984, 982959889440956416, 982959889675780097,
# 982959891370430464, 982959891760472064, 982959896097275904,
# 982959901587787778, 982959905853194245, 982959906398486535,
# 982959906817966080, 982959909422731264, 982959915185537025,
# 982959917068795905, 982959917849079808, 982959918167638017,
# 982959919078010880, 982959919887302657, 982959919933607936,
# 982959927399538688, 982959932415684608, 982959934005481472,
# 982959935620345856, 982959936924565505, 982959937637695488,
# 982959938145107968, 982959944545783808, 982959948975009793,
# 982959951181111297, 982959953702014976, 982959959393558529,
# 982959962409328640
#);
my @workaround = uniqint @list;
ok eq_set(\@workaround, \@list), 'workaround';
ok eq_set([ uniq @list ], \@list), 'uniq';
ok eq_set([ uniqstr @list ], \@list), 'uniqstr';
ok eq_set([ uniqint @list ], \@list), 'uniqint';
diag "expected: ", join ', ' => @list;
diag "got: ", join ', ' => @{[ uniqint @list ]};
done_testing;