Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src / run-tests.php

2008-07-24 Thread Ulf Wendel

Marcus Boerger schrieb:

  to be honest this is the wrong way. The correct way of fixing this is to
have PHP 6 name it correct: string and binary. And to have b for binary


Aside from the question of how to write a portable test, here is an 
example speaking for your argument of making a distinction between 
binary (strings) and strings (= always unicode) in the 
var_dump()/print_r()/etc. output of PHP 6.


In early PHP 6 days var_dump((binary)PHP) has printed string, like 
PHP 5 does. And in earlier versions of PHP 6 var_dump(PHP) has printed 
unicode. There was a distinction between the two types of strings in 
PHP 6.


That was nice, because it was simple to test if SELECT varbinary_column 
really returned a binary (string) or a (unicode) string.


Ulf

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: [PHP-CVS] cvs: php-src / run-tests.php

2008-07-23 Thread Marcus Boerger
Hello Lars,

  to be honest this is the wrong way. The correct way of fixing this is to
have PHP 6 name it correct: string and binary. And to have b for binary
prefix rather then u for unicode. Or did PHP 6 change in the meanwhile and
we support uNonsense besides bBinary?

Question actually goes to Andrei, who should decide whether we get a sane
output or not.

marcus

Wednesday, July 23, 2008, 6:10:14 PM, you wrote:

 lstrojnyWed Jul 23 16:10:14 2008 UTC

   Modified files:  
 /php-srcrun-tests.php 
   Log:
   Allowing %unicode|string% as a placeholder. In 6, this placeholder is 
 resolved
   to unicode, in 6 to string. This allows to easily write portable tests.
   Patch by uw
   
   
   
 http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.366r2=1.367diff_format=u
 Index: php-src/run-tests.php
 diff -u php-src/run-tests.php:1.366 php-src/run-tests.php:1.367
 --- php-src/run-tests.php:1.366   Tue Jul 22 19:53:00 2008
 +++ php-src/run-tests.php   Wed Jul 23 16:10:14 2008
 @@ -24,7 +24,7 @@

 +--+
   */
  
 -/* $Id: run-tests.php,v 1.366 2008/07/22 19:53:00 felipe Exp $ */
 +/* $Id: run-tests.php,v 1.367 2008/07/23 16:10:14 lstrojny Exp $ */
  
  /* Sanity check to ensure that pcre extension needed by this script is 
 available.
   * In the event it is not, print a nice error message indicating that this 
 script will
 @@ -478,7 +478,7 @@
 $html_output = 
 is_resource($html_file);
 break;
 case '--version':
 -   echo '$Revision: 1.366 $' . \n;
 +   echo '$Revision: 1.367 $' . \n;
 exit(1);
  
 default:
 @@ -1711,6 +1711,11 @@
  
 if (isset($section_text['EXPECTF'])) {
 $wanted_re = preg_quote($wanted_re, '/');
 +   $wanted_re = str_replace(
 +   array('%unicode\|string%', 
 '%string\|unicode%'),
 +   version_compare(PHP_VERSION,
 '6.0.0-dev') == -1 ? 'string' : 'unicode',
 +   $wanted_re
 +   );
 // Stick to basics
 $wanted_re = str_replace('%e', '\\' . 
 DIRECTORY_SEPARATOR, $wanted_re);
 $wanted_re = str_replace('%s', '[^\r\n]+', 
 $wanted_re);






Best regards,
 Marcus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src / run-tests.php

2008-07-23 Thread Ulf Wendel

Moin Marcus!

Marcus Boerger schrieb:

  to be honest this is the wrong way. The correct way of fixing this is to
have PHP 6 name it correct: string and binary. And to have b for binary
prefix rather then u for unicode. Or did PHP 6 change in the meanwhile and
we support uNonsense besides bBinary?


I'm not sure if a change to PHP would help solving the original question 
on portable tests which I raised on the QA list. I asked for a way to 
write portable tests. That is a test which can be run on both PHP 5 
and PHP 6 -- one file for both PHP 5 and PHP 6 (like in early PHP 6 days 
with UEXPECTF), not two versions that need to be kept in sync (like 
nowadays).


Currently we have:

 PHP 5
 var_dump(PHP . chr(0) .  rocks!) -- string(9) PHProcks
 var_dump((binary)PHP . chr(0) .  rocks!) -- string(9) PHProcks

 PHP 6
 var_dump(PHP . chr(0) .  rocks!) -- unicode(9) PHProcks
 var_dump((binary)PHP . chr(0) .  rocks!) -- unicode(9) PHProcks

The patch to run-tests.php allows you to use in your EXPECTF or 
EXPECTREGEXP section:


  %unicode|string%(9) PHProcks

With PHP 5, run-tests.php will search for string(9) PHProcks and with 
PHP 6 it will search for unicode(9) PHProcks: one EXPECTF section, one 
test file for both PHP 5 and PHP 6.


If I get you right, you suggest that it should read as follows in PHP 6:

 var_dump(PHP . chr(0) .  rocks!) -- string(9) PHProcks
 var_dump((binary)PHP . chr(0) .  rocks!) -- binary(9) PHProcks

This may be correct and desired. However, if you change it, I'm back to 
my question: is there a way to write a portable test?


Ulf

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src / run-tests.php

2008-07-23 Thread Lars Strojny
Hi Marcus,

Am Mittwoch, den 23.07.2008, 18:57 +0200 schrieb Marcus Boerger:
[...]
   to be honest this is the wrong way. The correct way of fixing this is to
 have PHP 6 name it correct: string and binary

This would not solve the problem of writing portable tests for 5_3 and
HEAD. Currently we have a number of tests with %s(4) test to
circumvent this problem. But this workaround will reliably lead us to
obscure bugs. This is the reason we discussed the introduction of the
placeholder on the QA-list. But if you know a better way to do it, I'm
really happy to implement that.

cu, Lars


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil