Changeset 1557
- Timestamp:
- 05/26/10 05:59:52 (15 years ago)
- Files:
-
- trunk/phobos/std/conv.d (modified) (3 diffs)
- trunk/phobos/std/getopt.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phobos/std/conv.d
r1513 r1557 1872 1872 assert( f == 123e+2f ); 1873 1873 1874 1874 f = to!float( "123e-2" ); 1875 1875 assert( f == 123e-2f ); 1876 1876 f = to!float( "123." ); 1877 1877 assert( f == 123.f ); 1878 1878 f = to!float( ".456" ); 1879 1879 assert( f == .456f ); 1880 1880 1881 1881 // min and max 1882 f = to!float("1.175 49435e-38");1883 assert(feq(cast(real)f, cast(real)1.175 49e-38));1882 f = to!float("1.1755e-38"); 1883 assert(feq(cast(real)f, cast(real)1.1755e-38)); 1884 1884 assert(feq(cast(real)f, cast(real)float.min_normal)); 1885 f = to!float("3.4028 2347e+38");1886 assert(to!string(f) == to!string(3.4028 2e+38));1885 f = to!float("3.4028e+38"); 1886 assert(to!string(f) == to!string(3.4028e+38)); 1887 1887 1888 1888 // nan 1889 1889 f = to!float("nan"); 1890 1890 assert(to!string(f) == to!string(float.nan)); 1891 1891 1892 1892 bool ok = false; 1893 1893 try 1894 1894 { 1895 1895 to!float("\x00"); 1896 1896 } … … 1921 1921 d = to!double( "123e-2" ); 1922 1922 assert( d == 123e-2 ); 1923 1923 d = to!double( "123." ); 1924 1924 assert( d == 123. ); 1925 1925 d = to!double( ".456" ); 1926 1926 assert( d == .456 ); 1927 1927 d = to!double( "1.23456E+2" ); 1928 1928 assert( d == 1.23456E+2 ); 1929 1929 1930 1930 // min and max 1931 d = to!double("2.225 0738585072014e-308");1932 assert(feq(cast(real)d, cast(real)2.225 08e-308));1931 d = to!double("2.2251e-308"); 1932 assert(feq(cast(real)d, cast(real)2.2251e-308)); 1933 1933 assert(feq(cast(real)d, cast(real)double.min_normal)); 1934 d = to!double("1.7976931348623157e+308"); 1935 assert(to!string(d) == to!string(1.79769e+308)); 1936 assert(to!string(d) == to!string(double.max)); 1934 d = to!double("1.7976e+308"); 1935 assert(to!string(d) == to!string(1.7976e+308)); 1937 1936 1938 1937 // nan 1939 1938 d = to!double("nan"); 1940 1939 assert(to!string(d) == to!string(double.nan)); 1941 1940 //assert(cast(real)d == cast(real)double.nan); 1942 1941 1943 1942 bool ok = false; 1944 1943 try 1945 1944 { 1946 1945 to!double("\x00"); … … 1966 1965 assert(r == 123L); 1967 1966 r = to!real("-123"); 1968 1967 assert(r == -123L); 1969 1968 r = to!real("123e2"); 1970 1969 assert(feq(r, 123e2L)); 1971 1970 r = to!real("123e-2"); 1972 1971 assert(feq(r, 1.23L)); 1973 1972 r = to!real("123."); 1974 1973 assert(r == 123L); 1975 1974 r = to!real(".456"); 1976 assert( r == .456L);1975 assert(feq(r, .456L)); 1977 1976 1978 1977 r = to!real("1.23456e+2"); 1979 1978 assert(feq(r, 1.23456e+2L)); 1980 1979 r = to!real(to!string(real.max / 2L)); 1981 1980 assert(to!string(r) == to!string(real.max / 2L)); 1982 1981 1983 1982 // min and max 1984 version (FreeBSD) 1985 { 1986 // BSD libc strtold() does a poor job on min/max values. 1987 writefln(" --- std.conv(%s) skipping tests on real.min_normal and real.max ---", __LINE__); 1988 } 1989 else 1983 version (Libc_ExactStrtold) 1990 1984 { 1991 1985 r = to!real(to!string(real.min_normal)); 1992 1986 assert(to!string(r) == to!string(real.min_normal)); 1993 1987 r = to!real(to!string(real.max)); 1994 1988 assert(to!string(r) == to!string(real.max)); 1995 1989 } 1996 1990 1997 1991 // nan 1998 1992 r = to!real("nan"); 1999 1993 assert(to!string(r) == to!string(real.nan)); trunk/phobos/std/getopt.d
r1500 r1557 576 576 getopt(args, "output", &outputFiles); 577 577 assert(outputFiles.length == 2 578 578 && outputFiles[0] == "myfile.txt" && outputFiles[0] == "myfile.txt"); 579 579 580 580 args = (["program.name", "--tune=alpha=0.5", 581 581 "--tune", "beta=0.6"]).dup; 582 582 double[string] tuningParms; 583 583 getopt(args, "tune", &tuningParms); 584 584 assert(args.length == 1); 585 585 assert(tuningParms.length == 2); 586 assert( tuningParms["alpha"] == 0.5);587 assert( tuningParms["beta"] == 0.6);586 assert(0.4999 < tuningParms["alpha"] && tuningParms["alpha"] < 0.5001); 587 assert(0.5999 < tuningParms["beta"] && tuningParms["beta"] < 0.6001); 588 588 589 589 uint verbosityLevel = 1; 590 590 void myHandler(string option) 591 591 { 592 592 if (option == "quiet") 593 593 { 594 594 verbosityLevel = 0; 595 595 } 596 596 else 597 597 {
