Annotation of embedaddon/php/ext/standard/tests/array/shuffle_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test shuffle() function : usage variation - arrays with diff heredoc strings
3: --FILE--
4: <?php
5: /* Prototype : bool shuffle(array $array_arg)
6: * Description: Randomly shuffle the contents of an array
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Test behaviour of shuffle() when an array of heredoc strings is passed to
12: * 'array_arg' argument of the function
13: */
14:
15: echo "*** Testing shuffle() : with array containing heredoc strings ***\n";
16:
17: // defining different heredoc strings
18: $empty_heredoc = <<<EOT
19: EOT;
20:
21: $heredoc_with_newline = <<<EOT
22: \n
23: EOT;
24:
25: $heredoc_with_characters = <<<EOT
26: first line of heredoc string
27: second line of heredoc string
28: third line of heredocstring
29: EOT;
30:
31: $heredoc_with_newline_and_tabs = <<<EOT
32: hello\tworld\nhello\nworld\n
33: EOT;
34:
35: $heredoc_with_alphanumerics = <<<EOT
36: hello123world456
37: 1234hello\t1234
38: EOT;
39:
40: $heredoc_with_embedded_nulls = <<<EOT
41: hello\0world\0hello
42: \0hello\0
43: EOT;
44:
45: // defining array with values as heredoc strings
46: $heredoc_array = array(
47: $empty_heredoc,
48: $heredoc_with_newline,
49: $heredoc_with_characters,
50: $heredoc_with_newline_and_tabs,
51: $heredoc_with_alphanumerics,
52: $heredoc_with_embedded_nulls
53: );
54:
55: // defining array with keys as heredoc strings
56: $heredoc_asso_array = array(
57: $empty_heredoc => "heredoc1",
58: $heredoc_with_newline => "heredoc2",
59: $heredoc_with_characters => "heredoc3",
60: $heredoc_with_newline_and_tabs => "heredoc3",
61: $heredoc_with_alphanumerics => "heredoc4",
62: $heredoc_with_embedded_nulls => "heredoc5"
63: );
64:
65: // test shuffle() with array containing heredoc strings as values
66: echo "\n-- with array of heredoc strings --\n";
67: var_dump( shuffle($heredoc_array) );
68: echo "\nThe output array is:\n";
69: var_dump( $heredoc_array );
70:
71: // test shuffle() with array containing heredoc strings as its keys
72: echo "\n-- with array having heredoc strings as keys --\n";
73: var_dump( shuffle($heredoc_asso_array) );
74: echo "\nThe output array is:\n";
75: var_dump( $heredoc_asso_array );
76:
77: echo "Done";
78: ?>
79: --EXPECTREGEX--
80: \*\*\* Testing shuffle\(\) : with array containing heredoc strings \*\*\*
81:
82: -- with array of heredoc strings --
83: bool\(true\)
84:
85: The output array is:
86: array\(6\) {
87: \[0\]=>
88: string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
89: \[1\]=>
90: string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
91: \[2\]=>
92: string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
93: \[3\]=>
94: string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
95: \[4\]=>
96: string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
97: \[5\]=>
98: string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
99: }
100:
101: -- with array having heredoc strings as keys --
102: bool\(true\)
103:
104: The output array is:
105: array\(6\) {
106: \[0\]=>
107: string\(8\) "[heredoc 1-5]*"
108: \[1\]=>
109: string\(8\) "[heredoc 1-5]*"
110: \[2\]=>
111: string\(8\) "[heredoc 1-5]*"
112: \[3\]=>
113: string\(8\) "[heredoc 1-5]*"
114: \[4\]=>
115: string\(8\) "[heredoc 1-5]*"
116: \[5\]=>
117: string\(8\) "[heredoc 1-5]*"
118: }
119: Done
120:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>