Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 35 lines (26 sloc) 1.506 kB
3682ff0 @baverman pairs parser moved into core
authored
1 from snaked.util.pairs_parser import get_brackets, find_closing_quote_pos
6e56553 @baverman Full smart selection implemented
authored
2
0f96de4 @baverman Fix smart select in non ascii files. Custom bracket matcher allows di…
authored
3 def test_parentheses_matcher():
4 assert get_brackets('foo()\nboo()', 4) == ('(', 4, 5)
5
6e56553 @baverman Full smart selection implemented
authored
6 assert get_brackets('foo(1,2, boo(a, b))', 13) == ('(', 13, 18)
7 assert get_brackets('foo(1,2, boo(a, b))', 12) == ('(', 4, 19)
8
9 assert get_brackets('foo(a[sas])', 6) == ('[', 6, 10)
10 assert get_brackets('foo(a[sas])', 7) == ('[', 6, 10)
11 assert get_brackets('foo(a[sas])', 9) == ('[', 6, 10)
12 assert get_brackets('foo(a[sas])', 10) == ('(', 4, 11)
13
14 assert get_brackets('foo() = boo()', 5) == (None, None, None)
15 assert get_brackets('foo() = boo()', 6) == (None, None, None)
16 assert get_brackets('foo() = boo()', 11) == (None, None, None)
17 assert get_brackets('foo() = boo()', 12) == ('(', 12, 13)
18
19 def test_quotes_matcher():
20 assert get_brackets(r'foo(")(\")")', 4) == ('(', 4, 12)
21 assert get_brackets(r'foo(")(\")")', 11) == ('(', 4, 12)
22
23 assert get_brackets(r'foo(")(\")")', 5) == ('"', 5, 11)
24 assert get_brackets(r'foo(")(\")")', 6) == ('"', 5, 11)
25 assert get_brackets(r"foo(')(\')')", 10) == ("'", 5, 11)
26
27 def test_triple_quotes_matcher():
28 assert get_brackets(r'foo("""()""")', 4) == ('(', 4, 13)
29 assert get_brackets(r'foo("""()""")', 7) == ('"""', 7, 12)
30 assert get_brackets(r"foo('''()''')", 9) == ("'''", 7, 12)
5341152 @baverman fix quotes finding in smart select
authored
31
32 def test_close_quote():
33 assert find_closing_quote_pos("'", "sss '' ddd '", 5) == 6
fc53779 @baverman fix quotes matching
authored
34 assert find_closing_quote_pos("'", "sss '\dfg' ddd '", 5) == 10
Something went wrong with that request. Please try again.