indeyets Fri, 17 Jul 2009 15:56:36 +0000 URL: http://svn.php.net/viewvc?view=revision&revision=284272
Changed paths: U php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic1.phpt D php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic2.phpt D php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic3.phpt U php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_error.phpt U php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation1.phpt U php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation2.phpt Log: fixed tests. money_format() is implemented in underlying system, not in php. So, we shouldn't test for actual values returned. They are different between systems
Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic1.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic1.phpt 2009-07-17 15:33:21 UTC (rev 284271) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic1.phpt 2009-07-17 15:56:36 UTC (rev 284272) @@ -2,13 +2,9 @@ Test money_format() function : basic functionality using national currency symbols --SKIPIF-- <?php - if (!function_exists('money_format') || !function_exists('setlocale')) { + if (!function_exists('money_format')) { die("SKIP money_format - not supported\n"); } - - if (setlocale(LC_MONETARY, 'en_US') == false) { - die("SKIP en_US locale not available\n"); - } ?> --FILE-- <?php @@ -17,9 +13,11 @@ * Source code: ext/standard/string.c */ -echo "*** Testing money_format() : basic functionality using national currency symbols***\n"; +// =========================================================================================== +// = We do not test for exact return-values, as those might be different between OS-versions = +// =========================================================================================== -$original = setlocale(LC_MONETARY, 'en_US'); +echo "*** Testing money_format() : basic functionality***\n"; $value = 1234.5678; $negative_value = -1234.5678; @@ -28,57 +26,55 @@ // left precision, 2 of right precision using national // format for en_US echo "Format values with 14 positions, 8 digits to left, 2 to right using national format\n"; -var_dump( money_format('%14#8.2n', $value)); -var_dump( money_format('%14#8.2n', $negative_value)); +echo gettype(money_format('%14#8.2n', $value))."\n"; +echo gettype(money_format('%14#8.2n', $negative_value))."\n"; // Same again but use '(' for negative values echo "Format again but with ( for negative values\n"; -var_dump( money_format('%(14#8.2n', $value)); -var_dump( money_format('%(14#8.2n', $negative_value)); +echo gettype(money_format('%(14#8.2n', $value))."\n"; +echo gettype(money_format('%(14#8.2n', $negative_value))."\n"; // Same again but use a '0' for padding character echo "Format with 0 for padding character\n"; -var_dump( money_format('%=014#8.2n', $value)); -var_dump( money_format('%=014#8.2n', $negative_value)); +echo gettype(money_format('%=014#8.2n', $value))."\n"; +echo gettype(money_format('%=014#8.2n', $negative_value))."\n"; // Same again but use a '*' for padding character echo "Format again with * for padding character\n"; -var_dump( money_format('%=*14#8.2n', $value)); -var_dump( money_format('%=*14#8.2n', $negative_value)); +echo gettype(money_format('%=*14#8.2n', $value))."\n"; +echo gettype(money_format('%=*14#8.2n', $negative_value))."\n"; // Same again but disable grouping character echo "Format again but disable grouping character\n"; -var_dump( money_format('%=*^14#8.2n', $value)); -var_dump( money_format('%=*^14#8.2n', $negative_value)); +echo gettype(money_format('%=*^14#8.2n', $value))."\n"; +echo gettype(money_format('%=*^14#8.2n', $negative_value))."\n"; // Same again but suppress currency symbol echo "Format again suppress currency symbol\n"; -var_dump( money_format('%=*!14#8.2n', $value)); -var_dump( money_format('%=*!14#8.2n', $negative_value)); +echo gettype(money_format('%=*!14#8.2n', $value))."\n"; +echo gettype(money_format('%=*!14#8.2n', $negative_value))."\n"; -setlocale(LC_MONETARY, $original); - ?> ===DONE=== --EXPECT-- -*** Testing money_format() : basic functionality using national currency symbols*** +*** Testing money_format() : basic functionality*** Format values with 14 positions, 8 digits to left, 2 to right using national format -string(15) " $ 1,234.57" -string(15) "-$ 1,234.57" +string +string Format again but with ( for negative values -string(15) " $ 1,234.57" -string(16) "($ 1,234.57)" +string +string Format with 0 for padding character -string(15) " $000001,234.57" -string(15) "-$000001,234.57" +string +string Format again with * for padding character -string(15) " $*****1,234.57" -string(15) "-$*****1,234.57" +string +string Format again but disable grouping character -string(14) " $****1234.57" -string(14) " -$****1234.57" +string +string Format again suppress currency symbol -string(14) " *****1,234.57" -string(14) "-*****1,234.57" +string +string ===DONE=== Deleted: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic2.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic2.phpt 2009-07-17 15:33:21 UTC (rev 284271) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic2.phpt 2009-07-17 15:56:36 UTC (rev 284272) @@ -1,84 +0,0 @@ ---TEST-- -Test money_format() function : basic functionality using international currency symbols ---SKIPIF-- -<?php - if (!function_exists('money_format') || !function_exists('setlocale')) { - die("SKIP money_format - not supported\n"); - } - - if (setlocale(LC_MONETARY, 'en_US') == false) { - die("SKIP en_US locale not available\n"); - } -?> ---FILE-- -<?php -/* Prototype : string money_format ( string $format , float $number ) - * Description: Formats a number as a currency string - * Source code: ext/standard/string.c -*/ - -echo "*** Testing money_format() : basic functionality using international currency symbols***\n"; - -$original = setlocale(LC_MONETARY, 'en_US'); - -$value = 1234.5678; -$negative_value = -1234.5678; - -// Format with 14 positions of width, 8 digits of -// left precision, 2 of right precision using national -// format for en_US -echo "Format with 14 positions, 8 digits to left, 2 to right using national format\n"; -var_dump( money_format('%14#8.2i', $value)); -var_dump( money_format('%14#8.2i', $negative_value)); - -// Same again but use '(' for negative values -echo "Format with ( for negative values\n"; -var_dump( money_format('%(14#8.2i', $value)); -var_dump( money_format('%(14#8.2i', $negative_value)); - -// Same again but use a '0' for padding character -echo "Format with 0 for padding character\n"; -var_dump( money_format('%=014#8.2i', $value)); -var_dump( money_format('%=014#8.2i', $negative_value)); - -// Same again but use a '*' for padding character -echo "Format with * for padding character\n"; -var_dump( money_format('%=*14#8.2i', $value)); -var_dump( money_format('%=*14#8.2i', $negative_value)); - -// Same again but disable grouping character -echo "Format again but disable grouping character\n"; -var_dump( money_format('%=*^14#8.2i', $value)); -var_dump( money_format('%=*^14#8.2i', $negative_value)); - -// Same again but suppress currency symbol -echo "Format again but suppress currency symbol\n"; -var_dump( money_format('%=*!14#8.2i', $value)); -var_dump( money_format('%=*!14#8.2i', $negative_value)); - -setlocale(LC_MONETARY, $original); - -?> -===DONE=== ---EXPECT-- -*** Testing money_format() : basic functionality using international currency symbols*** -Format with 14 positions, 8 digits to left, 2 to right using national format -string(18) " USD 1,234.57" -string(18) "-USD 1,234.57" -Format with ( for negative values -string(18) " USD 1,234.57" -string(19) "(USD 1,234.57)" -Format with 0 for padding character -string(18) " USD 000001,234.57" -string(18) "-USD 000001,234.57" -Format with * for padding character -string(18) " USD *****1,234.57" -string(18) "-USD *****1,234.57" -Format again but disable grouping character -string(16) " USD ****1234.57" -string(16) "-USD ****1234.57" -Format again but suppress currency symbol -string(14) " *****1,234.57" -string(14) "-*****1,234.57" -===DONE=== - Deleted: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic3.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic3.phpt 2009-07-17 15:33:21 UTC (rev 284271) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_basic3.phpt 2009-07-17 15:56:36 UTC (rev 284272) @@ -1,83 +0,0 @@ ---TEST-- -Test money_format() function : basic functionality using national currency symbols and de_DE locale ---SKIPIF-- -<?php - if (!function_exists('money_format') || !function_exists('setlocale')) { - die("SKIP money_format - not supported\n"); - } - - if (setlocale(LC_MONETARY, 'de_DE') == false) { - die("SKIP de_DE locale not available\n"); - } -?> ---FILE-- -<?php -/* Prototype : string money_format ( string $format , float $number ) - * Description: Formats a number as a currency string - * Source code: ext/standard/string.c -*/ - -echo "*** Testing money_format() : basic functionality using national currency symbols and de_DE locale***\n"; - -$original = setlocale(LC_MONETARY, 'de_DE'); - -$value = 1234.5678; -$negative_value = -1234.5678; - -// Format with 14 positions of width, 8 digits of -// left precision, 2 of right precision using national -// format for en_US -echo "Format values with 14 positions, 8 digits to left, 2 to right using national format\n"; -var_dump( money_format('%14#8.2n', $value)); -var_dump( money_format('%14#8.2n', $negative_value)); - -// Same again but use '(' for negative values -echo "Format again but with ( for negative values\n"; -var_dump( money_format('%(14#8.2n', $value)); -var_dump( money_format('%(14#8.2n', $negative_value)); - -// Same again but use a '0' for padding character -echo "Format with 0 for padding character\n"; -var_dump( money_format('%=014#8.2n', $value)); -var_dump( money_format('%=014#8.2n', $negative_value)); - -// Same again but use a '*' for padding character -echo "Format again with * for padding character\n"; -var_dump( money_format('%=*14#8.2n', $value)); -var_dump( money_format('%=*14#8.2n', $negative_value)); - -// Same again but disable grouping character -echo "Format again but disable grouping character\n"; -var_dump( money_format('%=*^14#8.2n', $value)); -var_dump( money_format('%=*^14#8.2n', $negative_value)); - -// Same again but suppress currency symbol -echo "Format again suppress currency symbol\n"; -var_dump( money_format('%=*!14#8.2n', $value)); -var_dump( money_format('%=*!14#8.2n', $negative_value)); - -setlocale(LC_MONETARY, $original); - -?> -===DONE=== ---EXPECT-- -*** Testing money_format() : basic functionality using national currency symbols and de_DE locale*** -Format values with 14 positions, 8 digits to left, 2 to right using national format -string(18) " 1.234,57 EUR" -string(18) "- 1.234,57 EUR" -Format again but with ( for negative values -string(18) " 1.234,57 EUR" -string(19) "( 1.234,57 EUR)" -Format with 0 for padding character -string(18) " 000001.234,57 EUR" -string(18) "-000001.234,57 EUR" -Format again with * for padding character -string(18) " *****1.234,57 EUR" -string(18) "-*****1.234,57 EUR" -Format again but disable grouping character -string(16) " ****1234,57 EUR" -string(16) "-****1234,57 EUR" -Format again suppress currency symbol -string(14) " *****1.234,57" -string(14) "-*****1.234,57" -===DONE=== Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_error.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_error.phpt 2009-07-17 15:33:21 UTC (rev 284271) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_error.phpt 2009-07-17 15:56:36 UTC (rev 284272) @@ -13,6 +13,10 @@ * Source code: ext/standard/string.c */ +// =========================================================================================== +// = We do not test for exact return-values, as those might be different between OS-versions = +// =========================================================================================== + $string = '%14#8.2n'; $value = 1234.56; $extra_arg = 10; Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation1.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation1.phpt 2009-07-17 15:33:21 UTC (rev 284271) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation1.phpt 2009-07-17 15:56:36 UTC (rev 284272) @@ -2,13 +2,9 @@ Test money_format() function : usage variations - test values for $format argument --SKIPIF-- <?php - if (!function_exists('money_format') || !function_exists('setlocale')) { + if (!function_exists('money_format')) { die("SKIP money_format - not supported\n"); } - - if (setlocale(LC_MONETARY, 'de_DE') == false) { - die("SKIP de_DE locale not available\n"); - } ?> --FILE-- <?php @@ -17,9 +13,10 @@ * Source code: ext/standard/string.c */ -$original = setlocale(LC_MONETARY, 'en_US'); +// =========================================================================================== +// = We do not test for exact return-values, as those might be different between OS-versions = +// =========================================================================================== - echo "*** Testing money_format() function: with unexpected inputs for 'format' argument ***\n"; //get an unset variable @@ -97,38 +94,35 @@ foreach($formats as $format) { echo "-- Iteration $count --\n"; - var_dump( money_format($format, $value) ); + echo gettype(money_format($format, $value))."\n"; $count ++; } // close the file handle fclose($file_handle); -// restore original locale -setlocale(LC_MONETARY, $original); - ?> ===Done=== --EXPECTF-- *** Testing money_format() function: with unexpected inputs for 'format' argument *** -- Iteration 1 -- -string(1) "0" +string -- Iteration 2 -- -string(1) "1" +string -- Iteration 3 -- -string(3) "255" +string -- Iteration 4 -- -string(3) "256" +string -- Iteration 5 -- -string(10) "2147483647" +string -- Iteration 6 -- -string(11) "-2147483648" +string -- Iteration 7 -- -string(4) "10.5" +string -- Iteration 8 -- -string(5) "-20.5" +string -- Iteration 9 -- -string(12) "101234567000" +string -- Iteration 10 -- Warning: money_format() expects parameter 1 to be string, array given in %s on line %d @@ -142,37 +136,37 @@ Warning: money_format() expects parameter 1 to be string, array given in %s on line %d NULL -- Iteration 13 -- -string(1) "1" +string -- Iteration 14 -- -string(0) "" +string -- Iteration 15 -- -string(1) "1" +string -- Iteration 16 -- -string(0) "" +string -- Iteration 17 -- -string(0) "" +string -- Iteration 18 -- -string(0) "" +string -- Iteration 19 -- -string(4) "abcd" +string -- Iteration 20 -- -string(4) "abcd" +string -- Iteration 21 -- -string(5) "0x12f" +string -- Iteration 22 -- -string(18) " *****1,234.56abcd" +string -- Iteration 23 -- Warning: money_format() expects parameter 1 to be string, object given in %s on line %d NULL -- Iteration 24 -- -string(17) " sample object " +string -- Iteration 25 -- Warning: money_format() expects parameter 1 to be string, resource given in %s on line %d NULL -- Iteration 26 -- -string(0) "" +string -- Iteration 27 -- -string(0) "" +string ===Done=== Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation2.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation2.phpt 2009-07-17 15:33:21 UTC (rev 284271) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/money_format_variation2.phpt 2009-07-17 15:56:36 UTC (rev 284272) @@ -2,13 +2,9 @@ Test money_format() function : usage variations - test values for $number argument --SKIPIF-- <?php - if (!function_exists('money_format') || !function_exists('setlocale')) { + if (!function_exists('money_format')) { die("SKIP money_format - not supported\n"); } - - if (setlocale(LC_MONETARY, 'de_DE') == false) { - die("SKIP de_DE locale not available\n"); - } ?> --FILE-- <?php @@ -17,9 +13,10 @@ * Source code: ext/standard/string.c */ -$original = setlocale(LC_MONETARY, 'en_US'); +// =========================================================================================== +// = We do not test for exact return-values, as those might be different between OS-versions = +// =========================================================================================== - echo "*** Testing money_format() function: with unexpected inputs for 'number' argument ***\n"; //get an unset variable @@ -97,38 +94,35 @@ foreach($numbers as $number) { echo "-- Iteration $count --\n"; - var_dump( money_format($format, $number) ); + echo gettype(money_format($format, $number))."\n"; $count ++; } // close the file handle -fclose($file_handle); +fclose($file_handle); -// restore original locale -setlocale(LC_MONETARY, $original); - ?> ===Done=== --EXPECTF-- *** Testing money_format() function: with unexpected inputs for 'number' argument *** -- Iteration 1 -- -string(18) " USD 0.00" +string -- Iteration 2 -- -string(18) " USD 1.00" +string -- Iteration 3 -- -string(18) " USD 255.00" +string -- Iteration 4 -- -string(18) " USD 256.00" +string -- Iteration 5 -- -string(21) " USD 2,147,483,647.00" +string -- Iteration 6 -- -string(21) "-USD 2,147,483,648.00" +string -- Iteration 7 -- -string(18) " USD 10.50" +string -- Iteration 8 -- -string(18) "-USD 20.50" +string -- Iteration 9 -- -string(23) " USD 101,234,567,000.00" +string -- Iteration 10 -- Warning: money_format() expects parameter 2 to be double, array given in %s on line %d @@ -142,17 +136,17 @@ Warning: money_format() expects parameter 2 to be double, array given in %s on line %d NULL -- Iteration 13 -- -string(18) " USD 1.00" +string -- Iteration 14 -- -string(18) " USD 0.00" +string -- Iteration 15 -- -string(18) " USD 1.00" +string -- Iteration 16 -- -string(18) " USD 0.00" +string -- Iteration 17 -- -string(18) " USD 0.00" +string -- Iteration 18 -- -string(18) " USD 0.00" +string -- Iteration 19 -- Warning: money_format() expects parameter 2 to be double, string given in %s on line %d @@ -162,7 +156,7 @@ Warning: money_format() expects parameter 2 to be double, string given in %s on line %d NULL -- Iteration 21 -- -string(18) " USD 303.00" +string -- Iteration 22 -- Warning: money_format() expects parameter 2 to be double, string given in %s on line %d @@ -180,7 +174,7 @@ Warning: money_format() expects parameter 2 to be double, resource given in %s on line %d NULL -- Iteration 26 -- -string(18) " USD 0.00" +string -- Iteration 27 -- -string(18) " USD 0.00" +string ===Done===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php