Annotation of embedaddon/php/ext/standard/tests/strings/chunk_split_variation12.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test chunk_split() function : usage variations - different heredoc strings for 'ending' argument 
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : string chunk_split(string $str [, int $chunklen [, string $ending]])
        !             6:  * Description: Returns split line
        !             7:  * Source code: ext/standard/string.c
        !             8:  * Alias to functions: none
        !             9: */
        !            10: 
        !            11: /*
        !            12: * passing different heredoc strings as 'ending' argument to chunk_split() 
        !            13: * 'chunklen' argument is set to 10
        !            14: */
        !            15: 
        !            16: echo "*** Testing chunk_split() : different heredoc strings for 'ending' argument ***\n";
        !            17: 
        !            18: // Initializing required variables
        !            19: $chunklen = 10;
        !            20: $str = "This is str to check with heredoc ending.This\tcontains,\nspeci@! ch@r$ __with wrong \k escape char 222.";
        !            21: 
        !            22: // Null heredoc string
        !            23: $heredoc_null = <<<EOT1
        !            24: EOT1;
        !            25: 
        !            26: // heredoc string with single character
        !            27: $heredoc_char = <<<EOT2
        !            28: a
        !            29: EOT2;
        !            30: 
        !            31: // simple heredoc string
        !            32: $heredoc_str = <<<EOT3
        !            33: This is simple heredoc string
        !            34: EOT3;
        !            35: 
        !            36: // heredoc with special characters
        !            37: $heredoc_spchar = <<<EOT4
        !            38: This checks with $, %, &, chars
        !            39: EOT4;
        !            40: 
        !            41: // blank heredoc string
        !            42: $heredoc_blank = <<<EOT5
        !            43: 
        !            44: EOT5;
        !            45: 
        !            46: // heredoc with different white space characters
        !            47: $heredoc_escchar = <<<EOT6
        !            48: This checks\t and \nwhite space chars
        !            49: EOT6;
        !            50: 
        !            51: // heredoc with multiline
        !            52: $heredoc_multiline= <<<EOT7
        !            53: This is to check chunk_split
        !            54: function with multiline
        !            55: heredoc
        !            56: EOT7;
        !            57: 
        !            58: // heredoc with quotes and slashes
        !            59: $heredoc_quote_slash = <<<EOT8
        !            60: "To check " in heredoc".I'm sure it'll \work!
        !            61: EOT8;
        !            62: 
        !            63: // different heredoc strings for 'ending'
        !            64: $heredoc_arr = array(
        !            65:   $heredoc_null,
        !            66:   $heredoc_blank,
        !            67:   $heredoc_char,
        !            68:   $heredoc_str,
        !            69:   $heredoc_multiline,
        !            70:   $heredoc_spchar,
        !            71:   $heredoc_escchar,
        !            72:   $heredoc_quote_slash
        !            73: );
        !            74: 
        !            75: 
        !            76: // loop through each element of the heredoc_arr for str
        !            77: $count = 0;
        !            78: foreach($heredoc_arr as $value) {
        !            79:   echo "-- Iteration ".($count+1). " --\n";
        !            80:   var_dump( chunk_split( $str, $chunklen, $value) );
        !            81:   $count++;
        !            82: };
        !            83:  
        !            84: echo "Done"
        !            85: ?>
        !            86: --EXPECTF--
        !            87: *** Testing chunk_split() : different heredoc strings for 'ending' argument ***
        !            88: -- Iteration 1 --
        !            89: string(102) "This is str to check with heredoc ending.This     contains,
        !            90: speci@! ch@r$ __with wrong \k escape char 222."
        !            91: -- Iteration 2 --
        !            92: string(102) "This is str to check with heredoc ending.This     contains,
        !            93: speci@! ch@r$ __with wrong \k escape char 222."
        !            94: -- Iteration 3 --
        !            95: string(113) "This is star to checka with hereadoc endinga.This contaains,
        !            96: specai@! ch@r$ a__with wroang \k escaape char 22a2.a"
        !            97: -- Iteration 4 --
        !            98: string(421) "This is stThis is simple heredoc stringr to checkThis is simple heredoc string with hereThis is simple heredoc stringdoc endingThis is simple heredoc string.This contThis is simple heredoc stringains,
        !            99: specThis is simple heredoc stringi@! ch@r$ This is simple heredoc string__with wroThis is simple heredoc stringng \k escaThis is simple heredoc stringpe char 22This is simple heredoc string2.This is simple heredoc string"
        !           100: -- Iteration 5 --
        !           101: string(762) "This is stThis is to check chunk_split
        !           102: function with multiline
        !           103: heredocr to checkThis is to check chunk_split
        !           104: function with multiline
        !           105: heredoc with hereThis is to check chunk_split
        !           106: function with multiline
        !           107: heredocdoc endingThis is to check chunk_split
        !           108: function with multiline
        !           109: heredoc.This   contThis is to check chunk_split
        !           110: function with multiline
        !           111: heredocains,
        !           112: specThis is to check chunk_split
        !           113: function with multiline
        !           114: heredoci@! ch@r$ This is to check chunk_split
        !           115: function with multiline
        !           116: heredoc__with wroThis is to check chunk_split
        !           117: function with multiline
        !           118: heredocng \k escaThis is to check chunk_split
        !           119: function with multiline
        !           120: heredocpe char 22This is to check chunk_split
        !           121: function with multiline
        !           122: heredoc2.This is to check chunk_split
        !           123: function with multiline
        !           124: heredoc"
        !           125: -- Iteration 6 --
        !           126: string(443) "This is stThis checks with $, %, &, charsr to checkThis checks with $, %, &, chars with hereThis checks with $, %, &, charsdoc endingThis checks with $, %, &, chars.This contThis checks with $, %, &, charsains,
        !           127: specThis checks with $, %, &, charsi@! ch@r$ This checks with $, %, &, chars__with wroThis checks with $, %, &, charsng \k escaThis checks with $, %, &, charspe char 22This checks with $, %, &, chars2.This checks with $, %, &, chars"
        !           128: -- Iteration 7 --
        !           129: string(487) "This is stThis checks      and 
        !           130: white space charsr to checkThis checks  and 
        !           131: white space chars with hereThis checks  and 
        !           132: white space charsdoc endingThis checks  and 
        !           133: white space chars.This contThis checks  and 
        !           134: white space charsains,
        !           135: specThis checks         and 
        !           136: white space charsi@! ch@r$ This checks  and 
        !           137: white space chars__with wroThis checks  and 
        !           138: white space charsng \k escaThis checks  and 
        !           139: white space charspe char 22This checks  and 
        !           140: white space chars2.This checks  and 
        !           141: white space chars"
        !           142: -- Iteration 8 --
        !           143: string(597) "This is st"To check " in heredoc".I'm sure it'll \work!r to check"To check " in heredoc".I'm sure it'll \work! with here"To check " in heredoc".I'm sure it'll \work!doc ending"To check " in heredoc".I'm sure it'll \work!.This cont"To check " in heredoc".I'm sure it'll \work!ains,
        !           144: spec"To check " in heredoc".I'm sure it'll \work!i@! ch@r$ "To check " in heredoc".I'm sure it'll \work!__with wro"To check " in heredoc".I'm sure it'll \work!ng \k esca"To check " in heredoc".I'm sure it'll \work!pe char 22"To check " in heredoc".I'm sure it'll \work!2."To check " in heredoc".I'm sure it'll \work!"
        !           145: Done

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