Wiki

Ticket #153: regression_test_fixes.patch

File regression_test_fixes.patch, 4.3 KB (added by jonathandavid, 16 years ago)

Fixes culture-related issues on several regression tests

  • Source/Cobra.Lang/StringMaker.cobra

     
    3838                return .makeString(x) 
    3939            else 
    4040                # 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 ! 
     41                return String.format(CultureInfo.invariantCulture, '{0:' + format + '}', x) to ! 
    4242 
    4343        def makeString(x as Object?) as String 
    4444            has MethodImpl(MethodImplOptions.Synchronized) 
  • Tests/110-basics-two/120-primitive-type-members.cobra

     
     1 
     2 
    13class Test 
    24 
    35    def main is shared 
     
    1820        assert d.round == 5.0 
    1921        assert d.round(1) == 5.2 
    2022 
    21         d = decimal.parse('5.0') 
     23        d = decimal.parse('5.0', System.Globalization.CultureInfo.invariantCulture) 
    2224        assert d == 5.0 
    2325        d = 3.0 
    2426        assert d.pow(4.5).round(3) == 140.296 
  • Tests/110-basics-two/310-primitive-members.cobra

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

     
     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 
  • Tests/200-misc/300-number-type/100-number-float32.cobra

     
    77I checked the code gen and the System.Single type is definitely in use. 
    88The assertions below prove the imperfect arithmetic whether on .NET or Mono. 
    99""" 
     10 
     11use System.Globalization 
     12 
    1013class X 
    1114 
    1215    shared 
     
    2932             
    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 
    3538            y = 4.0 
  • Tests/200-misc/300-number-type/102-number-float64.cobra

     
    11# .args. -number:float64 
     2 
     3use System.Globalization 
     4 
    25class X 
    36 
    47    shared 
     
    1821            one = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 
    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 
    2427            x = 3.0 
  • Tests/200-misc/300-number-type/106-number-decimal.cobra

     
    11# .args. -number:decimal 
     2 
     3use System.Globalization 
     4 
    25class X 
    36 
    47    shared 
     
    1821            one = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 
    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 
    2427            y = 4.0