mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-11 00:01:54 +08:00
passing hex/oct/bin tests for #327
This commit is contained in:
@@ -136,11 +136,10 @@ class Script(object):
|
|||||||
last word part. To ignore certain strange patterns with dots, just
|
last word part. To ignore certain strange patterns with dots, just
|
||||||
use regex.
|
use regex.
|
||||||
"""
|
"""
|
||||||
dots = re.search('^\.|([\d.]+)\.$', path)
|
dots = re.search('^\.|((?:0[xbo])?[\d.]+)\.$', path)
|
||||||
if dots:
|
if dots:
|
||||||
literal = dots.group(1)
|
literal = dots.group(1)
|
||||||
print(literal)
|
if re.match('0[xbo][\da-fA-F]+$|\d\.$|\.{3}$', literal or ''):
|
||||||
if re.search('\d\.|\.{3}', literal or ''):
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -70,14 +70,15 @@ def test_completion_on_number_literals():
|
|||||||
# power notation
|
# power notation
|
||||||
_check_number('1.e14.')
|
_check_number('1.e14.')
|
||||||
_check_number('1.e-3.')
|
_check_number('1.e-3.')
|
||||||
|
_check_number('9e3.')
|
||||||
assert api.Script('1.e3..').completions() == []
|
assert api.Script('1.e3..').completions() == []
|
||||||
assert api.Script('1.e-13..').completions() == []
|
assert api.Script('1.e-13..').completions() == []
|
||||||
|
|
||||||
|
|
||||||
def test_completion_on_complex_literals():
|
def test_completion_on_hex_literals():
|
||||||
assert api.Script('1j..').completions() == []
|
assert api.Script('0x1..').completions() == []
|
||||||
_check_number('1j.', 'complex')
|
_check_number('0x1.', 'int') # hexdecimal
|
||||||
_check_number('44.j.', 'complex')
|
_check_number('0b3.', 'int') # binary
|
||||||
_check_number('4.0j.', 'complex')
|
_check_number('0o7.', 'int') # octal
|
||||||
# No dot no completion
|
# theoretically, but people can just check for syntax errors:
|
||||||
assert api.Script('4j').completions() == []
|
#assert api.Script('0x.').completions() == []
|
||||||
|
|||||||
Reference in New Issue
Block a user