svn: /pecl/judy/trunk/ php_judy.c tests/github_issue15_001.phpt tests/github_issue15_002.phpt

From: Date: Sun, 03 Nov 2013 07:41:02 +0000
Subject: svn: /pecl/judy/trunk/ php_judy.c tests/github_issue15_001.phpt tests/github_issue15_002.phpt
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-19963@lists.php.net to get a copy of this message
nicolas Sun, 03 Nov 2013 07:41:02 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=332048 Log: fix github issue #15 Bug: https://bugs.php.net/15 (Closed) Apache 1.2.4 .htaccess directives Changed paths: U pecl/judy/trunk/php_judy.c A pecl/judy/trunk/tests/github_issue15_001.phpt A pecl/judy/trunk/tests/github_issue15_002.phpt Modified: pecl/judy/trunk/php_judy.c =================================================================== --- pecl/judy/trunk/php_judy.c 2013-11-03 07:38:26 UTC (rev 332047) +++ pecl/judy/trunk/php_judy.c 2013-11-03 07:41:02 UTC (rev 332048) @@ -366,10 +366,11 @@ if (*PValue != NULL) { zval *old_value = (zval *)*PValue; zval_ptr_dtor(&old_value); - } + } else { + intern->counter++; + } *PValue = value; Z_ADDREF_P(value); - intern->counter++; res = SUCCESS; } else { res = FAILURE; Added: pecl/judy/trunk/tests/github_issue15_001.phpt =================================================================== --- pecl/judy/trunk/tests/github_issue15_001.phpt (rev 0) +++ pecl/judy/trunk/tests/github_issue15_001.phpt 2013-11-03 07:41:02 UTC (rev 332048) @@ -0,0 +1,39 @@ +--TEST-- +Check for Judy count() method when using INT_TO_INT in a loop +--SKIPIF-- +<?php if (!extension_loaded("judy")) print "skip"; ?> +--FILE-- +<?php +/* +Ref. https://github.com/orieg/php-judy/issues/15 +*/ + +echo "Instantiate first object: \$judy1\n"; +$judy1 = new Judy(Judy::STRING_TO_MIXED); + +echo "Assign a value while in a loop of 1\n"; +for ($i = 0;$i < 1;$i++) { + $judy1[5] = 100; +} +echo "\$judy1->count(): ". $judy1->size()."\n"; + +echo "Assign a value while in a loop of 1000\n"; +for ($i = 0;$i < 1000;$i++) { + $judy1[5] = 100; +} +echo "\$judy1->count(): ". $judy1->size()."\n"; + +foreach ($judy1 as $k => $v) { + echo "\$judy1[".$k."] = ".$v."\n"; +} + +unset($judy1); + +?> +--EXPECT-- +Instantiate first object: $judy1 +Assign a value while in a loop of 1 +$judy1->count(): 1 +Assign a value while in a loop of 1000 +$judy1->count(): 1 +$judy1[5] = 100 Added: pecl/judy/trunk/tests/github_issue15_002.phpt =================================================================== --- pecl/judy/trunk/tests/github_issue15_002.phpt (rev 0) +++ pecl/judy/trunk/tests/github_issue15_002.phpt 2013-11-03 07:41:02 UTC (rev 332048) @@ -0,0 +1,39 @@ +--TEST-- +Check for Judy count() method when using STRING_TO_MIXED in a loop +--SKIPIF-- +<?php if (!extension_loaded("judy")) print "skip"; ?> +--FILE-- +<?php +/* +Ref. https://github.com/orieg/php-judy/issues/15 +*/ + +echo "Instantiate first object: \$judy1\n"; +$judy1 = new Judy(Judy::STRING_TO_MIXED); + +echo "Assign a value while in a loop of 1\n"; +for ($i = 0;$i < 1;$i++) { + $judy1["a"] = 100; +} +echo "\$judy1->count(): ". $judy1->size()."\n"; + +echo "Assign a value while in a loop of 1000\n"; +for ($i = 0;$i < 1000;$i++) { + $judy1["a"] = 100; +} +echo "\$judy1->count(): ". $judy1->size()."\n"; + +foreach ($judy1 as $k => $v) { + echo "\$judy1[".$k."] = ".$v."\n"; +} + +unset($judy1); + +?> +--EXPECT-- +Instantiate first object: $judy1 +Assign a value while in a loop of 1 +$judy1->count(): 1 +Assign a value while in a loop of 1000 +$judy1->count(): 1 +$judy1[a] = 100

« previous php.pecl.cvs (#19963) next »