From 5f773f890a0e9afb942a5da50936e4b1079051b3 Mon Sep 17 00:00:00 2001 From: Eric Poe Date: Sat, 23 Sep 2017 23:12:38 -0500 Subject: [PATCH] Provide test for bug 62477 --- ext/spl/tests/bug62477.phpt | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ext/spl/tests/bug62477.phpt diff --git a/ext/spl/tests/bug62477.phpt b/ext/spl/tests/bug62477.phpt new file mode 100644 index 0000000000..a5469cce91 --- /dev/null +++ b/ext/spl/tests/bug62477.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #62477 (Problem LimitIterator, argument Offset only Integers) +--CREDIT-- +KCPHPUG TestFest 2017 - Eric Poe +--FILE-- +_n++; + } + + public function rewind() + { + $this->_n = 0; + } + + public function current() : float + { + return $this->_n; + } + + public function key() {} + + public function valid() : bool + { + return $this->_n < 10000000000000000000; + } + + public function seek($pos) + { + $this->_n = $pos; + } +} +$comb = new Combinator(); +$float = 10000000000; + +$limitIteratorFloatSeek = []; +foreach (new limitIterator($comb, $float, 3) as $current) { + $limitIteratorFloatSeek[] = $current; +} + +$controlGroup = []; +for ($comb->seek($float); $comb->current() < ($float + 3) && $comb->valid(); $comb->next()) { + $controlGroup[] = $comb->current(); +} + +foreach ($limitIteratorFloatSeek as $item) { + echo in_array($item, $controlGroup) ? "same" : "not same"; + echo PHP_EOL; +} +?> +--EXPECT-- +same +same +same \ No newline at end of file