mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Fix issues with the right count of parsers used.
This commit is contained in:
@@ -61,24 +61,32 @@ def test_carriage_return_splitting():
|
||||
|
||||
def test_change_and_undo():
|
||||
|
||||
def fp(src):
|
||||
def fp(src, number_parsers_used):
|
||||
p = FastParser(load_grammar(), u(src))
|
||||
cache.save_parser(None, None, p, pickling=False)
|
||||
|
||||
# TODO Don't change get_code, the whole thing should be the same.
|
||||
# -> Need to refactor the parser first, though.
|
||||
assert src == p.module.get_code()[:-1]
|
||||
assert p.number_parsers_used == number_parsers_used
|
||||
|
||||
cache.parser_cache.pop(None, None)
|
||||
func_before = 'def func():\n pass\n'
|
||||
fp(func_before + 'a')
|
||||
fp(func_before + 'b')
|
||||
fp(func_before + 'a')
|
||||
fp(func_before + 'a')
|
||||
# Parse the function and a.
|
||||
fp(func_before + 'a', 2)
|
||||
# Parse just b.
|
||||
fp(func_before + 'b', 1)
|
||||
# b has changed to a again, so parse that.
|
||||
fp(func_before + 'a', 1)
|
||||
# Same as before no parsers should be used.
|
||||
fp(func_before + 'a', 0)
|
||||
|
||||
fp('a')
|
||||
fp('b')
|
||||
fp('a')
|
||||
# Getting rid of an old parser: Still no parsers used.
|
||||
fp('a', 0)
|
||||
# Now the file has completely change and we need to parse.
|
||||
fp('b', 1)
|
||||
# And again.
|
||||
fp('a', 1)
|
||||
|
||||
|
||||
def test_incomplete_function():
|
||||
|
||||
Reference in New Issue
Block a user