Annotation of embedaddon/php/ext/standard/tests/streams/bug60455_03.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Bug #60455: stream_get_line and 2 lines, one possibly empty
                      3: --FILE--
                      4: <?php
                      5: class TestStream {
                      6:        private $lines = array();
                      7:        private $s = 0;
                      8:        private $eofth = 3;
                      9:        function stream_open($path, $mode, $options, &$opened_path) {
                     10:                        $this->lines[] = "a\n";
                     11:                        $this->lines[] = ($path == "test://nonempty2nd" ? "b\n" : "\n");
                     12:                        if ($path == "test://eofafter2nd")
                     13:                                $this->eofth = 2;
                     14:                return true;
                     15:        }
                     16:        function stream_read($count) {
                     17:                if (key_exists($this->s++, $this->lines))
                     18:                        return $this->lines[$this->s - 1];
                     19: 
                     20:                return "";
                     21:        }
                     22:        function stream_eof() {
                     23:                return $this->s >= $this->eofth;
                     24:        }
                     25:        
                     26: }
                     27: 
                     28: stream_wrapper_register("test", "TestStream");
                     29: 
                     30: $f = fopen("test://nonempty2nd", "r");
                     31: while (!feof($f)) {
                     32:     $line = stream_get_line($f, 99, "\n");
                     33:     var_dump($line);
                     34: }
                     35: $f = fopen("test://", "r");
                     36: while (!feof($f)) {
                     37:     $line = stream_get_line($f, 99, "\n");
                     38:     var_dump($line);
                     39: }
                     40: $f = fopen("test://eofafter2nd", "r");
                     41: while (!feof($f)) {
                     42:     $line = stream_get_line($f, 99, "\n");
                     43:     var_dump($line);
                     44: }
                     45: 
                     46: 
                     47: --EXPECT--
                     48: string(1) "a"
                     49: string(1) "b"
1.1.1.2 ! misho      50: bool(false)
1.1       misho      51: string(1) "a"
                     52: string(0) ""
1.1.1.2 ! misho      53: bool(false)
1.1       misho      54: string(1) "a"
                     55: string(0) ""

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