comparison js_args.t @ 1811:520fb74cce4c

Tests: improved njs version check to account multi digit versions.
author Dmitry Volyntsev <xeioex@nginx.com>
date Fri, 02 Dec 2022 17:46:22 -0800
parents 0979f22e3a5b
children
comparison
equal deleted inserted replaced
1810:7cf848422b28 1811:520fb74cce4c
114 recode($1); 114 recode($1);
115 } 115 }
116 116
117 ############################################################################### 117 ###############################################################################
118 118
119 TODO: { 119 local $TODO = 'not yet' unless has_version('0.7.6');
120 local $TODO = 'not yet'
121 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.6';
122 120
123 like(http_get('/iter?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/, 121 like(http_get('/iter?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/,
124 'r.args iteration'); 122 'r.args iteration');
125 like(http_get('/iter?foo=123&foo2=&foo3&foo4=456'), qr/123456/, 123 like(http_get('/iter?foo=123&foo2=&foo3&foo4=456'), qr/123456/,
126 'r.args iteration 2'); 124 'r.args iteration 2');
144 is(get_json('/object?a=%62%63&b=%63%64'), '{"a":"bc","b":"cd"}', 142 is(get_json('/object?a=%62%63&b=%63%64'), '{"a":"bc","b":"cd"}',
145 'values percent-encoded object'); 143 'values percent-encoded object');
146 is(get_json('/object?a=%6&b=%&c=%%&d=%zz'), 144 is(get_json('/object?a=%6&b=%&c=%%&d=%zz'),
147 '{"a":"%6","b":"%","c":"%%","d":"%zz"}', 145 '{"a":"%6","b":"%","c":"%%","d":"%zz"}',
148 'values percent-encoded broken object'); 146 'values percent-encoded broken object');
147
148 ###############################################################################
149
150 sub has_version {
151 my $need = shift;
152
153 http_get('/njs') =~ /^([.0-9]+)$/m;
154
155 my @v = split(/\./, $1);
156 my ($n, $v);
157
158 for $n (split(/\./, $need)) {
159 $v = shift @v || 0;
160 return 0 if $n > $v;
161 return 1 if $v > $n;
162 }
163
164 return 1;
149 } 165 }
150 166
151 ############################################################################### 167 ###############################################################################