-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from vyperlang/charles/review
Charles/review
- Loading branch information
Showing
13 changed files
with
527 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import time | ||
from vyper_lsp.debounce import Debouncer # Import Debouncer from your module | ||
|
||
|
||
def test_debounce(): | ||
result = [] | ||
|
||
def test_function(arg): | ||
result.append(arg) | ||
|
||
debouncer = Debouncer(wait=0.5) | ||
debounced_func = debouncer.debounce(test_function) | ||
|
||
debounced_func("first call") | ||
time.sleep(0.2) # Sleep for less than the debounce period | ||
debounced_func("second call") | ||
time.sleep( | ||
0.6 | ||
) # Sleep for more than the debounce period to allow the function to execute | ||
|
||
assert result == ["second call"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from vyper_lsp import utils | ||
|
||
|
||
def test_get_word_at_cursor(): | ||
text = "self.foo = 123" | ||
assert utils.get_word_at_cursor(text, 0) == "self" | ||
assert utils.get_word_at_cursor(text, 1) == "self" | ||
assert utils.get_word_at_cursor(text, 5) == "foo" | ||
assert utils.get_word_at_cursor(text, 12) == "123" | ||
|
||
text = "foo_bar = 123" | ||
assert utils.get_word_at_cursor(text, 0) == "foo_bar" | ||
assert utils.get_word_at_cursor(text, 4) == "foo_bar" | ||
|
||
|
||
def test_get_expression_at_cursor(): | ||
text = "self.foo = 123" | ||
assert utils.get_expression_at_cursor(text, 0) == "self.foo" | ||
assert utils.get_expression_at_cursor(text, 1) == "self.foo" | ||
assert utils.get_expression_at_cursor(text, 5) == "self.foo" | ||
assert utils.get_expression_at_cursor(text, 12) == "123" | ||
|
||
text = "foo_bar = self.baz (1,2,3)" | ||
assert utils.get_expression_at_cursor(text, 0) == "foo_bar" | ||
assert utils.get_expression_at_cursor(text, 4) == "foo_bar" | ||
assert utils.get_expression_at_cursor(text, 21) == "self.baz (1,2,3)" | ||
|
||
|
||
def test_get_internal_fn_name_at_cursor(): | ||
text = "self.foo = 123" | ||
assert utils.get_internal_fn_name_at_cursor(text, 0) is None | ||
assert utils.get_internal_fn_name_at_cursor(text, 1) is None | ||
assert utils.get_internal_fn_name_at_cursor(text, 5) is None | ||
assert utils.get_internal_fn_name_at_cursor(text, 12) is None | ||
|
||
text = "foo_bar = self.baz (1,2,3)" | ||
assert utils.get_internal_fn_name_at_cursor(text, 0) is None | ||
assert utils.get_internal_fn_name_at_cursor(text, 4) is None | ||
assert utils.get_internal_fn_name_at_cursor(text, 21) == "baz" | ||
|
||
text = "self.foo(self.bar())" | ||
assert utils.get_internal_fn_name_at_cursor(text, 7) == "foo" | ||
assert utils.get_internal_fn_name_at_cursor(text, 15) == "bar" |
Oops, something went wrong.