Example #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)
Example #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)
Example #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)
Example #4
0
def test_parse_double_must_fail_if_cant_parse():
    parser.parse_double("foobar")
Example #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)
Example #6
0
def test_parse_double_must_fail_if_cant_parse():
    parser.parse_double("foobar")
Example #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)
Example #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)
Example #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)
Example #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)