File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 6
6
from .CacheSelfie import cache_selfie_binary as cache_selfie_binary
7
7
from .CacheSelfie import cache_selfie_json as cache_selfie_json
8
8
from .CommentTracker import CommentTracker as CommentTracker
9
+ from .EscapeLeadingWhitespace import EscapeLeadingWhitespace as EscapeLeadingWhitespace
9
10
from .FS import FS as FS
10
11
from .Lens import Camera as Camera
11
12
from .Lens import CompoundLens as CompoundLens
Original file line number Diff line number Diff line change
1
+ from selfie_lib import EscapeLeadingWhitespace
2
+
3
+ def test_detection ():
4
+ # not enough to detect
5
+ assert EscapeLeadingWhitespace .appropriate_for ("" ) == EscapeLeadingWhitespace .ALWAYS
6
+ assert EscapeLeadingWhitespace .appropriate_for ("abc" ) == EscapeLeadingWhitespace .ALWAYS
7
+ assert EscapeLeadingWhitespace .appropriate_for ("abc\n abc" ) == EscapeLeadingWhitespace .ALWAYS
8
+
9
+ # all spaces -> only tabs need escape
10
+ assert EscapeLeadingWhitespace .appropriate_for (" " ) == EscapeLeadingWhitespace .ONLY_ON_TAB
11
+ assert EscapeLeadingWhitespace .appropriate_for (" " ) == EscapeLeadingWhitespace .ONLY_ON_TAB
12
+ assert EscapeLeadingWhitespace .appropriate_for (" \n " ) == EscapeLeadingWhitespace .ONLY_ON_TAB
13
+
14
+ # all tabs -> only space needs escape
15
+ assert EscapeLeadingWhitespace .appropriate_for ("\t " ) == EscapeLeadingWhitespace .ONLY_ON_SPACE
16
+ assert EscapeLeadingWhitespace .appropriate_for ("\t \t " ) == EscapeLeadingWhitespace .ONLY_ON_SPACE
17
+ assert EscapeLeadingWhitespace .appropriate_for ("\t \n \t " ) == EscapeLeadingWhitespace .ONLY_ON_SPACE
18
+
19
+ # it's a mess -> everything needs escape
20
+ assert EscapeLeadingWhitespace .appropriate_for ("\t \n " ) == EscapeLeadingWhitespace .ALWAYS
21
+
22
+ # single spaces and tabs -> only tabs need escape
23
+ test_string = """/*
24
+ * Copyright
25
+ */
26
+ interface Foo {
27
+ \t fun bar()
28
+ }"""
29
+ assert EscapeLeadingWhitespace .appropriate_for (test_string ) == EscapeLeadingWhitespace .ALWAYS
You can’t perform that action at this time.
0 commit comments