1 #!/usr/local/bin/perl -sw
9 my @sort_styles = qw( ST GRT ) ;
11 my @string_keys = map rand_alpha( 4, 8 ), 1 .. 10 ;
12 my @number_keys = map int rand_number( 100, 10000 ), 1 .. 10 ;
21 gen => sub { rand_choice( @string_keys ) . ':' .
22 rand_choice( @number_keys ) },
24 ($a =~ /^(\w+)/)[0] cmp ($b =~ /^(\w+)/)[0]
26 ($a =~ /(\d+$)/)[0] <=> ($b =~ /(\d+$)/)[0]
30 init_code => 'my( $str, $num ) ;',
32 'do{( $str, $num ) = /^(\w+):(\d+)$/; $str}',
44 name => 'deep init_code',
46 gen => sub { [[{'a' => rand_choice( @string_keys ) . ':' .
47 rand_choice( @number_keys )}]] },
49 ($a->[0][0]{a} =~ /^(\w+)/)[0] cmp
50 ($b->[0][0]{a} =~ /^(\w+)/)[0]
52 ($a->[0][0]{a} =~ /(\d+$)/)[0] <=>
53 ($b->[0][0]{a} =~ /(\d+$)/)[0]
57 init_code => 'my( $str, $num ) ;',
58 string => 'do{( $str, $num ) =
59 $_->[0][0]{a} =~ /^(\w+):(\d+)$/; $str}',
63 string => '$_->[0][0]{a} =~ /^(\w+)/',
64 number => '$_->[0][0]{a} =~ /(\d+$)/',
70 common_driver( $sort_tests, \@sort_styles ) ;