Commit | Line | Data |
7468c584 |
1 | #!/usr/local/bin/perl -sw |
2 | |
3 | use strict ; |
4 | |
5 | use lib 't' ; |
6 | use lib '..' ; |
7 | require 'common.pm' ; |
8 | |
9 | my @sort_styles = qw( plain orcish ST GRT ) ; |
10 | |
11 | my $sort_tests = [ |
12 | |
13 | { |
14 | skip => 0, |
15 | name => 'hashes of strings', |
16 | data => [ map { |
17 | { a => rand_token( 8, 20 ) } |
18 | } 1 .. 100 |
19 | ], |
20 | gold => sub { $a->{a} cmp $b->{a} }, |
21 | args => [ qw( string $_->{a} ) ], |
22 | }, |
23 | { |
24 | skip => 0, |
25 | name => 'hashes of numbers', |
26 | data => [ map { |
27 | { a => rand_number( 1, 20 ) } |
28 | } 1 .. 100 |
29 | ], |
30 | gold => sub { $a->{a} <=> $b->{a} }, |
31 | args => [ qw( number $_->{a} ) ], |
32 | }, |
33 | { |
34 | skip => 0, |
35 | name => 'hashes of multiple strings', |
36 | data => [ map { |
37 | { a => rand_token( 8, 20 ), |
38 | b => rand_token( 8, 20 ), } |
39 | } 1 .. 100 |
40 | ], |
41 | gold => sub { $a->{a} cmp $b->{a} || |
42 | $a->{b} cmp $b->{b} }, |
43 | args => [ qw( string $_->{a} string $_->{b} ) ], |
44 | }, |
45 | { |
46 | skip => 0, |
47 | name => 'hashes of multiple numbers', |
48 | data => [ map { |
49 | { a => rand_number( 1, 20 ), |
50 | b => rand_number( 1, 20 ) } |
51 | } 1 .. 100 |
52 | ], |
53 | gold => sub { $a->{a} <=> $b->{a} || |
54 | $a->{b} <=> $b->{b} }, |
55 | args => [ qw( number $_->{a} number $_->{b} ) ], |
56 | }, |
57 | ] ; |
58 | |
59 | common_driver( $sort_tests, \@sort_styles ) ; |
60 | |
61 | exit ; |