1--TEST--
2locale_filter_matches.phpt() ICU >= 51.2
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
6--FILE--
7<?php
8
9/*
10 * Try parsing different Locales
11 * with Procedural and Object methods.
12 */
13
14function ut_main()
15{
16	$loc_ranges = array(
17		'de-de',
18		'sl_IT',
19		'sl_IT_Nedis',
20		'jbo',
21		'art-lojban',
22		'sl_IT'
23	);
24
25	$lang_tags = array(
26		'de-DEVA',
27		'de-DE-1996',
28		'de-DE',
29		'zh_Hans',
30		'de-CH-1996',
31		'sl_IT',
32		'sl_IT_nedis-a-kirti-x-xyz',
33		'sl_IT_rozaj',
34		'sl_IT_NEDIS_ROJAZ_1901',
35		'i-enochian',
36		'sgn-CH-de',
37		'art-lojban',
38		'i-lux',
39		'art-lojban',
40		'jbo',
41		'en_sl_IT'
42	);
43
44    $res_str = '';
45    $isCanonical = false;
46	foreach($loc_ranges as $loc_range){
47		foreach($lang_tags as $lang_tag){
48			$res_str .="--------------\n";
49			$result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical);
50			$res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? ";
51			if( $result){
52				$res_str .= "YES\n";
53			}else{
54				$res_str .= "NO\n";
55			}
56//canonicalized version
57			$result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical));
58			$can_loc_range = ut_loc_canonicalize($loc_range);
59			$can_lang_tag = ut_loc_canonicalize($lang_tag);
60			$res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? ";
61			if( $result){
62				$res_str .= "YES\n";
63			}else{
64				$res_str .= "NO\n";
65			}
66		}
67	}
68
69	$res_str .= "\n";
70    return $res_str;
71
72}
73
74include_once( 'ut_common.inc' );
75ut_run();
76
77?>
78--EXPECT--
79--------------
80loc_range:de-de matches lang_tag de-DEVA ? NO
81loc_range:de_DE canonically matches lang_tag de_Deva ? NO
82--------------
83loc_range:de-de matches lang_tag de-DE-1996 ? YES
84loc_range:de_DE canonically matches lang_tag de_DE_1996 ? YES
85--------------
86loc_range:de-de matches lang_tag de-DE ? YES
87loc_range:de_DE canonically matches lang_tag de_DE ? YES
88--------------
89loc_range:de-de matches lang_tag zh_Hans ? NO
90loc_range:de_DE canonically matches lang_tag zh_Hans ? NO
91--------------
92loc_range:de-de matches lang_tag de-CH-1996 ? NO
93loc_range:de_DE canonically matches lang_tag de_CH_1996 ? NO
94--------------
95loc_range:de-de matches lang_tag sl_IT ? NO
96loc_range:de_DE canonically matches lang_tag sl_IT ? NO
97--------------
98loc_range:de-de matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
99loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
100--------------
101loc_range:de-de matches lang_tag sl_IT_rozaj ? NO
102loc_range:de_DE canonically matches lang_tag sl_IT_ROZAJ ? NO
103--------------
104loc_range:de-de matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
105loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
106--------------
107loc_range:de-de matches lang_tag i-enochian ? NO
108loc_range:de_DE canonically matches lang_tag @x=i-enochian ? NO
109--------------
110loc_range:de-de matches lang_tag sgn-CH-de ? NO
111loc_range:de_DE canonically matches lang_tag sgn_CH_DE ? NO
112--------------
113loc_range:de-de matches lang_tag art-lojban ? NO
114loc_range:de_DE canonically matches lang_tag art__LOJBAN ? NO
115--------------
116loc_range:de-de matches lang_tag i-lux ? NO
117loc_range:de_DE canonically matches lang_tag lb ? NO
118--------------
119loc_range:de-de matches lang_tag art-lojban ? NO
120loc_range:de_DE canonically matches lang_tag art__LOJBAN ? NO
121--------------
122loc_range:de-de matches lang_tag jbo ? NO
123loc_range:de_DE canonically matches lang_tag jbo ? NO
124--------------
125loc_range:de-de matches lang_tag en_sl_IT ? NO
126loc_range:de_DE canonically matches lang_tag en_SL_IT ? NO
127--------------
128loc_range:sl_IT matches lang_tag de-DEVA ? NO
129loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
130--------------
131loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
132loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
133--------------
134loc_range:sl_IT matches lang_tag de-DE ? NO
135loc_range:sl_IT canonically matches lang_tag de_DE ? NO
136--------------
137loc_range:sl_IT matches lang_tag zh_Hans ? NO
138loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
139--------------
140loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
141loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
142--------------
143loc_range:sl_IT matches lang_tag sl_IT ? YES
144loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
145--------------
146loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
147loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
148--------------
149loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
150loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
151--------------
152loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
153loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
154--------------
155loc_range:sl_IT matches lang_tag i-enochian ? NO
156loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO
157--------------
158loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
159loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
160--------------
161loc_range:sl_IT matches lang_tag art-lojban ? NO
162loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
163--------------
164loc_range:sl_IT matches lang_tag i-lux ? NO
165loc_range:sl_IT canonically matches lang_tag lb ? NO
166--------------
167loc_range:sl_IT matches lang_tag art-lojban ? NO
168loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
169--------------
170loc_range:sl_IT matches lang_tag jbo ? NO
171loc_range:sl_IT canonically matches lang_tag jbo ? NO
172--------------
173loc_range:sl_IT matches lang_tag en_sl_IT ? NO
174loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
175--------------
176loc_range:sl_IT_Nedis matches lang_tag de-DEVA ? NO
177loc_range:sl_IT_NEDIS canonically matches lang_tag de_Deva ? NO
178--------------
179loc_range:sl_IT_Nedis matches lang_tag de-DE-1996 ? NO
180loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE_1996 ? NO
181--------------
182loc_range:sl_IT_Nedis matches lang_tag de-DE ? NO
183loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE ? NO
184--------------
185loc_range:sl_IT_Nedis matches lang_tag zh_Hans ? NO
186loc_range:sl_IT_NEDIS canonically matches lang_tag zh_Hans ? NO
187--------------
188loc_range:sl_IT_Nedis matches lang_tag de-CH-1996 ? NO
189loc_range:sl_IT_NEDIS canonically matches lang_tag de_CH_1996 ? NO
190--------------
191loc_range:sl_IT_Nedis matches lang_tag sl_IT ? NO
192loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT ? NO
193--------------
194loc_range:sl_IT_Nedis matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
195loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
196--------------
197loc_range:sl_IT_Nedis matches lang_tag sl_IT_rozaj ? NO
198loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_ROZAJ ? NO
199--------------
200loc_range:sl_IT_Nedis matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
201loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
202--------------
203loc_range:sl_IT_Nedis matches lang_tag i-enochian ? NO
204loc_range:sl_IT_NEDIS canonically matches lang_tag @x=i-enochian ? NO
205--------------
206loc_range:sl_IT_Nedis matches lang_tag sgn-CH-de ? NO
207loc_range:sl_IT_NEDIS canonically matches lang_tag sgn_CH_DE ? NO
208--------------
209loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
210loc_range:sl_IT_NEDIS canonically matches lang_tag art__LOJBAN ? NO
211--------------
212loc_range:sl_IT_Nedis matches lang_tag i-lux ? NO
213loc_range:sl_IT_NEDIS canonically matches lang_tag lb ? NO
214--------------
215loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO
216loc_range:sl_IT_NEDIS canonically matches lang_tag art__LOJBAN ? NO
217--------------
218loc_range:sl_IT_Nedis matches lang_tag jbo ? NO
219loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO
220--------------
221loc_range:sl_IT_Nedis matches lang_tag en_sl_IT ? NO
222loc_range:sl_IT_NEDIS canonically matches lang_tag en_SL_IT ? NO
223--------------
224loc_range:jbo matches lang_tag de-DEVA ? NO
225loc_range:jbo canonically matches lang_tag de_Deva ? NO
226--------------
227loc_range:jbo matches lang_tag de-DE-1996 ? NO
228loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO
229--------------
230loc_range:jbo matches lang_tag de-DE ? NO
231loc_range:jbo canonically matches lang_tag de_DE ? NO
232--------------
233loc_range:jbo matches lang_tag zh_Hans ? NO
234loc_range:jbo canonically matches lang_tag zh_Hans ? NO
235--------------
236loc_range:jbo matches lang_tag de-CH-1996 ? NO
237loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO
238--------------
239loc_range:jbo matches lang_tag sl_IT ? NO
240loc_range:jbo canonically matches lang_tag sl_IT ? NO
241--------------
242loc_range:jbo matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
243loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
244--------------
245loc_range:jbo matches lang_tag sl_IT_rozaj ? NO
246loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO
247--------------
248loc_range:jbo matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
249loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
250--------------
251loc_range:jbo matches lang_tag i-enochian ? NO
252loc_range:jbo canonically matches lang_tag @x=i-enochian ? NO
253--------------
254loc_range:jbo matches lang_tag sgn-CH-de ? NO
255loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO
256--------------
257loc_range:jbo matches lang_tag art-lojban ? NO
258loc_range:jbo canonically matches lang_tag art__LOJBAN ? NO
259--------------
260loc_range:jbo matches lang_tag i-lux ? NO
261loc_range:jbo canonically matches lang_tag lb ? NO
262--------------
263loc_range:jbo matches lang_tag art-lojban ? NO
264loc_range:jbo canonically matches lang_tag art__LOJBAN ? NO
265--------------
266loc_range:jbo matches lang_tag jbo ? YES
267loc_range:jbo canonically matches lang_tag jbo ? YES
268--------------
269loc_range:jbo matches lang_tag en_sl_IT ? NO
270loc_range:jbo canonically matches lang_tag en_SL_IT ? NO
271--------------
272loc_range:art-lojban matches lang_tag de-DEVA ? NO
273loc_range:art__LOJBAN canonically matches lang_tag de_Deva ? NO
274--------------
275loc_range:art-lojban matches lang_tag de-DE-1996 ? NO
276loc_range:art__LOJBAN canonically matches lang_tag de_DE_1996 ? NO
277--------------
278loc_range:art-lojban matches lang_tag de-DE ? NO
279loc_range:art__LOJBAN canonically matches lang_tag de_DE ? NO
280--------------
281loc_range:art-lojban matches lang_tag zh_Hans ? NO
282loc_range:art__LOJBAN canonically matches lang_tag zh_Hans ? NO
283--------------
284loc_range:art-lojban matches lang_tag de-CH-1996 ? NO
285loc_range:art__LOJBAN canonically matches lang_tag de_CH_1996 ? NO
286--------------
287loc_range:art-lojban matches lang_tag sl_IT ? NO
288loc_range:art__LOJBAN canonically matches lang_tag sl_IT ? NO
289--------------
290loc_range:art-lojban matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO
291loc_range:art__LOJBAN canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO
292--------------
293loc_range:art-lojban matches lang_tag sl_IT_rozaj ? NO
294loc_range:art__LOJBAN canonically matches lang_tag sl_IT_ROZAJ ? NO
295--------------
296loc_range:art-lojban matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
297loc_range:art__LOJBAN canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO
298--------------
299loc_range:art-lojban matches lang_tag i-enochian ? NO
300loc_range:art__LOJBAN canonically matches lang_tag @x=i-enochian ? NO
301--------------
302loc_range:art-lojban matches lang_tag sgn-CH-de ? NO
303loc_range:art__LOJBAN canonically matches lang_tag sgn_CH_DE ? NO
304--------------
305loc_range:art-lojban matches lang_tag art-lojban ? YES
306loc_range:art__LOJBAN canonically matches lang_tag art__LOJBAN ? YES
307--------------
308loc_range:art-lojban matches lang_tag i-lux ? NO
309loc_range:art__LOJBAN canonically matches lang_tag lb ? NO
310--------------
311loc_range:art-lojban matches lang_tag art-lojban ? YES
312loc_range:art__LOJBAN canonically matches lang_tag art__LOJBAN ? YES
313--------------
314loc_range:art-lojban matches lang_tag jbo ? NO
315loc_range:art__LOJBAN canonically matches lang_tag jbo ? NO
316--------------
317loc_range:art-lojban matches lang_tag en_sl_IT ? NO
318loc_range:art__LOJBAN canonically matches lang_tag en_SL_IT ? NO
319--------------
320loc_range:sl_IT matches lang_tag de-DEVA ? NO
321loc_range:sl_IT canonically matches lang_tag de_Deva ? NO
322--------------
323loc_range:sl_IT matches lang_tag de-DE-1996 ? NO
324loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO
325--------------
326loc_range:sl_IT matches lang_tag de-DE ? NO
327loc_range:sl_IT canonically matches lang_tag de_DE ? NO
328--------------
329loc_range:sl_IT matches lang_tag zh_Hans ? NO
330loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO
331--------------
332loc_range:sl_IT matches lang_tag de-CH-1996 ? NO
333loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO
334--------------
335loc_range:sl_IT matches lang_tag sl_IT ? YES
336loc_range:sl_IT canonically matches lang_tag sl_IT ? YES
337--------------
338loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES
339loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES
340--------------
341loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES
342loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES
343--------------
344loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
345loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES
346--------------
347loc_range:sl_IT matches lang_tag i-enochian ? NO
348loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO
349--------------
350loc_range:sl_IT matches lang_tag sgn-CH-de ? NO
351loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO
352--------------
353loc_range:sl_IT matches lang_tag art-lojban ? NO
354loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
355--------------
356loc_range:sl_IT matches lang_tag i-lux ? NO
357loc_range:sl_IT canonically matches lang_tag lb ? NO
358--------------
359loc_range:sl_IT matches lang_tag art-lojban ? NO
360loc_range:sl_IT canonically matches lang_tag art__LOJBAN ? NO
361--------------
362loc_range:sl_IT matches lang_tag jbo ? NO
363loc_range:sl_IT canonically matches lang_tag jbo ? NO
364--------------
365loc_range:sl_IT matches lang_tag en_sl_IT ? NO
366loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO
367