Ejemplo n.º 1
0
def test_strtod():
    assert strtod("12345") == 12345.0
    assert strtod("1.1") == 1.1
    assert strtod("3.47") == 3.47
    assert strtod(".125") == .125
    py.test.raises(ValueError, strtod, "123A")
    py.test.raises(ValueError, strtod, "")
    py.test.raises(ValueError, strtod, " ")
    py.test.raises(ValueError, strtod, "\0")
    py.test.raises(ValueError, strtod, "3\09")
Ejemplo n.º 2
0
def test_strtod():
    assert strtod("12345") == 12345.0
    assert strtod("1.1") == 1.1
    assert strtod("3.47") == 3.47
    assert strtod(".125") == .125
    py.test.raises(ValueError, strtod, "123A")
    py.test.raises(ValueError, strtod, "")
    py.test.raises(ValueError, strtod, " ")
    py.test.raises(ValueError, strtod, "\0")
    py.test.raises(ValueError, strtod, "3\09")
Ejemplo n.º 3
0
 def command_print(cmd, extra):
     if extra == 'print-me':
         stuff = dbstate.stuff
     elif extra == '$0':
         stuff = dbstate.metavar
     elif extra == '2.35':
         val = rdtoa.strtod('2.35')
         valx, valy = math.modf(val)
         revdb.send_output(rdtoa.dtoa(valx) + '\n')
         revdb.send_output(rdtoa.dtoa(valy) + '\n')
         xx, yy = math.frexp(val)
         revdb.send_output(rdtoa.dtoa(xx) + '\n')
         revdb.send_output('%d\n' % yy)
         return
     elif extra == 'very-long-loop':
         i = 0
         total = 0
         while i < 2000000000:
             total += revdb.flag_io_disabled()
             i += 1
         revdb.send_output(str(total))
         return
     else:
         assert False
     uid = revdb.get_unique_id(stuff)
     ll_assert(uid > 0, "uid == 0")
     revdb.send_nextnid(uid)  # outputs '$NUM = '
     revdb.send_output('stuff\n')
     dbstate.printed_stuff = stuff
Ejemplo n.º 4
0
def rstring_to_float(s):
    from rpython.rlib.rdtoa import strtod
    return strtod(s)
Ejemplo n.º 5
0
def rstring_to_float(s):
    from rpython.rlib.rdtoa import strtod
    return strtod(s)