@@ -13,6 +13,10 @@ class ComplexTest extends TestCase
1313
1414 public function setup ()
1515 {
16+ # When tests run in a different locale, this might affect the decimal-point character and thus the validation
17+ # of floats. This makes sure the tests run in a locale that the tests are known to be working in.
18+ setlocale (LC_ALL , "en_US.UTF-8 " );
19+
1620 $ this ->complex = new Complex (new Real (2.05 ), new Real (3.2 ));
1721 }
1822
@@ -77,14 +81,29 @@ public function testGetArgument()
7781 $ this ->assertTrue ($ arg ->sameValueAs ($ this ->complex ->getArgument ()));
7882 }
7983
80- public function testToString ()
84+ public function testToString ($ expectedString = ' 2.034 - 1.4i ' )
8185 {
8286 $ complex = new Complex (new Real (2.034 ), new Real (-1.4 ));
83- $ this ->assertEquals (' 2.034 - 1.4i ' , $ complex ->__toString ());
87+ $ this ->assertEquals ($ expectedString , $ complex ->__toString ());
8488 }
8589
8690 public function testNotSameValue ()
8791 {
8892 $ this ->assertFalse ($ this ->complex ->sameValueAs (new Real (2.035 )));
8993 }
94+
95+ public function testDifferentLocaleWithDifferentDecimalCharacter ()
96+ {
97+ setlocale (LC_ALL , "de_DE.UTF-8 " );
98+
99+ $ this ->testFromNative ();
100+ $ this ->testFromPolar ();
101+ $ this ->testToNative ();
102+ $ this ->testGetReal ();
103+ $ this ->testGetIm ();
104+ $ this ->testGetModulus ();
105+ $ this ->testGetArgument ();
106+ $ this ->testToString ('2,034 - 1,4i ' );
107+ $ this ->testNotSameValue ();
108+ }
90109}
0 commit comments