summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Coallier <davidc@php.net>2008-11-22 14:19:47 +0000
committerDavid Coallier <davidc@php.net>2008-11-22 14:19:47 +0000
commit16de7fbd16d7a9cbed6e71db7b87bb3da0d2c6f4 (patch)
treeacd7c18b38f5a80bd33b5d8fd140c7ef22f17dc6
parentb2e419ef40af4c685e1374bf345a0819e7eb1d1d (diff)
downloadphp-git-16de7fbd16d7a9cbed6e71db7b87bb3da0d2c6f4.tar.gz
- MFH
- Bug #46615 - Return the count - 1 when invoking SplHeap->key() - Adjusted the tests
-rw-r--r--ext/spl/spl_heap.c4
-rw-r--r--ext/spl/tests/heap_007.phpt9
-rw-r--r--ext/spl/tests/pqueue_003.phpt8
3 files changed, 11 insertions, 10 deletions
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index fe82d81644..f073597af1 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -970,8 +970,8 @@ static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{
SPL_METHOD(SplHeap, key)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- RETURN_LONG(intern->heap->count);
+
+ RETURN_LONG(intern->heap->count - 1);
}
/* }}} */
diff --git a/ext/spl/tests/heap_007.phpt b/ext/spl/tests/heap_007.phpt
index 784ac6e8b0..e8d5c9997c 100644
--- a/ext/spl/tests/heap_007.phpt
+++ b/ext/spl/tests/heap_007.phpt
@@ -12,6 +12,7 @@ $h->insert(4);
$h->rewind();
echo "count(\$h) = ".count($h)."\n";
echo "\$h->count() = ".$h->count()."\n";
+
while ($h->valid()) {
$k = $h->key();
$v = $h->current();
@@ -24,8 +25,8 @@ while ($h->valid()) {
--EXPECTF--
count($h) = 4
$h->count() = 4
-4=>5
-3=>4
-2=>1
-1=>0
+3=>5
+2=>4
+1=>1
+0=>0
===DONE===
diff --git a/ext/spl/tests/pqueue_003.phpt b/ext/spl/tests/pqueue_003.phpt
index 8abc72c4c7..9c0b5a5147 100644
--- a/ext/spl/tests/pqueue_003.phpt
+++ b/ext/spl/tests/pqueue_003.phpt
@@ -24,8 +24,8 @@ while ($h->valid()) {
--EXPECTF--
count($h) = 4
$h->count() = 4
-4=>5
-3=>4
-2=>1
-1=>0
+3=>5
+2=>4
+1=>1
+0=>0
===DONE===