Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1559

Show
Ignore:
Timestamp:
05/26/10 14:21:39 (15 years ago)
Author:
rsinfu
Message:

Reverted r1557 (and r1513 partially).

r1557 relaxed some unittests, as some platforms had accuracy problem with strtold(). But the strict unittests were requirements for D; so r1557 should be reverted.

With this change, these unittests will fail on some platforms such as OSX and Gentoo. However, the unittests SHOULD fail because using strtold() on these platforms is a 'bug' -- we should provide an accurate implementation.

Related issues:
3758: Create D impementation of to!(float, string), etc.
4200: "to!real(to!string(real.min_normal))" raises std.conv.ConvError?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/conv.d

    r1557 r1559  
    18721872    assert( f == 123e+2f ); 
    18731873 
    18741874    f = to!float( "123e-2" ); 
    18751875    assert( f == 123e-2f ); 
    18761876    f = to!float( "123." ); 
    18771877    assert( f == 123.f ); 
    18781878    f = to!float( ".456" ); 
    18791879    assert( f == .456f ); 
    18801880 
    18811881    // min and max 
    1882     f = to!float("1.1755e-38"); 
    1883     assert(feq(cast(real)f, cast(real)1.1755e-38)); 
     1882    f = to!float("1.17549e-38"); 
     1883    assert(feq(cast(real)f, cast(real)1.17549e-38)); 
    18841884    assert(feq(cast(real)f, cast(real)float.min_normal)); 
    18851885    f = to!float("3.4028e+38"); 
    1886     assert(to!string(f) == to!string(3.4028e+38)); 
     1886    assert(to!string(f) == to!string(3.40282e+38)); 
    18871887 
    18881888    // nan 
    18891889    f = to!float("nan"); 
    18901890    assert(to!string(f) == to!string(float.nan)); 
    18911891 
    18921892    bool ok = false; 
    18931893    try 
    18941894    { 
    18951895        to!float("\x00"); 
    18961896    } 
     
    19211921    d = to!double( "123e-2" ); 
    19221922    assert( d == 123e-2 ); 
    19231923    d = to!double( "123." ); 
    19241924    assert( d == 123. ); 
    19251925    d = to!double( ".456" ); 
    19261926    assert( d == .456 ); 
    19271927    d = to!double( "1.23456E+2" ); 
    19281928    assert( d == 1.23456E+2 ); 
    19291929 
    19301930    // min and max 
    1931     d = to!double("2.2251e-308"); 
    1932     assert(feq(cast(real)d, cast(real)2.2251e-308)); 
     1931    d = to!double("2.22508e-308"); 
     1932    assert(feq(cast(real)d, cast(real)2.22508e-308)); 
    19331933    assert(feq(cast(real)d, cast(real)double.min_normal)); 
    1934     d = to!double("1.7976e+308"); 
    1935     assert(to!string(d) == to!string(1.7976e+308)); 
     1934    d = to!double("1.79769e+308"); 
     1935    assert(to!string(d) == to!string(1.79769e+308)); 
     1936    assert(to!string(d) == to!string(double.max)); 
    19361937 
    19371938    // nan 
    19381939    d = to!double("nan"); 
    19391940    assert(to!string(d) == to!string(double.nan)); 
    19401941    //assert(cast(real)d == cast(real)double.nan); 
    19411942 
    19421943    bool ok = false; 
    19431944    try 
    19441945    { 
    19451946        to!double("\x00"); 
     
    19651966    assert(r == 123L); 
    19661967    r = to!real("-123"); 
    19671968    assert(r == -123L); 
    19681969    r = to!real("123e2"); 
    19691970    assert(feq(r, 123e2L)); 
    19701971    r = to!real("123e-2"); 
    19711972    assert(feq(r, 1.23L)); 
    19721973    r = to!real("123."); 
    19731974    assert(r == 123L); 
    19741975    r = to!real(".456"); 
    1975     assert(feq(r, .456L)); 
     1976    assert(r == .456L); 
    19761977 
    19771978    r = to!real("1.23456e+2"); 
    19781979    assert(feq(r,  1.23456e+2L)); 
    19791980    r = to!real(to!string(real.max / 2L)); 
    19801981    assert(to!string(r) == to!string(real.max / 2L)); 
    19811982 
    19821983    // min and max 
    1983     version (Libc_ExactStrtold) 
    1984     { 
    1985         r = to!real(to!string(real.min_normal)); 
    1986         assert(to!string(r) == to!string(real.min_normal)); 
    1987         r = to!real(to!string(real.max)); 
    1988         assert(to!string(r) == to!string(real.max)); 
    1989     } 
     1984    r = to!real(to!string(real.min_normal)); 
     1985    assert(to!string(r) == to!string(real.min_normal)); 
     1986    r = to!real(to!string(real.max)); 
     1987    assert(to!string(r) == to!string(real.max)); 
    19901988 
    19911989    // nan 
    19921990    r = to!real("nan"); 
    19931991    assert(to!string(r) == to!string(real.nan)); 
    19941992    //assert(r == real.nan); 
    19951993 
    19961994    r = to!real(to!string(real.nan)); 
    19971995    assert(to!string(r) == to!string(real.nan)); 
    19981996    //assert(r == real.nan); 
    19991997 
  • trunk/phobos/std/getopt.d

    r1557 r1559  
    576576    getopt(args, "output", &outputFiles); 
    577577    assert(outputFiles.length == 2 
    578578           && outputFiles[0] == "myfile.txt" && outputFiles[0] == "myfile.txt"); 
    579579 
    580580    args = (["program.name", "--tune=alpha=0.5", 
    581581             "--tune", "beta=0.6"]).dup; 
    582582    double[string] tuningParms; 
    583583    getopt(args, "tune", &tuningParms); 
    584584    assert(args.length == 1); 
    585585    assert(tuningParms.length == 2); 
    586     assert(0.4999 < tuningParms["alpha"] && tuningParms["alpha"] < 0.5001); 
    587     assert(0.5999 < tuningParms["beta"] && tuningParms["beta"] < 0.6001); 
     586    assert(tuningParms["alpha"] == 0.5); 
     587    assert(tuningParms["beta"] == 0.6); 
    588588 
    589589    uint verbosityLevel = 1; 
    590590    void myHandler(string option) 
    591591    { 
    592592        if (option == "quiet") 
    593593        { 
    594594            verbosityLevel = 0; 
    595595        } 
    596596        else 
    597597        {