File: floats.t

package info (click to toggle)
libsort-key-perl 1.33-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 344 kB
  • sloc: perl: 493; ansic: 212; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl

use Test::More tests => 6;
use Sort::Key qw(nkeysort rnkeysort nkeysort_inplace nsort rnsort);

use strict;
use warnings;

my @data=map { rand(200)-100 } 1..10000;

is_deeply([nkeysort {$_*$_} @data], [sort {$a*$a <=> $b*$b} @data], 'i sqr');

my @sorted = sort {$a<=>$b} @data;
my @rsorted = reverse @sorted;
is_deeply([nkeysort {$_} @data], \@sorted, 'n id');
is_deeply([rnkeysort {$_} @data], \@rsorted, 'reverse');
nkeysort_inplace {$_} @data;
is_deeply(\@data, \@sorted, 'in place');

is_deeply([nsort @data], \@sorted, 'nsort');
is_deeply([rnsort @data], \@rsorted, 'rnsort');