Changeset 1559
- Timestamp:
- 05/26/10 14:21:39 (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
r1557 r1559 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 5e-38");1883 assert(feq(cast(real)f, cast(real)1.175 5e-38));1882 f = to!float("1.17549e-38"); 1883 assert(feq(cast(real)f, cast(real)1.17549e-38)); 1884 1884 assert(feq(cast(real)f, cast(real)float.min_normal)); 1885 1885 f = to!float("3.4028e+38"); 1886 assert(to!string(f) == to!string(3.4028 e+38));1886 assert(to!string(f) == to!string(3.40282e+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 1e-308");1932 assert(feq(cast(real)d, cast(real)2.225 1e-308));1931 d = to!double("2.22508e-308"); 1932 assert(feq(cast(real)d, cast(real)2.22508e-308)); 1933 1933 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)); 1936 1937 1937 1938 // nan 1938 1939 d = to!double("nan"); 1939 1940 assert(to!string(d) == to!string(double.nan)); 1940 1941 //assert(cast(real)d == cast(real)double.nan); 1941 1942 1942 1943 bool ok = false; 1943 1944 try 1944 1945 { 1945 1946 to!double("\x00"); … … 1965 1966 assert(r == 123L); 1966 1967 r = to!real("-123"); 1967 1968 assert(r == -123L); 1968 1969 r = to!real("123e2"); 1969 1970 assert(feq(r, 123e2L)); 1970 1971 r = to!real("123e-2"); 1971 1972 assert(feq(r, 1.23L)); 1972 1973 r = to!real("123."); 1973 1974 assert(r == 123L); 1974 1975 r = to!real(".456"); 1975 assert( feq(r, .456L));1976 assert(r == .456L); 1976 1977 1977 1978 r = to!real("1.23456e+2"); 1978 1979 assert(feq(r, 1.23456e+2L)); 1979 1980 r = to!real(to!string(real.max / 2L)); 1980 1981 assert(to!string(r) == to!string(real.max / 2L)); 1981 1982 1982 1983 // 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)); 1990 1988 1991 1989 // nan 1992 1990 r = to!real("nan"); 1993 1991 assert(to!string(r) == to!string(real.nan)); 1994 1992 //assert(r == real.nan); 1995 1993 1996 1994 r = to!real(to!string(real.nan)); 1997 1995 assert(to!string(r) == to!string(real.nan)); 1998 1996 //assert(r == real.nan); 1999 1997 trunk/phobos/std/getopt.d
r1557 r1559 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( 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); 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 {
