[limb-svn] r6857 - in 3.x/trunk/limb/core: src tests/cases
svn at limb-project.com
svn at limb-project.com
Tue Mar 25 18:31:51 MSK 2008
Author: serega
Date: 2008-03-25 18:31:51 +0300 (Tue, 25 Mar 2008)
New Revision: 6857
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6857
Modified:
3.x/trunk/limb/core/src/lmbSet.class.php
3.x/trunk/limb/core/tests/cases/lmbSetTest.class.php
Log:
-- fixed a bug with lmbSet caused foreach constructions to work badly with sets with elements having "false" values
Modified: 3.x/trunk/limb/core/src/lmbSet.class.php
===================================================================
--- 3.x/trunk/limb/core/src/lmbSet.class.php 2008-03-25 12:58:31 UTC (rev 6856)
+++ 3.x/trunk/limb/core/src/lmbSet.class.php 2008-03-25 15:31:51 UTC (rev 6857)
@@ -173,14 +173,17 @@
function next()
{
$this->__current = next($this->__properties);
- $this->__valid = $this->__current !== false;
+ $this->__counter++;
+ $this->__valid = $this->__size > $this->__counter;
}
function rewind()
{
$this->__properties = $this->_getUnguardedVars($this);
$this->__current = reset($this->__properties);
- $this->__valid = $this->__current !== false;
+ $this->__size = count($this->__properties);
+ $this->__counter = 0;
+ $this->__valid = $this->__size > $this->__counter;
}
function key()
@@ -190,3 +193,4 @@
}
+
Modified: 3.x/trunk/limb/core/tests/cases/lmbSetTest.class.php
===================================================================
--- 3.x/trunk/limb/core/tests/cases/lmbSetTest.class.php 2008-03-25 12:58:31 UTC (rev 6856)
+++ 3.x/trunk/limb/core/tests/cases/lmbSetTest.class.php 2008-03-25 15:31:51 UTC (rev 6857)
@@ -206,6 +206,19 @@
$this->assertEqual($array, $result);
}
+
+ function testImplementsIteratorWithFalseElementsInArray()
+ {
+ $ds = new lmbSet($array = array('test1' => 'foo',
+ 'test2' => false,
+ 'test3' => 'bar'));
+
+ $result = array();
+ foreach($ds as $key => $value)
+ $result[$key] = $value;
+
+ $this->assertEqual($array, $result);
+ }
}
More information about the limb-svn
mailing list