1 #!/usr/local/bin/perl -sw
11 my @sort_styles = qw( GRT ) ;
13 my @string_keys = map rand_alpha( 4, 8 ), 1 .. 100 ;
14 my @number_keys = map int( rand_number( 100, 10000 ) ), 1 .. 100 ;
16 #print "STR @string_keys NUM @number_keys\n" ;
21 name => 'simple string',
23 gen => sub { rand_choice( @string_keys ) },
24 gold => sub { $a cmp $b },
26 string => [ qw( string_data string ) ],
27 index => [ qw( string ) ],
32 name => 'simple string no-case',
34 gen => sub { rand_choice( @string_keys ) },
35 gold => sub { uc($a) cmp uc($b) },
37 string => [ qw( string_data string no_case ) ],
38 index => [ qw( string no_case ) ],
44 name => 'simple string descending',
46 gen => sub { rand_choice( @string_keys ) },
47 gold => sub { $b cmp $a },
49 string => [ qw( string_data string
50 descending varying ) ],
51 index => [ qw( string descending varying ) ],
56 name => 'simple string no-case descending',
58 gen => sub { rand_choice( @string_keys ) },
59 gold => sub { uc($b) cmp uc($a) },
61 string => [ qw( string_data string no_case
62 descending varying ) ],
63 index => [ qw( string no_case descending varying ) ],
68 name => 'simple number',
70 gen => sub { rand_choice( @number_keys ) },
71 gold => sub { $a <=> $b },
73 string => [ qw( string_data number ) ],
74 index => [ qw( number ) ],
81 name => 'string:number',
82 gen => sub { rand_choice( @string_keys ) . ':' .
83 rand_choice( @number_keys )
86 ($a =~ /^(\w+)/)[0] cmp ($b =~ /^(\w+)/)[0]
88 ($a =~ /(\d+)$/)[0] <=> ($b =~ /(\d+)$/)[0]
91 index => [ string => '/^(\w+)/',
94 string => [ 'string_data',
102 common_driver( $sort_tests, \@sort_styles ) ;