Skip to content

Commit 2cd4c95

Browse files
committed
Add tests for float
1 parent 5c70631 commit 2cd4c95

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/snippets/floats.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,26 @@
206206
# Test special case for lexer, float starts with a dot:
207207
a = .5
208208
assert a == 0.5
209+
assert 3.14 == float('3.14')
210+
src = """
211+
a = 3._14
212+
"""
213+
214+
with assert_raises(SyntaxError):
215+
exec(src)
216+
src = """
217+
a = 3.__14
218+
"""
219+
220+
with assert_raises(SyntaxError):
221+
exec(src)
222+
223+
src = """
224+
a = 3.1__4
225+
"""
226+
227+
with assert_raises(SyntaxError):
228+
exec(src)
209229

210230
assert float.fromhex('0x0.0p+0') == 0.0
211231
assert float.fromhex('-0x0.0p+0') == -0.0

0 commit comments

Comments
 (0)