1--TEST--
2Regression: sort() and copy-on-write.
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7/*
8 * Check if collator_sort() properly supports copy-on-write.
9 */
10
11
12/* Create two copies of the given array.
13 * Sort the array and the first copy.
14 * Check if the second copy remains unsorted.
15 */
16function test_COW( $locale, $test_array )
17{
18    $res_str = '';
19
20    $coll = ut_coll_create( $locale );
21
22    // Create two copies of the given array.
23    $copy1 = $test_array;
24    $copy2 = $test_array;
25
26    // Sort given array and the first copy of it.
27    ut_coll_sort( $coll, $test_array );
28    ut_coll_sort( $coll, $copy1      );
29
30    // Return contents of all the arrays.
31    // The second copy should remain unsorted.
32    $res_str .= dump( $test_array ) . "\n";
33    $res_str .= dump( $copy1 ) . "\n";
34    $res_str .= dump( $copy2 ) . "\n";
35
36    return $res_str;
37}
38
39function ut_main()
40{
41    $res_str = '';
42
43    $a1 = array( 'b', 'a', 'c' );
44    $a2 = array( 'в', 'а', 'б' );
45
46    $res_str .= test_COW( 'en_US', $a1 );
47    $res_str .= test_COW( 'ru_RU', $a2 );
48
49    return $res_str;
50}
51
52require_once( 'ut_common.inc' );
53ut_run();
54?>
55--EXPECT--
56array (
57  0 => 'a',
58  1 => 'b',
59  2 => 'c',
60)
61array (
62  0 => 'a',
63  1 => 'b',
64  2 => 'c',
65)
66array (
67  0 => 'b',
68  1 => 'a',
69  2 => 'c',
70)
71array (
72  0 => 'а',
73  1 => 'б',
74  2 => 'в',
75)
76array (
77  0 => 'а',
78  1 => 'б',
79  2 => 'в',
80)
81array (
82  0 => 'в',
83  1 => 'а',
84  2 => 'б',
85)
86