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

1.1     ! misho       1: --TEST--
        !             2: sort()
        !             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:  * Sort arrays using various locales.
        !            11:  */
        !            12: 
        !            13: 
        !            14: $test_num = 1;
        !            15: 
        !            16: /*
        !            17:  * Sort arrays in the given list using specified locale.
        !            18:  */
        !            19: function sort_arrays( $locale, $arrays, $sort_flag = Collator::SORT_REGULAR )
        !            20: {
        !            21:     $res_str = '';
        !            22: 
        !            23:     $coll = ut_coll_create( $locale );
        !            24: 
        !            25:     foreach( $arrays as $array )
        !            26:     {
        !            27:         // Sort array values
        !            28:         $res_val = ut_coll_sort( $coll, $array, $sort_flag );
        !            29: 
        !            30:         // Concatenate the sorted array and function result
        !            31:         // with output string.
        !            32:         $res_dump = "\n" . dump( $array ) .
        !            33:                     "\n Result: " . dump( $res_val );
        !            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: function ut_main()
        !            50: {
        !            51:     global $test_num;
        !            52:     $test_num = 1;
        !            53:     $res_str = '';
        !            54: 
        !            55:     // Sort an array in SORT_REGULAR mode using en_US locale.
        !            56:     $test_params = array(
        !            57:         array( 'abc', 'abd', 'aaa' ),
        !            58:         array( 'm'  , '1'  , '_'   ),
        !            59:         array( 'a'  , 'aaa', 'aa'  ),
        !            60:         array( 'ba' , 'b'  , 'ab'  ),
        !            61:         array( 'e'  , 'c'  , 'a'   ),
        !            62:         array( '100', '25' , '36'  ),
        !            63:         array( 5    , '30' , 2     ),
        !            64:         array( 'd'  , ''   , ' a'  ),
        !            65:         array( 'd ' , 'f ' , ' a'  ),
        !            66:         array( 'a'  , null , '3'   ),
        !            67:         array( 'y'  , 'k'  , 'i' )
        !            68:     );
        !            69: 
        !            70:     $res_str .= sort_arrays( 'en_US', $test_params );
        !            71: 
        !            72:     $test_params = array(
        !            73:         array( '100', '25' , '36'  ),
        !            74:         array( 5    , '30' , 2     ),
        !            75:         array( 'd'  , ''   , ' a'  ),
        !            76:         array( 'y'  , 'k'  , 'i' )
        !            77:     );
        !            78: 
        !            79:     // Sort in en_US locale with SORT_STRING flag
        !            80:     $res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING );
        !            81: 
        !            82: 
        !            83:     // Sort a non-ASCII array using ru_RU locale.
        !            84:     $test_params = array(
        !            85:         array( 'абг', 'абв', 'ааа', 'abc' ),
        !            86:         array( 'аа', 'ааа' , 'а' )
        !            87:     );
        !            88: 
        !            89:     $res_str .= sort_arrays( 'ru_RU', $test_params );
        !            90: 
        !            91:     // Sort an array using Lithuanian locale.
        !            92:     $test_params = array(
        !            93:         array( 'y'  , 'k'  , 'i' )
        !            94:     );
        !            95: 
        !            96:     $res_str .= sort_arrays( 'lt_LT', $test_params );
        !            97: 
        !            98:     return $res_str;
        !            99: }
        !           100: 
        !           101: include_once( 'ut_common.inc' );
        !           102: ut_run();
        !           103: ?>
        !           104: --EXPECT--
        !           105: Test 1.e8f1cd28133d79ecd660002f1c660d0e:
        !           106: array (
        !           107:   0 => 'aaa',
        !           108:   1 => 'abc',
        !           109:   2 => 'abd',
        !           110: )
        !           111:  Result: true
        !           112: 
        !           113: Test 2.c2ded12173dd2996927378cae37eb275:
        !           114: array (
        !           115:   0 => '_',
        !           116:   1 => '1',
        !           117:   2 => 'm',
        !           118: )
        !           119:  Result: true
        !           120: 
        !           121: Test 3.54071c968d71cb98c5d379145f8d7d38:
        !           122: array (
        !           123:   0 => 'a',
        !           124:   1 => 'aa',
        !           125:   2 => 'aaa',
        !           126: )
        !           127:  Result: true
        !           128: 
        !           129: Test 4.19abe63d6f6dfef65b0e3c9ab4826b07:
        !           130: array (
        !           131:   0 => 'ab',
        !           132:   1 => 'b',
        !           133:   2 => 'ba',
        !           134: )
        !           135:  Result: true
        !           136: 
        !           137: Test 5.9a8dc0a9bc771368c2f1fc3d02754610:
        !           138: array (
        !           139:   0 => 'a',
        !           140:   1 => 'c',
        !           141:   2 => 'e',
        !           142: )
        !           143:  Result: true
        !           144: 
        !           145: Test 6.ab530b060e5e54a65bfb8b9f8fc61870:
        !           146: array (
        !           147:   0 => '25',
        !           148:   1 => '36',
        !           149:   2 => '100',
        !           150: )
        !           151:  Result: true
        !           152: 
        !           153: Test 7.0718dd838509017bded2ed307a6e785f:
        !           154: array (
        !           155:   0 => 2,
        !           156:   1 => 5,
        !           157:   2 => '30',
        !           158: )
        !           159:  Result: true
        !           160: 
        !           161: Test 8.923d65739c5219c634616ffd100a50e4:
        !           162: array (
        !           163:   0 => '',
        !           164:   1 => ' a',
        !           165:   2 => 'd',
        !           166: )
        !           167:  Result: true
        !           168: 
        !           169: Test 9.289bc2f28e87d3201ec9d7e8477ae1b0:
        !           170: array (
        !           171:   0 => ' a',
        !           172:   1 => 'd ',
        !           173:   2 => 'f ',
        !           174: )
        !           175:  Result: true
        !           176: 
        !           177: Test 10.de0fd958484f2377a645835d7fbcf124:
        !           178: array (
        !           179:   0 => NULL,
        !           180:   1 => '3',
        !           181:   2 => 'a',
        !           182: )
        !           183:  Result: true
        !           184: 
        !           185: Test 11.dd2b8f0adb37c45d528cad1a0cc0f361:
        !           186: array (
        !           187:   0 => 'i',
        !           188:   1 => 'k',
        !           189:   2 => 'y',
        !           190: )
        !           191:  Result: true
        !           192: 
        !           193: Test 12.1e6b4d6f7df9d4580317634ea46d8208:
        !           194: array (
        !           195:   0 => '100',
        !           196:   1 => '25',
        !           197:   2 => '36',
        !           198: )
        !           199:  Result: true
        !           200: 
        !           201: Test 13.cec115dc9850b98dfbdf102efa09e61b:
        !           202: array (
        !           203:   0 => 2,
        !           204:   1 => '30',
        !           205:   2 => 5,
        !           206: )
        !           207:  Result: true
        !           208: 
        !           209: Test 14.923d65739c5219c634616ffd100a50e4:
        !           210: array (
        !           211:   0 => '',
        !           212:   1 => ' a',
        !           213:   2 => 'd',
        !           214: )
        !           215:  Result: true
        !           216: 
        !           217: Test 15.dd2b8f0adb37c45d528cad1a0cc0f361:
        !           218: array (
        !           219:   0 => 'i',
        !           220:   1 => 'k',
        !           221:   2 => 'y',
        !           222: )
        !           223:  Result: true
        !           224: 
        !           225: Test 16.49056308afb2b800363c5baa735ed247:
        !           226: array (
        !           227:   0 => 'ааа',
        !           228:   1 => 'абв',
        !           229:   2 => 'абг',
        !           230:   3 => 'abc',
        !           231: )
        !           232:  Result: true
        !           233: 
        !           234: Test 17.91480b10473a0c96a4cd6d88c23c577a:
        !           235: array (
        !           236:   0 => 'а',
        !           237:   1 => 'аа',
        !           238:   2 => 'ааа',
        !           239: )
        !           240:  Result: true
        !           241: 
        !           242: Test 18.fdd3fe3981476039164aa000bf9177f2:
        !           243: array (
        !           244:   0 => 'i',
        !           245:   1 => 'y',
        !           246:   2 => 'k',
        !           247: )
        !           248:  Result: true

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