]> granicus.if.org Git - php/commitdiff
MFB: fixed tests. money_format() is implemented in underlying system, not in php...
authorAlexey Zakhlestin <indeyets@php.net>
Fri, 17 Jul 2009 16:04:06 +0000 (16:04 +0000)
committerAlexey Zakhlestin <indeyets@php.net>
Fri, 17 Jul 2009 16:04:06 +0000 (16:04 +0000)
ext/standard/tests/strings/money_format_basic1.phpt
ext/standard/tests/strings/money_format_basic2.phpt [deleted file]
ext/standard/tests/strings/money_format_basic3.phpt [deleted file]
ext/standard/tests/strings/money_format_error.phpt
ext/standard/tests/strings/money_format_variation1.phpt
ext/standard/tests/strings/money_format_variation2.phpt

index e76aa60875f70485c9b8b8b997afac1f107a7f11..70b5ca574eb6764cd0f1a5a6b4bae24ac1a837fe 100644 (file)
@@ -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 @@ Test money_format() function : basic functionality using national currency symbo
  * 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 @@ $negative_value = -1234.5678;
 // 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));
-
-setlocale(LC_MONETARY, $original);
+echo gettype(money_format('%=*!14#8.2n', $value))."\n";
+echo gettype(money_format('%=*!14#8.2n', $negative_value))."\n";
 
 ?>
 ===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===
 
diff --git a/ext/standard/tests/strings/money_format_basic2.phpt b/ext/standard/tests/strings/money_format_basic2.phpt
deleted file mode 100644 (file)
index 8074cf9..0000000
+++ /dev/null
@@ -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===
-
diff --git a/ext/standard/tests/strings/money_format_basic3.phpt b/ext/standard/tests/strings/money_format_basic3.phpt
deleted file mode 100644 (file)
index 98d0fca..0000000
+++ /dev/null
@@ -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===
index fac89d1b55301db14cad2c6bdee32a49ed83aa9c..cf110b43ab59804abcf413227fc7939343311839 100644 (file)
@@ -13,6 +13,10 @@ Test money_format() function : error conditions
  * 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;
index 4224a6975ebdfadbc193796ad8a00a4738802e41..492824f864568d2110125264db6a98c76bbf6351 100644 (file)
@@ -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,8 +13,9 @@ Test money_format() function :  usage variations - test values for $format argum
  * 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";
 
@@ -97,38 +94,34 @@ $value = 1234.56;
 
 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 +135,37 @@ NULL
 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===
index 24d48735ba8d2f19730320c628dbaae152d813f7..9769ff5fa547ae0b4099d5d924ac622f9ebd3007 100644 (file)
@@ -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,8 +13,9 @@ Test money_format() function :  usage variations - test values for $number argum
  * 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";
 
@@ -97,38 +94,34 @@ $format = '%14#8.2i';
 
 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);  
-
-// 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 +135,17 @@ NULL
 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 +155,7 @@ NULL
 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 +173,7 @@ NULL
 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===