global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / intl / tests / collator_asort_variant2.php
bloba0d00367c3eb9f25be64c5f1f9d04d86fe2e9d11
1 <?php
3 /*
4 * Sort associative arrays using various locales.
5 */
8 ZendGoodExtIntlTestsCollatorAsortVariant2::$test_num = 1;
11 * Sort various arrays in specified locale.
13 function sort_arrays( $locale, $test_arrays, $sort_flag = Collator::SORT_REGULAR )
15 $res_str = '';
17 $coll = ut_coll_create( $locale );
19 foreach( $test_arrays as $test_array )
21 // Try to sort test data.
22 $res_val = ut_coll_asort( $coll, &$test_array, $sort_flag );
24 // Return output data.
25 $res_dump = "\n" . dump( $test_array ) .
26 "\n Result: " . dump( $res_val );
28 // Preppend test signature to output string
29 $md5 = md5( $res_dump );
32 $res_str .= "\n\n".
33 "Test ".ZendGoodExtIntlTestsCollatorAsortVariant2::$test_num.".$md5:" .
34 $res_dump;
35 ++ZendGoodExtIntlTestsCollatorAsortVariant2::$test_num;
38 return $res_str;
42 * Test main function.
44 function ut_main()
47 ZendGoodExtIntlTestsCollatorAsortVariant2::$test_num = 1;
48 $res_str = '';
50 // Sort an array in SORT_REGULAR mode using en_US locale.
51 $test_params = array(
52 array( 'd' => 'y' ,
53 'c' => 'i' ,
54 'a' => 'k' ),
56 array( 'a' => 'a' ,
57 'b' => 'aaa',
58 'c' => 'aa' ),
60 array( 'a' => 'a' ,
61 'aaa'=> 'a' ,
62 'aa' => 'a' ),
64 array( '1' => 'abc',
65 '5' => '!' ,
66 '2' => null ,
67 '7' => '' ),
69 array( '1' => '100',
70 '2' => '25' ,
71 '3' => '36' ),
73 array( '1' => 5 ,
74 '2' => '30' ,
75 '3' => 2 )
78 $res_str .= sort_arrays( 'en_US', $test_params );
80 // Sort an array in SORT_STRING mode using en_US locale.
81 $test_params = array(
82 array( '1' => '100',
83 '2' => '25' ,
84 '3' => '36' ),
86 array( '1' => 5 ,
87 '2' => '30' ,
88 '3' => 2 ),
90 array( '1' => 'd' ,
91 '2' => '' ,
92 '3' => ' a' ),
94 array( '1' => 'y' ,
95 '2' => 'k' ,
96 '3' => 'i' )
99 $res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING );
101 // Sort a non-ASCII array using ru_RU locale.
102 $test_params = array(
103 array( 'п' => 'у',
104 'б' => 'в',
105 'е' => 'а' ),
107 array( '1' => 'п',
108 '4' => '',
109 '7' => 'd',
110 '2' => 'пп' )
113 $res_str .= sort_arrays( 'ru_RU', $test_params );
116 // Sort an array using Lithuanian locale.
117 $test_params = array(
118 array( 'd' => 'y',
119 'c' => 'i',
120 'a' => 'k' )
123 $res_str .= sort_arrays( 'lt_LT', $test_params );
125 return $res_str . "\n";
128 include_once( 'ut_common.inc' );
129 ut_run();
131 abstract final class ZendGoodExtIntlTestsCollatorAsortVariant2 {
132 public static $test_num;