[fw-general] Re: diff in double-to-string conversion 5.2.1 vs 5.2.2

2007-04-19 Thread Sebastian Nohn
Hi,

On Thu, April 19, 2007 11:33 am, Antony Dovgal wrote:
> On 04/15/2007 11:05 AM, Sebastian Nohn wrote:
>> > $a = 69;
>> var_dump($a);
>> $b = "A is: ".$a;
>> var_dump($b);
>> ?>
>>
>> 5.2.1 output is:
>>
>> float(6.9E+9)
>> string(16) "A is: 69"
>>
>> 5.2.2-dev output is:
>>
>> float(6.9E+9)
>> string(12) "A is: 6.9E+9"
>
> Fix committed, please test the next snapshot.

Works! Thanks a lot!

- Sebastian



Re: [fw-general] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
Antony Dovgal wrote:
> On 04/17/2007 10:16 PM, Sebastian Nohn wrote:
>> Dmitry Stogov wrote:
>>
>>> It is bad practice to use echo $float or var_dump($float)
>>> because they depends on php.ini settings.
>>> You should use printf() of number_format() for deterministic result.
> 
>  $a = 69;
> $b = $a.""; <-- that's the very same mistake
> printf("%d", $a); echo "\n";
> printf("%d", $b); echo "\n";
> ?>

So please someone take care, that this is fixed in Zend Framework.
Occurs at least in Zend_Date_DateObject::date() with $timestamp.

- Sebastian


[fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
Sebastian Nohn wrote:

> $c = $a."";
> $d = (string)$a;

Forget that.

- Sebastian


[fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
Antony Dovgal wrote:
> On 04/17/2007 10:16 PM, Sebastian Nohn wrote:
>> Dmitry Stogov wrote:
>>
>>> It is bad practice to use echo $float or var_dump($float)
>>> because they depends on php.ini settings.
>>> You should use printf() of number_format() for deterministic result.
> 
>  $a = 69;
> $b = $a.""; <-- that's the very same mistake
> printf("%d", $a); echo "\n";
> printf("%d", $b); echo "\n";
> ?>
> 
> You're converting float to string and THEN trying to output as integer.
> My patch returns the old behaviour, though you're code is still wrong.
> 
>> PHP 5.2.2:
>>
>> -1689934592
>> 6
> 
> #php -r 'printf("%d", 69);'
> -1689934592
> 
> #php -r 'printf("%d", "69");'
> 2147483647
> 
> #php -v
> PHP 5.2.2RC1 (cli) (built: Apr 16 2007 10:01:11)

$ ./php -v
PHP 5.2.2RC2-dev (cli) (built: Apr 17 2007 20:12:31)
$ cat ~/test.php

sh-3.1$ ./php ~/test.php
-1689934592
2147483647
6
6

Best regards,
  Sebastian Nohn
-- 
Sebastian Nohn · Wolfstraße 29 · 53111 Bonn · Germany
+49-170-4718105 · http://nohn.net/ · [EMAIL PROTECTED]
http://pgpkeys.pca.dfn.de:11371/pks/lookup?op=get&fingerprint=on&search=0xD47D55E0


[fw-general] Re: [PHP-DEV] Re: [fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
Dmitry Stogov wrote:

> It is bad practice to use echo $float or var_dump($float)
> because they depends on php.ini settings.
> You should use printf() of number_format() for deterministic result.



PHP 5.2.1:

-1689934592
2147483647

PHP 5.2.2:

-1689934592
6

- Sebastian


[fw-general] Re: [PHP-DEV] Re: [fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
Marcus Boerger wrote:

>   lemme try this again. You can in no way rely on the last digits of a float
> output. Those depend on your system, your CPU, your ini settings and any
> operation you do with floats reduces the accuracy

If I do the same operation with the same ini setting on exakt the same
machine with different PHP versions and I get different results with
these different versions, I expect that to be documented.

Best regards,
  Sebastian Nohn
-- 
Sebastian Nohn · Wolfstraße 29 · 53111 Bonn · Germany
+49-170-4718105 · http://nohn.net/ · [EMAIL PROTECTED]
http://pgpkeys.pca.dfn.de:11371/pks/lookup?op=get&fingerprint=on&search=0xD47D55E0


[fw-general] Re: [PHP-DEV] Re: [fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
Marcus Boerger wrote:

>   float numbers are never perfect values. So should in anyway never rely
> on a certain output format. So there is nothing to document here.

We have a changed behavior here that should be documented. Otherwise
users will run into problems. As the non-academic example that raised
this discussion shows.

- Sebastian



[fw-general] RE: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-17 Thread Sebastian Nohn
On Tue, April 17, 2007 9:55 am, Dmitry Stogov wrote:

> The float formatting algorithms were changed because of
> licensing issues and new ones are not 100% compatible with
> previous ones.

Could you please provide more details on that?

- Sebastian



Re: [fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-16 Thread Sebastian Nohn
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Thomas,

> it should also be mentioned that when you are refferring to a test
> within ZF you should always look
> against the latest version of ZF.

As already mentioned: This also happens in ZF trunk. ZF unit tests fail
on any platform since sometime between 0.8.0 and 0.9.0 (see mine and
others unresolved bug reports), so everything > 0.8.0 is no reference to
test PHP (which I did).

> Independent on why this failure is there I also have to mention that I
> think that we will not fix issues within ZF which are raised due to the
> development tree of a php version. If php 5.2.2 is released and we have
> an issue with it we will fix it, but as this php version will probably
> be changed until it's release it would be nonsense to fix bugs which may
> be not in there when the new version of php is released.

At that time I didn't know if the bug is a PHP bug or a ZF bug and I
didn't want to investigate. Unfortunately neither PHP nor ZF developers
wanted to investigate this, so I did it in the end.

Best regards,
  Sebastian Nohn
- --
Sebastian Nohn · Wolfstraße 29 · 53111 Bonn · Germany
+49-170-4718105 · http://nohn.net/ · [EMAIL PROTECTED]
http://pgpkeys.pca.dfn.de:11371/pks/lookup?op=get&fingerprint=on&search=0xD47D55E0
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (MingW32)

iD8DBQFGI8ebsvwfldR9VeARAqp3AJ9SvZ6wTGfn4B5tMwpdTDmWbOu5QgCgv4/6
uafKqBUpOtnjv1O0FZcFt38=
=6wBP
-END PGP SIGNATURE-


[fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-16 Thread Sebastian Nohn
On Mon, April 16, 2007 10:10 am, Antony Dovgal wrote:
> On 04/15/2007 11:05 AM, Sebastian Nohn wrote:
>> > $a = 69;
>> var_dump($a);
>> $b = "A is: ".$a;
>> var_dump($b);
>> ?>
>>
>> 5.2.1 output is:
>>
>> float(6.9E+9)
>> string(16) "A is: 69"
>>
>> 5.2.2-dev output is:
>>
>> float(6.9E+9)
>> string(12) "A is: 6.9E+9"
>
> Nice catch, thanks.
>
> What do you think is the most correct output for 1 000 000 000 000 000
> (with precision = 14)?
> Versions <= 5.2.1 output "1E+15", 5.2.2 says "1.0E+15".

Whatever is done, if the result is a different behaviour between 5.2.1 and
5.2.2, it needs to be documented in the change log / release notes.

- Sebastian



[fw-general] Re: [PHP-DEV] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-16 Thread Sebastian Nohn
On Sat, April 14, 2007 8:29 pm, Antony Dovgal wrote:
> On 04/14/2007 08:50 PM, Sebastian Nohn wrote:
>> On PHP 5.2.1, ZendFramework 0.8.0 Unit Tests pass, while they fail on
>> PHP 5.2.2-dev (latest CVS) on the same machine:
>>
>> 1) testDate(Zend_Date_DateObjectTest)
>> Failed asserting that  is identical to
>> 
>> .../tests/Zend/Date/DateObjectTest.php:408
>
> Would be nice to have a short but complete reproduce case.
> Referring to some test (which I personally have never seen) is not really
> helpful.

This was the idea why PHP and ZF developers should come together. However,
I investigated the issue and here is a small testcase:



5.2.1 output is:

float(6.9E+9)
string(16) "A is: 69"

5.2.2-dev output is:

float(6.9E+9)
string(12) "A is: 6.9E+9"

- Sebastian



[fw-general] ZF 0.8.0 Unit Tests behaving different on PHP 5.2.1 and PHP 5.2.2-dev

2007-04-16 Thread Sebastian Nohn
On PHP 5.2.1, ZendFramework 0.8.0 Unit Tests pass, while they fail on
PHP 5.2.2-dev (latest CVS) on the same machine:

1) testDate(Zend_Date_DateObjectTest)
Failed asserting that  is identical to 
.../tests/Zend/Date/DateObjectTest.php:408

This behaviour is also reproducable on Zend Framework trunk.

I don't know, where the bug is (ZF or PHP), so it would be nice, if PHP
and ZF developers could come together to solve this.

- Sebastian



[fw-general] PHP 5.2.1RC2-dev vs. Zend Framework 0.2.0

2006-12-17 Thread Sebastian Nohn
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Some ZF 0.2.0 Unit Tests fail on PHP 5.2.1RC2-dev, you can ignore tests
1-6, these already fail on 5.2.0 (ZF-463). The method in question looks
like this:

public function toString($factory = null)
{
if (is_integer($this->value)) {
return (string)$this->value;
}

/**
 * PDF doesn't support exponental format.
 * Fixed point format must be used instead
 */
$prec = 0; $v = $this->value;
while (abs( floor($v) - $v ) > 1e-10) {
$prec++; $v *= 10;
}
return sprintf("%.{$prec}F", $this->value);
}

I wonder wether this is a bug in PHP or ZF and like to ask for your
opinion before posting it.

-  cut here 
PHPUnit 3.0.0 by Sebastian Bergmann.

.
...F.FF..FFF.
.
...E.
.
.
.
...F..FF.
FFF..
..

Time: 00:00

There was 1 error:

1) testIterator(Zend_ConfigTest)
Object of class Zend_Config could not be converted to string
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/ConfigTest.php:173
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40
There were 12 failures:

1) testCleanModeAllWithHashedDirectoryStructure(Zend_Cache_FileBackendTest)
Failed asserting that  is identical to .
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Cache/FileBackendTest.php:78
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

2) testCleanModeAll(Zend_Cache_FileBackendTest)
Failed asserting that  is identical to .
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

3) testCleanModeOld(Zend_Cache_FileBackendTest)
Failed asserting that  is identical to .
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

4) testCleanModeNotMatchingTags(Zend_Cache_FileBackendTest)
Failed asserting that  is identical to .
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

5) testCleanModeNotMatchingTags2(Zend_Cache_FileBackendTest)
Failed asserting that  is identical to .
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

6) testCleanModeNotMatchingTags3(Zend_Cache_FileBackendTest)
Failed asserting that  is identical to .
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

7) testToString(Zend_Pdf_Element_ArrayTest)
Failed asserting that  is
equal to .
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Pdf/Element/ArrayTest.php:112
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

8) testToString(Zend_Pdf_Element_DictionaryTest)
Failed asserting that  >>> is equal to
 >>>.
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Pdf/Element/DictionaryTest.php:107
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

9) testAdd(Zend_Pdf_Element_DictionaryTest)
Failed asserting that >> is equal to >>.
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Pdf/Element/DictionaryTest.php:118
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

10) testToStringFloat1(Zend_Pdf_Element_NumericTest)
Failed asserting that  is equal to .
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Pdf/Element/NumericTest.php:57
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

11) testToStringFloat2(Zend_Pdf_Element_NumericTest)
Failed asserting that  is equal to .
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Pdf/Element/NumericTest.php:63
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

12) testToStringFloat3(Zend_Pdf_Element_NumericTest)
Failed asserting that  is equal to .
/home/cruise/cruisecontrol/projects/PHP_5_2/tests/frameworks/ZendFramework-0.2.0/tests/Zend/Pdf/Element/NumericTest.php:69
/home/cruise/cruisecontrol/projects/PHP_5_2/slash/opt/php/bin/phpunit:40

FAILURES!
Tests: 399, Failures: 12, Errors: 1.
-  cut here 

You can ignore tests 1-6, these already fail with 5.2.0:

-  cut here 
PHPUnit 3.0.0 by Sebastian Bergmann.

.
...F.FF..FFF.
.
...E.
.
.
.
.
..

[fw-general] Re: Zend_Cache_FileBackendTest failing

2006-10-28 Thread Sebastian Nohn
Fabien MARTY wrote:

> Zend_Cache tests are ok for me with latest SVN.
> 
> May you open a bug report with your exact configuration (OS, versions...) ?

ZF-463

Sebastian



[fw-general] Zend_Cache_FileBackendTest failing

2006-10-26 Thread Sebastian Nohn
testCleanModeAllWithHashedDirectoryStructure
testCleanModeAll
testCleanModeOld
testCleanModeNotMatchingTags
testCleanModeNotMatchingTags2
testCleanModeNotMatchingTags3

Best regards,
Sebastian