Commit | Line | Data |
7468c584 |
1 | #!/usr/local/bin/perl |
2 | |
3 | use strict ; |
4 | use warnings ; |
5 | |
6 | use lib 't' ; |
7 | use lib '..' ; |
8 | require 'common.pm' ; |
9 | |
10 | my $sort_tests = [ |
11 | |
12 | { |
13 | name => 'unknown option', |
14 | args => { |
15 | unknown => [ qw( xxx ), ], |
16 | }, |
17 | error => qr/unknown/i, |
18 | }, |
19 | |
20 | { |
21 | name => 'no keys', |
22 | styles => [ qw( plain ) ], |
23 | args => { |
24 | no_keys => [], |
25 | }, |
26 | error => qr/no keys/i, |
27 | }, |
28 | |
29 | { |
30 | name => 'duplicate style', |
31 | args => { |
32 | dup_style => [qw( GRT ST ) ], |
33 | }, |
34 | error => qr/style was already set/i, |
35 | }, |
36 | |
37 | { |
38 | name => 'no value', |
39 | args => { |
40 | no_value => [ qw( name ) ], |
41 | }, |
42 | error => qr/no value/i, |
43 | }, |
44 | { |
45 | name => 'no style', |
46 | args => { |
47 | no_style => [ qw( string ) ], |
48 | }, |
49 | error => qr/no sort style/i, |
50 | }, |
51 | |
52 | { |
53 | name => 'ascending and descending', |
54 | styles => [ qw( plain ) ], |
55 | args => { |
56 | up_and_down => [ |
57 | string => { |
58 | ascending => 1, |
59 | descending => 1, |
60 | }, |
61 | ], |
62 | }, |
63 | error => qr/has ascending/i, |
64 | }, |
65 | |
66 | { |
67 | name => 'case and no case', |
68 | styles => [ qw( plain ) ], |
69 | args => { |
70 | up_and_down => [ |
71 | string => { |
72 | case => 1, |
73 | no_case => 1, |
74 | }, |
75 | ], |
76 | }, |
77 | error => qr/has case/, |
78 | }, |
79 | |
80 | { |
81 | name => 'illegal code', |
82 | styles => [ qw( plain ) ], |
83 | args => { |
84 | illegal => [ |
85 | string => 'XXX', |
86 | ], |
87 | }, |
88 | error => qr/compile/, |
89 | }, |
90 | |
91 | { |
92 | name => 'GRT descending string', |
93 | styles => [ qw( GRT ) ], |
94 | args => { |
95 | GRT => [ |
96 | qw( string descending ) |
97 | ], |
98 | }, |
99 | error => qr/descending string/, |
100 | }, |
101 | |
102 | { |
103 | name => 'array args - no value', |
104 | styles => [ qw( ST ) ], |
105 | args => { |
106 | array => [ |
107 | qw( ref_in ref_out ), |
108 | number => [ |
109 | qw( |
110 | descending |
111 | unsigned_float |
112 | ), |
113 | 'code', |
114 | ], |
115 | ], |
116 | }, |
117 | error => qr/No value/i, |
118 | }, |
119 | |
120 | { |
121 | name => 'array args - unknown attribute', |
122 | styles => [ qw( ST ) ], |
123 | args => { |
124 | array => [ |
125 | |
126 | number => [ |
127 | qw( |
128 | descending |
129 | unsigned_float |
130 | ), |
131 | 'foobar', |
132 | ], |
133 | ], |
134 | }, |
135 | error => qr/Unknown attribute/, |
136 | }, |
137 | |
138 | ] ; |
139 | |
140 | common_driver( $sort_tests ) ; |
141 | |
142 | exit ; |