File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / spl / tests / heap_009.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:01 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
SPL: SplHeap and friends, throw: An iterator cannot be used with foreach by reference
--CREDITS--
Thomas Koch <thomas@koch.ro>
#Hackday Webtuesday 2008-05-24
--FILE--
<?php
function testForException( $heap )
{
    try
    {
        foreach( $heap as &$item );
    }
    catch( RuntimeException $e )
    {
        echo $e->getMessage(),"\n";
    }
}

// 1. SplMinHeap emtpy
$heap = new SplMinHeap;
testForException( $heap );

// 2. SplMinHeap non-emtpy
$heap = new SplMinHeap;
$heap->insert( 1 );
testForException( $heap );

// 3. SplMaxHeap emtpy
$heap = new SplMaxHeap;
testForException( $heap );

// 4. SplMaxHeap non-emtpy
$heap = new SplMaxHeap;
$heap->insert( 1 );
testForException( $heap );

// 5. SplPriorityQueue empty
$heap = new SplPriorityQueue;
testForException( $heap );

// 6. SplPriorityQueue non-empty
$heap = new SplPriorityQueue;
$heap->insert( 1, 2 );
testForException( $heap );

?>
==DONE==
--EXPECT--
An iterator cannot be used with foreach by reference
An iterator cannot be used with foreach by reference
An iterator cannot be used with foreach by reference
An iterator cannot be used with foreach by reference
An iterator cannot be used with foreach by reference
An iterator cannot be used with foreach by reference
==DONE==

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