Annotation of embedaddon/php/ext/standard/tests/strings/strtok_variation3.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test strtok() function : usage variations - with heredoc strings
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string strtok ( str $str, str $token )
                      6:  * Description: splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /*
                     11:  * Testing strtok() : with heredoc strings
                     12: */
                     13: 
                     14: echo "*** Testing strtok() : with heredoc strings ***\n";
                     15: 
                     16: // defining different heredoc strings
                     17: $empty_heredoc = <<<EOT
                     18: EOT;
                     19: 
                     20: $heredoc_with_newline = <<<EOT
                     21: \n
                     22: 
                     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: $heredoc_strings = array(
                     46:                    $empty_heredoc,
                     47:                    $heredoc_with_newline,
                     48:                    $heredoc_with_characters,
                     49:                    $heredoc_with_newline_and_tabs,
                     50:                    $heredoc_with_alphanumerics,
                     51:                    $heredoc_with_embedded_nulls
                     52:                    );
                     53: 
                     54: // loop through each element of the array and check the working of strtok()
                     55: // when supplied with different string values
                     56: 
                     57: $count = 1;
                     58: foreach($heredoc_strings as $string)  {
                     59:   echo "\n--- Iteration $count ---\n";
                     60:   var_dump( strtok($string, "5o\0\n\t") );
                     61:   for($counter = 1; $counter <= 10; $counter++)  {
                     62:     var_dump( strtok("5o\0\n\t") );
                     63:   }
                     64:   $count++;
                     65: }
                     66: 
                     67: 
                     68: echo "Done\n";
                     69: ?>
                     70: --EXPECTF--
                     71: *** Testing strtok() : with heredoc strings ***
                     72: 
                     73: --- Iteration 1 ---
                     74: bool(false)
                     75: bool(false)
                     76: bool(false)
                     77: bool(false)
                     78: bool(false)
                     79: bool(false)
                     80: bool(false)
                     81: bool(false)
                     82: bool(false)
                     83: bool(false)
                     84: bool(false)
                     85: 
                     86: --- Iteration 2 ---
                     87: bool(false)
                     88: bool(false)
                     89: bool(false)
                     90: bool(false)
                     91: bool(false)
                     92: bool(false)
                     93: bool(false)
                     94: bool(false)
                     95: bool(false)
                     96: bool(false)
                     97: bool(false)
                     98: 
                     99: --- Iteration 3 ---
                    100: string(11) "first line "
                    101: string(7) "f hered"
                    102: string(8) "c string"
                    103: string(3) "sec"
                    104: string(8) "nd line "
                    105: string(7) "f hered"
                    106: string(8) "c string"
                    107: string(11) "third line "
                    108: string(7) "f hered"
                    109: string(7) "cstring"
                    110: bool(false)
                    111: 
                    112: --- Iteration 4 ---
                    113: string(4) "hell"
                    114: string(1) "w"
                    115: string(3) "rld"
                    116: string(4) "hell"
                    117: string(1) "w"
                    118: string(3) "rld"
                    119: bool(false)
                    120: bool(false)
                    121: bool(false)
                    122: bool(false)
                    123: bool(false)
                    124: 
                    125: --- Iteration 5 ---
                    126: string(4) "hell"
                    127: string(4) "123w"
                    128: string(4) "rld4"
                    129: string(1) "6"
                    130: string(8) "1234hell"
                    131: string(4) "1234"
                    132: bool(false)
                    133: bool(false)
                    134: bool(false)
                    135: bool(false)
                    136: bool(false)
                    137: 
                    138: --- Iteration 6 ---
                    139: string(4) "hell"
                    140: string(1) "w"
                    141: string(3) "rld"
                    142: string(4) "hell"
                    143: string(4) "hell"
                    144: bool(false)
                    145: bool(false)
                    146: bool(false)
                    147: bool(false)
                    148: bool(false)
                    149: bool(false)
                    150: Done

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