mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +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
|
||||
use regex.
|
||||
"""
|
||||
dots = re.search('^\.|([\d.]+)\.$', path)
|
||||
dots = re.search('^\.|((?:0[xbo])?[\d.]+)\.$', path)
|
||||
if dots:
|
||||
literal = dots.group(1)
|
||||
print(literal)
|
||||
if re.search('\d\.|\.{3}', literal or ''):
|
||||
if re.match('0[xbo][\da-fA-F]+$|\d\.$|\.{3}$', literal or ''):
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -70,14 +70,15 @@ def test_completion_on_number_literals():
|
||||
# power notation
|
||||
_check_number('1.e14.')
|
||||
_check_number('1.e-3.')
|
||||
_check_number('9e3.')
|
||||
assert api.Script('1.e3..').completions() == []
|
||||
assert api.Script('1.e-13..').completions() == []
|
||||
|
||||
|
||||
def test_completion_on_complex_literals():
|
||||
assert api.Script('1j..').completions() == []
|
||||
_check_number('1j.', 'complex')
|
||||
_check_number('44.j.', 'complex')
|
||||
_check_number('4.0j.', 'complex')
|
||||
# No dot no completion
|
||||
assert api.Script('4j').completions() == []
|
||||
def test_completion_on_hex_literals():
|
||||
assert api.Script('0x1..').completions() == []
|
||||
_check_number('0x1.', 'int') # hexdecimal
|
||||
_check_number('0b3.', 'int') # binary
|
||||
_check_number('0o7.', 'int') # octal
|
||||
# theoretically, but people can just check for syntax errors:
|
||||
#assert api.Script('0x.').completions() == []
|
||||
|
||||
Reference in New Issue
Block a user