diff options
Diffstat (limited to 'tests/strings')
| -rw-r--r-- | tests/strings/001.phpt | 84 | ||||
| -rw-r--r-- | tests/strings/002.phpt | 9 | ||||
| -rw-r--r-- | tests/strings/bug26703.phpt | 2 | ||||
| -rw-r--r-- | tests/strings/offsets_chaining_1.phpt | 2 | ||||
| -rw-r--r-- | tests/strings/offsets_chaining_2.phpt | 11 | ||||
| -rw-r--r-- | tests/strings/offsets_chaining_3.phpt | 2 | ||||
| -rw-r--r-- | tests/strings/offsets_chaining_4.phpt | 11 | ||||
| -rw-r--r-- | tests/strings/offsets_chaining_5.phpt | 12 | ||||
| -rw-r--r-- | tests/strings/offsets_general.phpt | 50 |
9 files changed, 60 insertions, 123 deletions
diff --git a/tests/strings/001.phpt b/tests/strings/001.phpt index bf1fb67711..0f1f749459 100644 --- a/tests/strings/001.phpt +++ b/tests/strings/001.phpt @@ -3,8 +3,6 @@ String functions --FILE-- <?php -error_reporting(0); - echo "Testing strtok: "; $str = "testing 1/2\\3"; @@ -13,58 +11,58 @@ $tok2 = strtok("/"); $tok3 = strtok("\\"); $tok4 = strtok("."); if ($tok1 != "testing") { - echo("failed 1\n"); + echo("failed 1\n"); } elseif ($tok2 != "1") { - echo("failed 2\n"); + echo("failed 2\n"); } elseif ($tok3 != "2") { - echo("failed 3\n"); + echo("failed 3\n"); } elseif ($tok4 != "3") { - echo("failed 4\n"); + echo("failed 4\n"); } else { - echo("passed\n"); + echo("passed\n"); } echo "Testing strstr: "; $test = "This is a test"; -$found1 = strstr($test, 32); +$found1 = strstr($test, chr(32)); $found2 = strstr($test, "a "); if ($found1 != " is a test") { - echo("failed 1\n"); + echo("failed 1\n"); } elseif ($found2 != "a test") { - echo("failed 2\n"); + echo("failed 2\n"); } else { - echo("passed\n"); + echo("passed\n"); } echo "Testing strrchr: "; $test = "fola fola blakken"; $found1 = strrchr($test, "b"); -$found2 = strrchr($test, 102); +$found2 = strrchr($test, chr(102)); if ($found1 != "blakken") { - echo("failed 1\n"); + echo("failed 1\n"); } elseif ($found2 != "fola blakken") { - echo("failed 2\n"); + echo("failed 2\n"); } else { - echo("passed\n"); + echo("passed\n"); } echo "Testing strtoupper: "; $test = "abCdEfg"; $upper = strtoupper($test); if ($upper == "ABCDEFG") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing strtolower: "; $test = "ABcDeFG"; $lower = strtolower($test); if ($lower == "abcdefg") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing substr: "; @@ -81,9 +79,9 @@ $tests++; if (substr($string, -1, -2) == "") { $ok++; } $tests++; if (substr($string, -3, -2) == "3") { $ok++; } if ($tests == $ok) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } $raw = ' !"#$%&\'()*+,-./0123456789:;<=>?' @@ -98,17 +96,17 @@ $correct = '%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3 . '%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~' . '%00'; if ($encoded == $correct) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing rawurldecode: "; $decoded = rawurldecode($correct); if ($decoded == $raw) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing urlencode: "; @@ -118,62 +116,62 @@ $correct = '+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E% . '%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E' . '%00'; if ($encoded == $correct) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing urldecode: "; $decoded = urldecode($correct); if ($decoded == $raw) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing quotemeta: "; $raw = "a.\\+*?" . chr(91) . "^" . chr(93) . "b\$c"; $quoted = quotemeta($raw); if ($quoted == "a\\.\\\\\\+\\*\\?\\[\\^\\]b\\\$c") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing ufirst: "; $str = "fahrvergnuegen"; $uc = ucfirst($str); if ($uc == "Fahrvergnuegen") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing strtr: "; $str = "test abcdefgh"; $tr = strtr($str, "def", "456"); if ($tr == "t5st abc456gh") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing addslashes: "; $str = "\"\\'"; $as = addslashes($str); if ($as == "\\\"\\\\\\'") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing stripslashes: "; $str = "\$\\'"; $ss = stripslashes($str); if ($ss == "\$'") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } @@ -185,9 +183,9 @@ $ui2 = uniqid($str, true); $len = 29; if (strlen($ui1) == strlen($ui2) && strlen($ui1) == $len && $ui1 != $ui2) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo "Testing uniqid(false): "; @@ -199,9 +197,9 @@ $ui2 = uniqid($str); $len = strncasecmp(PHP_OS, 'CYGWIN', 6) ? 19 : 29; if (strlen($ui1) == strlen($ui2) && strlen($ui1) == $len && $ui1 != $ui2) { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } ?> diff --git a/tests/strings/002.phpt b/tests/strings/002.phpt index 5e82091088..a43a68c88b 100644 --- a/tests/strings/002.phpt +++ b/tests/strings/002.phpt @@ -2,7 +2,6 @@ Formatted print functions --FILE-- <?php -error_reporting(0); $fp = fopen("php://stdout", "w") or die("Arrggsgg!!"); $x = fprintf($fp, "fprintf test 1:%.5s", "abcdefghij"); @@ -40,7 +39,11 @@ printf("printf test 26:%2\$d %1\$d\n", 1, 2); printf("printf test 27:%3\$d %d %d\n", 1, 2, 3); printf("printf test 28:%2\$02d %1\$2d\n", 1, 2); printf("printf test 29:%2\$-2d %1\$2d\n", 1, 2); -print("printf test 30:"); printf("%0\$s", 1); print("x\n"); +try { + print("printf test 30:"); printf("%0\$s", 1); print("x\n"); +} catch(\ValueError $e) { + print('Error found: '.$e->getMessage()."\n"); +} vprintf("vprintf test 1:%2\$-2d %1\$2d\n", array(1, 2)); @@ -79,5 +82,5 @@ printf test 26:2 1 printf test 27:3 1 2 printf test 28:02 1 printf test 29:2 1 -printf test 30:x +printf test 30:Error found: Argument number must be greater than zero vprintf test 1:2 1 diff --git a/tests/strings/bug26703.phpt b/tests/strings/bug26703.phpt index bea8fb1214..4e48845fdf 100644 --- a/tests/strings/bug26703.phpt +++ b/tests/strings/bug26703.phpt @@ -8,7 +8,7 @@ highlight.default=#0000BB highlight.html=#000000 --FILE-- <?php - highlight_string('<?php echo "foo[] $a \n"; ?>'); + highlight_string('<?php echo "foo[] $a \n"; ?>'); ?> --EXPECT-- <code><span style="color: #000000"> diff --git a/tests/strings/offsets_chaining_1.phpt b/tests/strings/offsets_chaining_1.phpt index 0c3c0074b1..18b6fa2f9d 100644 --- a/tests/strings/offsets_chaining_1.phpt +++ b/tests/strings/offsets_chaining_1.phpt @@ -1,7 +1,5 @@ --TEST-- testing the behavior of string offset chaining ---INI-- -error_reporting=E_ALL | E_DEPRECATED --FILE-- <?php $string = "foobar"; diff --git a/tests/strings/offsets_chaining_2.phpt b/tests/strings/offsets_chaining_2.phpt deleted file mode 100644 index 0c3c0074b1..0000000000 --- a/tests/strings/offsets_chaining_2.phpt +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -testing the behavior of string offset chaining ---INI-- -error_reporting=E_ALL | E_DEPRECATED ---FILE-- -<?php -$string = "foobar"; -var_dump($string[0][0][0][0]); -?> ---EXPECT-- -string(1) "f" diff --git a/tests/strings/offsets_chaining_3.phpt b/tests/strings/offsets_chaining_3.phpt index fc11b8d797..12cac5917f 100644 --- a/tests/strings/offsets_chaining_3.phpt +++ b/tests/strings/offsets_chaining_3.phpt @@ -1,7 +1,5 @@ --TEST-- testing the behavior of string offset chaining ---INI-- -error_reporting=E_ALL | E_DEPRECATED --FILE-- <?php $string = "foobar"; diff --git a/tests/strings/offsets_chaining_4.phpt b/tests/strings/offsets_chaining_4.phpt deleted file mode 100644 index fc11b8d797..0000000000 --- a/tests/strings/offsets_chaining_4.phpt +++ /dev/null @@ -1,11 +0,0 @@ ---TEST-- -testing the behavior of string offset chaining ---INI-- -error_reporting=E_ALL | E_DEPRECATED ---FILE-- -<?php -$string = "foobar"; -var_dump(isset($string[0][0][0][0])); -?> ---EXPECT-- -bool(true) diff --git a/tests/strings/offsets_chaining_5.phpt b/tests/strings/offsets_chaining_5.phpt index efcf2f3074..49f062463f 100644 --- a/tests/strings/offsets_chaining_5.phpt +++ b/tests/strings/offsets_chaining_5.phpt @@ -1,27 +1,25 @@ --TEST-- testing the behavior of string offset chaining ---INI-- -error_reporting=E_ALL | E_DEPRECATED --FILE-- <?php $array = array('expected_array' => "foobar"); var_dump(isset($array['expected_array'])); var_dump($array['expected_array']); var_dump(isset($array['expected_array']['foo'])); -var_dump($array['expected_array']['foo']); +var_dump($array['expected_array']['0foo']); var_dump(isset($array['expected_array']['foo']['bar'])); -var_dump($array['expected_array']['foo']['bar']); +var_dump($array['expected_array']['0foo']['0bar']); ?> --EXPECTF-- bool(true) string(6) "foobar" bool(false) -Warning: Illegal string offset 'foo' in %soffsets_chaining_5.php on line %d +Warning: Illegal string offset "0foo" in %s on line %d string(1) "f" bool(false) -Warning: Illegal string offset 'foo' in %soffsets_chaining_5.php on line %d +Warning: Illegal string offset "0foo" in %s on line %d -Warning: Illegal string offset 'bar' in %soffsets_chaining_5.php on line %d +Warning: Illegal string offset "0bar" in %s on line %d string(1) "f" diff --git a/tests/strings/offsets_general.phpt b/tests/strings/offsets_general.phpt index b2ceea088a..16960eac95 100644 --- a/tests/strings/offsets_general.phpt +++ b/tests/strings/offsets_general.phpt @@ -9,55 +9,19 @@ var_dump($string[0]); var_dump($string[1]); var_dump(isset($string[0])); var_dump(isset($string[0][0])); -var_dump($string["foo"]); +try { + var_dump($string["foo"]); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(isset($string["foo"]["bar"])); -const FOO_DEPRECATED = "BAR"{0}; -var_dump(FOO_DEPRECATED); -var_dump([$string{0}]); // 1 notice -var_dump($string{1}); -var_dump(isset($string{0})); -var_dump(isset($string{0}{0})); // 2 notices -var_dump($string{"foo"}); -var_dump(isset($string{"foo"}{"bar"})); // 2 notices ?> ---EXPECTF-- - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d +--EXPECT-- string(1) "B" string(1) "f" string(1) "o" bool(true) bool(true) - -Warning: Illegal string offset 'foo' in %s line %d -string(1) "f" -bool(false) -string(1) "B" -array(1) { - [0]=> - string(1) "f" -} -string(1) "o" -bool(true) -bool(true) - -Warning: Illegal string offset 'foo' in %s line %d -string(1) "f" +Cannot access offset of type string on string bool(false) |
