示例#1
0
def test_parse_double_is_able_to_parse_exp_notation():
    (a, b, e) = (random.randint(0,
                                10), random.randint(0,
                                                    10), random.randint(0, 10))
    (num, s) = parser.parse_double("%d.%de%dfoo" % (a, b, e))
    eq_(float("%d.%de%d" % (a, b, e)), num)
    ok_("foo", s)
示例#2
0
def test_parse_double_is_able_to_parse_minus_inf():
    for inf in ["-inf", "-Infinity"]:
        (num, s) = parser.parse_double("%sfoo" % inf)
        ok_(math.isinf(num))
        eq_("foo", s)
示例#3
0
def test_parse_double_is_able_to_parse_double_numbers():
    tmp = random.random()
    (num, s) = parser.parse_double("%sfoo" % repr(tmp))
    eq_(num, tmp)
    eq_("foo", s)
示例#4
0
def test_parse_double_must_fail_if_cant_parse():
    parser.parse_double("foobar")
示例#5
0
def test_parse_double_is_able_to_parse_nan():
    for nan in ["nan", "NaN"]:
        (num, s) = parser.parse_double("%sfoo" % nan)
        ok_(math.isnan(num))
        eq_("foo", s)
示例#6
0
def test_parse_double_must_fail_if_cant_parse():
    parser.parse_double("foobar")
示例#7
0
def test_parse_double_is_able_to_parse_exp_notation():
    (a, b, e) = (random.randint(0, 10), random.randint(0, 10), random.randint(0, 10))
    (num, s) = parser.parse_double("%d.%de%dfoo" % (a, b, e))
    eq_(float("%d.%de%d" % (a,b,e)), num)
    ok_("foo", s)
示例#8
0
def test_parse_double_is_able_to_parse_double_numbers():
    tmp = random.random()
    (num, s) = parser.parse_double("%sfoo" % repr(tmp))
    eq_(num, tmp)
    eq_("foo", s)
示例#9
0
def test_parse_double_is_able_to_parse_minus_inf():
    for inf in ["-inf", "-Infinity"]:
        (num, s) = parser.parse_double("%sfoo" % inf)
        ok_(math.isinf(num))
        eq_("foo", s)
示例#10
0
def test_parse_double_is_able_to_parse_nan():
    for nan in ["nan", "NaN"]:
        (num, s) = parser.parse_double("%sfoo" % nan)
        ok_(math.isnan(num))
        eq_("foo", s)