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