@@ -7,114 +7,114 @@ suite('Position', () => {
7
7
assert . throws ( ( ) => new Position ( - 1 , 0 ) )
8
8
assert . throws ( ( ) => new Position ( 0 , - 1 ) )
9
9
10
- const pos = new Position ( 0 , 0 )
11
- assert . throws ( ( ) => ( ( pos as any ) . line = - 1 ) )
12
- assert . throws ( ( ) => ( ( pos as any ) . character = - 1 ) )
13
- assert . throws ( ( ) => ( ( pos as any ) . line = 12 ) )
10
+ const position = new Position ( 0 , 0 )
11
+ assert . throws ( ( ) => ( ( position as any ) . line = - 1 ) )
12
+ assert . throws ( ( ) => ( ( position as any ) . character = - 1 ) )
13
+ assert . throws ( ( ) => ( ( position as any ) . line = 12 ) )
14
14
15
- const { line, character } = pos . toJSON ( )
15
+ const { line, character } = position . toJSON ( )
16
16
assert . strictEqual ( line , 0 )
17
17
assert . strictEqual ( character , 0 )
18
18
} )
19
19
20
20
test ( 'toJSON' , ( ) => {
21
- const pos = new Position ( 4 , 2 )
22
- assertToJSON ( pos , { line : 4 , character : 2 } )
21
+ const position = new Position ( 4 , 2 )
22
+ assertToJSON ( position , { line : 4 , character : 2 } )
23
23
} )
24
24
25
25
test ( 'isBefore(OrEqual)?' , ( ) => {
26
- const p1 = new Position ( 1 , 3 )
27
- const p2 = new Position ( 1 , 2 )
28
- const p3 = new Position ( 0 , 4 )
29
-
30
- assert ( p1 . isBeforeOrEqual ( p1 ) )
31
- assert ( ! p1 . isBefore ( p1 ) )
32
- assert ( p2 . isBefore ( p1 ) )
33
- assert ( p3 . isBefore ( p2 ) )
26
+ const position1 = new Position ( 1 , 3 )
27
+ const position2 = new Position ( 1 , 2 )
28
+ const position3 = new Position ( 0 , 4 )
29
+
30
+ assert ( position1 . isBeforeOrEqual ( position1 ) )
31
+ assert ( ! position1 . isBefore ( position1 ) )
32
+ assert ( position2 . isBefore ( position1 ) )
33
+ assert ( position3 . isBefore ( position2 ) )
34
34
} )
35
35
36
36
test ( 'isAfter(OrEqual)?' , ( ) => {
37
- const p1 = new Position ( 1 , 3 )
38
- const p2 = new Position ( 1 , 2 )
39
- const p3 = new Position ( 0 , 4 )
40
-
41
- assert ( p1 . isAfterOrEqual ( p1 ) )
42
- assert ( ! p1 . isAfter ( p1 ) )
43
- assert ( p1 . isAfter ( p2 ) )
44
- assert ( p2 . isAfter ( p3 ) )
45
- assert ( p1 . isAfter ( p3 ) )
37
+ const position1 = new Position ( 1 , 3 )
38
+ const position2 = new Position ( 1 , 2 )
39
+ const position3 = new Position ( 0 , 4 )
40
+
41
+ assert ( position1 . isAfterOrEqual ( position1 ) )
42
+ assert ( ! position1 . isAfter ( position1 ) )
43
+ assert ( position1 . isAfter ( position2 ) )
44
+ assert ( position2 . isAfter ( position3 ) )
45
+ assert ( position1 . isAfter ( position3 ) )
46
46
} )
47
47
48
48
test ( 'compareTo' , ( ) => {
49
- const p1 = new Position ( 1 , 3 )
50
- const p2 = new Position ( 1 , 2 )
51
- const p3 = new Position ( 0 , 4 )
52
-
53
- assert . strictEqual ( p1 . compareTo ( p1 ) , 0 )
54
- assert . strictEqual ( p2 . compareTo ( p1 ) , - 1 )
55
- assert . strictEqual ( p1 . compareTo ( p2 ) , 1 )
56
- assert . strictEqual ( p2 . compareTo ( p3 ) , 1 )
57
- assert . strictEqual ( p1 . compareTo ( p3 ) , 1 )
49
+ const position1 = new Position ( 1 , 3 )
50
+ const position2 = new Position ( 1 , 2 )
51
+ const position3 = new Position ( 0 , 4 )
52
+
53
+ assert . strictEqual ( position1 . compareTo ( position1 ) , 0 )
54
+ assert . strictEqual ( position2 . compareTo ( position1 ) , - 1 )
55
+ assert . strictEqual ( position1 . compareTo ( position2 ) , 1 )
56
+ assert . strictEqual ( position2 . compareTo ( position3 ) , 1 )
57
+ assert . strictEqual ( position1 . compareTo ( position3 ) , 1 )
58
58
} )
59
59
60
60
test ( 'translate' , ( ) => {
61
- const p1 = new Position ( 1 , 3 )
62
-
63
- assert ( p1 . translate ( ) === p1 )
64
- assert ( p1 . translate ( { } ) === p1 )
65
- assert ( p1 . translate ( 0 , 0 ) === p1 )
66
- assert ( p1 . translate ( 0 ) === p1 )
67
- assert ( p1 . translate ( undefined , 0 ) === p1 )
68
- assert ( p1 . translate ( undefined ) === p1 )
69
-
70
- let res = p1 . translate ( - 1 )
71
- assert . strictEqual ( res . line , 0 )
72
- assert . strictEqual ( res . character , 3 )
73
-
74
- res = p1 . translate ( { lineDelta : - 1 } )
75
- assert . strictEqual ( res . line , 0 )
76
- assert . strictEqual ( res . character , 3 )
77
-
78
- res = p1 . translate ( undefined , - 1 )
79
- assert . strictEqual ( res . line , 1 )
80
- assert . strictEqual ( res . character , 2 )
81
-
82
- res = p1 . translate ( { characterDelta : - 1 } )
83
- assert . strictEqual ( res . line , 1 )
84
- assert . strictEqual ( res . character , 2 )
85
-
86
- res = p1 . translate ( 11 )
87
- assert . strictEqual ( res . line , 12 )
88
- assert . strictEqual ( res . character , 3 )
89
-
90
- assert . throws ( ( ) => p1 . translate ( null as any ) )
91
- assert . throws ( ( ) => p1 . translate ( null as any , null as any ) )
92
- assert . throws ( ( ) => p1 . translate ( - 2 ) )
93
- assert . throws ( ( ) => p1 . translate ( { lineDelta : - 2 } ) )
94
- assert . throws ( ( ) => p1 . translate ( - 2 , null as any ) )
95
- assert . throws ( ( ) => p1 . translate ( 0 , - 4 ) )
61
+ const position1 = new Position ( 1 , 3 )
62
+
63
+ assert ( position1 . translate ( ) === position1 )
64
+ assert ( position1 . translate ( { } ) === position1 )
65
+ assert ( position1 . translate ( 0 , 0 ) === position1 )
66
+ assert ( position1 . translate ( 0 ) === position1 )
67
+ assert ( position1 . translate ( undefined , 0 ) === position1 )
68
+ assert ( position1 . translate ( undefined ) === position1 )
69
+
70
+ let translated = position1 . translate ( - 1 )
71
+ assert . strictEqual ( translated . line , 0 )
72
+ assert . strictEqual ( translated . character , 3 )
73
+
74
+ translated = position1 . translate ( { lineDelta : - 1 } )
75
+ assert . strictEqual ( translated . line , 0 )
76
+ assert . strictEqual ( translated . character , 3 )
77
+
78
+ translated = position1 . translate ( undefined , - 1 )
79
+ assert . strictEqual ( translated . line , 1 )
80
+ assert . strictEqual ( translated . character , 2 )
81
+
82
+ translated = position1 . translate ( { characterDelta : - 1 } )
83
+ assert . strictEqual ( translated . line , 1 )
84
+ assert . strictEqual ( translated . character , 2 )
85
+
86
+ translated = position1 . translate ( 11 )
87
+ assert . strictEqual ( translated . line , 12 )
88
+ assert . strictEqual ( translated . character , 3 )
89
+
90
+ assert . throws ( ( ) => position1 . translate ( null as any ) )
91
+ assert . throws ( ( ) => position1 . translate ( null as any , null as any ) )
92
+ assert . throws ( ( ) => position1 . translate ( - 2 ) )
93
+ assert . throws ( ( ) => position1 . translate ( { lineDelta : - 2 } ) )
94
+ assert . throws ( ( ) => position1 . translate ( - 2 , null as any ) )
95
+ assert . throws ( ( ) => position1 . translate ( 0 , - 4 ) )
96
96
} )
97
97
98
98
test ( 'with' , ( ) => {
99
- const p1 = new Position ( 1 , 3 )
100
-
101
- assert ( p1 . with ( ) === p1 )
102
- assert ( p1 . with ( 1 ) === p1 )
103
- assert ( p1 . with ( undefined , 3 ) === p1 )
104
- assert ( p1 . with ( 1 , 3 ) === p1 )
105
- assert ( p1 . with ( undefined ) === p1 )
106
- assert ( p1 . with ( { line : 1 } ) === p1 )
107
- assert ( p1 . with ( { character : 3 } ) === p1 )
108
- assert ( p1 . with ( { line : 1 , character : 3 } ) === p1 )
109
-
110
- const p2 = p1 . with ( { line : 0 , character : 11 } )
111
- assert . strictEqual ( p2 . line , 0 )
112
- assert . strictEqual ( p2 . character , 11 )
113
-
114
- assert . throws ( ( ) => p1 . with ( null as any ) )
115
- assert . throws ( ( ) => p1 . with ( - 9 ) )
116
- assert . throws ( ( ) => p1 . with ( 0 , - 9 ) )
117
- assert . throws ( ( ) => p1 . with ( { line : - 1 } ) )
118
- assert . throws ( ( ) => p1 . with ( { character : - 1 } ) )
99
+ const position1 = new Position ( 1 , 3 )
100
+
101
+ assert ( position1 . with ( ) === position1 )
102
+ assert ( position1 . with ( 1 ) === position1 )
103
+ assert ( position1 . with ( undefined , 3 ) === position1 )
104
+ assert ( position1 . with ( 1 , 3 ) === position1 )
105
+ assert ( position1 . with ( undefined ) === position1 )
106
+ assert ( position1 . with ( { line : 1 } ) === position1 )
107
+ assert ( position1 . with ( { character : 3 } ) === position1 )
108
+ assert ( position1 . with ( { line : 1 , character : 3 } ) === position1 )
109
+
110
+ const position2 = position1 . with ( { line : 0 , character : 11 } )
111
+ assert . strictEqual ( position2 . line , 0 )
112
+ assert . strictEqual ( position2 . character , 11 )
113
+
114
+ assert . throws ( ( ) => position1 . with ( null as any ) )
115
+ assert . throws ( ( ) => position1 . with ( - 9 ) )
116
+ assert . throws ( ( ) => position1 . with ( 0 , - 9 ) )
117
+ assert . throws ( ( ) => position1 . with ( { line : - 1 } ) )
118
+ assert . throws ( ( ) => position1 . with ( { character : - 1 } ) )
119
119
} )
120
120
} )
0 commit comments