Annotation of embedaddon/php/ext/intl/tests/collator_sort_with_sort_keys.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: sort_with_sort_keys()
        !             3: --SKIPIF--
        !             4: <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
        !             5: --FILE--
        !             6: <?php
        !             7: 
        !             8: /*
        !             9:  * Sort arrays using various locales.
        !            10:  */
        !            11: 
        !            12: 
        !            13: $test_num = 1;
        !            14: 
        !            15: /*
        !            16:  * Sort arrays in the given list using specified locale.
        !            17:  */
        !            18: function sort_arrays( $locale, $arrays )
        !            19: {
        !            20:     $res_str = '';
        !            21: 
        !            22:     $coll = ut_coll_create( $locale );
        !            23: 
        !            24:     foreach( $arrays as $array )
        !            25:     {
        !            26:         // Sort array values
        !            27:         $res_val = ut_coll_sort_with_sort_keys( $coll, $array );
        !            28: 
        !            29:         // Concatenate the sorted array and function result
        !            30:         // with output string.
        !            31:         $res_dump = "\n" . dump( $array ) .
        !            32:                     "\n Result: " . dump( $res_val );
        !            33:         
        !            34:         
        !            35:         // Preppend test signature to output string
        !            36:         $md5 = md5( $res_dump );
        !            37: 
        !            38:         global $test_num;
        !            39: 
        !            40:         $res_str .= "\n\n".
        !            41:                     "Test $test_num.$md5:" .
        !            42:                     $res_dump;
        !            43:         ++$test_num;
        !            44:     }
        !            45: 
        !            46:     return $res_str;
        !            47: }
        !            48: 
        !            49: 
        !            50: function ut_main()
        !            51: {
        !            52:     global $test_num;
        !            53:     $test_num = 1;
        !            54:     $res_str = '';
        !            55: 
        !            56:     // Sort an array in SORT_REGULAR mode using en_US locale.
        !            57:     $test_params = array(
        !            58:         array( 'abc', 'abd', 'aaa' ),
        !            59:         array( 'm'  , '1'  , '_'   ),
        !            60:         array( 'a'  , 'aaa', 'aa'  ),
        !            61:         array( 'ba' , 'b'  , 'ab'  ),
        !            62:         array( 'e'  , 'c'  , 'a'   ),
        !            63:         array( 'd'  , ''   , ' a'  ),
        !            64:         array( 'd ' , 'f ' , ' a'  ),
        !            65:         array( 'a'  , null , '3'   ),
        !            66:         array( 'y'  , 'i'  , 'k'   )
        !            67:     );
        !            68: 
        !            69:     $res_str .= sort_arrays( 'en_US', $test_params );
        !            70: 
        !            71:     // Sort a non-ASCII array using ru_RU locale.
        !            72:     $test_params = array(
        !            73:         array( 'абг', 'абв', 'ааа', 'abc' ),
        !            74:         array( 'аа', 'ааа', 'а' )
        !            75:     );
        !            76: 
        !            77:     $res_str .= sort_arrays( 'ru_RU', $test_params );
        !            78: 
        !            79:     // Array with data for sorting.
        !            80:     $test_params = array(
        !            81:         array( 'y'  , 'i'  , 'k'   )
        !            82:     );
        !            83: 
        !            84:     // Sort an array using Lithuanian locale.
        !            85:     $res_str .= sort_arrays( 'lt_LT', $test_params );
        !            86: 
        !            87:     return $res_str . "\n";
        !            88: }
        !            89: 
        !            90: include_once( 'ut_common.inc' );
        !            91: ut_run();
        !            92: ?>
        !            93: --EXPECT--
        !            94: Test 1.e8f1cd28133d79ecd660002f1c660d0e:
        !            95: array (
        !            96:   0 => 'aaa',
        !            97:   1 => 'abc',
        !            98:   2 => 'abd',
        !            99: )
        !           100:  Result: true
        !           101: 
        !           102: Test 2.c2ded12173dd2996927378cae37eb275:
        !           103: array (
        !           104:   0 => '_',
        !           105:   1 => '1',
        !           106:   2 => 'm',
        !           107: )
        !           108:  Result: true
        !           109: 
        !           110: Test 3.54071c968d71cb98c5d379145f8d7d38:
        !           111: array (
        !           112:   0 => 'a',
        !           113:   1 => 'aa',
        !           114:   2 => 'aaa',
        !           115: )
        !           116:  Result: true
        !           117: 
        !           118: Test 4.19abe63d6f6dfef65b0e3c9ab4826b07:
        !           119: array (
        !           120:   0 => 'ab',
        !           121:   1 => 'b',
        !           122:   2 => 'ba',
        !           123: )
        !           124:  Result: true
        !           125: 
        !           126: Test 5.9a8dc0a9bc771368c2f1fc3d02754610:
        !           127: array (
        !           128:   0 => 'a',
        !           129:   1 => 'c',
        !           130:   2 => 'e',
        !           131: )
        !           132:  Result: true
        !           133: 
        !           134: Test 6.923d65739c5219c634616ffd100a50e4:
        !           135: array (
        !           136:   0 => '',
        !           137:   1 => ' a',
        !           138:   2 => 'd',
        !           139: )
        !           140:  Result: true
        !           141: 
        !           142: Test 7.289bc2f28e87d3201ec9d7e8477ae1b0:
        !           143: array (
        !           144:   0 => ' a',
        !           145:   1 => 'd ',
        !           146:   2 => 'f ',
        !           147: )
        !           148:  Result: true
        !           149: 
        !           150: Test 8.de0fd958484f2377a645835d7fbcf124:
        !           151: array (
        !           152:   0 => NULL,
        !           153:   1 => '3',
        !           154:   2 => 'a',
        !           155: )
        !           156:  Result: true
        !           157: 
        !           158: Test 9.dd2b8f0adb37c45d528cad1a0cc0f361:
        !           159: array (
        !           160:   0 => 'i',
        !           161:   1 => 'k',
        !           162:   2 => 'y',
        !           163: )
        !           164:  Result: true
        !           165: 
        !           166: Test 10.ca0e38a2e3147dd97070f2128f140934:
        !           167: array (
        !           168:   0 => 'abc',
        !           169:   1 => 'ааа',
        !           170:   2 => 'абв',
        !           171:   3 => 'абг',
        !           172: )
        !           173:  Result: true
        !           174: 
        !           175: Test 11.91480b10473a0c96a4cd6d88c23c577a:
        !           176: array (
        !           177:   0 => 'а',
        !           178:   1 => 'аа',
        !           179:   2 => 'ааа',
        !           180: )
        !           181:  Result: true
        !           182: 
        !           183: Test 12.fdd3fe3981476039164aa000bf9177f2:
        !           184: array (
        !           185:   0 => 'i',
        !           186:   1 => 'y',
        !           187:   2 => 'k',
        !           188: )
        !           189:  Result: true

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>