Wiki

Changeset 1953

Show
Ignore:
Timestamp:
03/08/09 03:42:11 (3 years ago)
Author:
Chuck.Esterbrook
Message:

Update tests to be robust against variations in culture which would normally change .toString results.
ticket:153
credit:jonathandavid

Location:
cobra/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Cobra.Lang/StringMaker.cobra

    r1895 r1953  
    22 
    33    use System.Collections 
     4    use System.Globalization 
    45    use System.Reflection 
    56    use System.Runtime.CompilerServices 
     
    3940            else 
    4041                # Is there a faster way to do this? Some types already have .toString(format as String) overload. 
    41                 return String.format('{0:' + format + '}', x) to ! 
     42                return String.format(CultureInfo.invariantCulture, '{0:' + format + '}', x) to ! 
    4243 
    4344        def makeString(x as Object?) as String 
  • cobra/trunk/Tests/110-basics-two/120-primitive-type-members.cobra

    r1845 r1953  
    1919        assert d.round(1) == 5.2 
    2020 
    21         d = decimal.parse('5.0') 
     21        d = decimal.parse('5.0', System.Globalization.CultureInfo.invariantCulture) 
    2222        assert d == 5.0 
    2323        d = 3.0 
  • cobra/trunk/Tests/110-basics-two/310-primitive-members.cobra

    r1177 r1953  
     1use System.Globalization 
     2 
    13class Test 
    24 
    35    def main is shared 
    46        x = 5.0f 
    5         s = x.toString('0.0') 
     7        s = x.toString('0.0', CultureInfo.invariantCulture) 
    68        assert s == '5.0' 
    7         s = x.toString('0.0').trim 
     9        s = x.toString('0.0', CultureInfo.invariantCulture).trim 
    810        assert s == '5.0' 
  • cobra/trunk/Tests/110-basics-two/510-number-parse.cobra

    r1177 r1953  
     1use System.Globalization 
     2 
    13class Foo 
    24 
    35    def main is shared 
    4         f as float = float.parse('3.5') 
     6        f as float = float.parse('3.5', CultureInfo.invariantCulture) 
    57        assert f==3.5f 
  • cobra/trunk/Tests/200-misc/300-number-type/100-number-float32.cobra

    r1553 r1953  
    88The assertions below prove the imperfect arithmetic whether on .NET or Mono. 
    99""" 
     10 
     11use System.Globalization 
     12 
    1013class X 
    1114 
     
    3033            assert 1.0 <> one or 0.9 <> pointNine 
    3134 
    32             assert one.toString('R') == '1.00000012' or pointNine.toString('R') == '0.900000036' 
     35            assert one.toString('R', CultureInfo.invariantCulture) == '1.00000012' or pointNine.toString('R', CultureInfo.invariantCulture) == '0.900000036' 
    3336 
    3437            x = 3.0 
  • cobra/trunk/Tests/200-misc/300-number-type/102-number-float64.cobra

    r1417 r1953  
    11# .args. -number:float64 
     2 
     3use System.Globalization 
     4 
    25class X 
    36 
     
    1922            assert 1.0 <> one 
    2023 
    21             roundTripFormat = one.toString('R') 
     24            roundTripFormat = one.toString('R', CultureInfo.invariantCulture) 
    2225            assert roundTripFormat.startsWith('0.999999') 
    2326 
  • cobra/trunk/Tests/200-misc/300-number-type/106-number-decimal.cobra

    r1417 r1953  
    11# .args. -number:decimal 
     2 
     3use System.Globalization 
     4 
    25class X 
    36 
     
    1922            assert 1.0 == one 
    2023 
    21             assert one.toString == '1.0' 
     24            assert one.toString(CultureInfo.invariantCulture) == '1.0' 
    2225 
    2326            x = 3.0