@@ -17,8 +17,6 @@ const noPoints = {type: 'c', position: {}}
17
17
18
18
const noPosition = { type : 'd' }
19
19
20
- const generated = { line : null , column : null , offset : null }
21
-
22
20
test ( 'core' , ( ) => {
23
21
assert . deepEqual (
24
22
Object . keys ( mod ) . sort ( ) ,
@@ -34,28 +32,52 @@ test('position', () => {
34
32
'should get the whole position'
35
33
)
36
34
35
+ assert . deepEqual (
36
+ position ( {
37
+ type : 'x' ,
38
+ position : {
39
+ start : { line : 0 , column : 0 , offset : - 1 } ,
40
+ end : { line : 0 , column : 0 , offset : - 1 }
41
+ }
42
+ } ) ,
43
+ undefined ,
44
+ 'should not get too low values'
45
+ )
46
+
47
+ assert . deepEqual (
48
+ position ( {
49
+ type : 'x' ,
50
+ position : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 2 } }
51
+ } ) ,
52
+ {
53
+ start : { line : 1 , column : 1 , offset : undefined } ,
54
+ end : { line : 1 , column : 2 , offset : undefined }
55
+ } ,
56
+ 'should support points w/o `offset`'
57
+ )
58
+
37
59
assert . deepEqual (
38
60
position ( noFields ) ,
39
- { start : generated , end : generated } ,
40
- 'should return an empty position without fields'
61
+ undefined ,
62
+ 'should return nothing when without fields'
41
63
)
42
64
43
65
assert . deepEqual (
44
66
position ( noPoints ) ,
45
- { start : generated , end : generated } ,
46
- 'should return an empty position without points'
67
+ undefined ,
68
+ 'should return nothing when without points'
47
69
)
48
70
49
71
assert . deepEqual (
50
72
position ( noPosition ) ,
51
- { start : generated , end : generated } ,
52
- 'should return an empty position without position'
73
+ undefined ,
74
+ 'should return nothing when without position'
53
75
)
54
76
55
77
assert . deepEqual (
56
78
position ( ) ,
57
- { start : generated , end : generated } ,
58
- 'should return an empty position without node'
79
+ undefined ,
80
+ 'should return nothing when without node'
59
81
)
60
82
} )
61
83
@@ -66,28 +88,49 @@ test('pointStart', () => {
66
88
'should get a side'
67
89
)
68
90
91
+ assert . deepEqual (
92
+ pointStart ( {
93
+ type : 'x' ,
94
+ position : {
95
+ start : { line : 0 , column : 0 , offset : - 1 } ,
96
+ end : { line : 0 , column : 0 , offset : - 1 }
97
+ }
98
+ } ) ,
99
+ undefined ,
100
+ 'should not get too low values'
101
+ )
102
+
103
+ assert . deepEqual (
104
+ pointStart ( {
105
+ type : 'x' ,
106
+ position : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 2 } }
107
+ } ) ,
108
+ { line : 1 , column : 1 , offset : undefined } ,
109
+ 'should support points w/o `offset`'
110
+ )
111
+
69
112
assert . deepEqual (
70
113
pointStart ( noFields ) ,
71
- generated ,
72
- 'should return an empty point without fields'
114
+ undefined ,
115
+ 'should return nothing when without fields'
73
116
)
74
117
75
118
assert . deepEqual (
76
119
pointStart ( noPoints ) ,
77
- generated ,
78
- 'should return an empty point without points'
120
+ undefined ,
121
+ 'should return nothing when without points'
79
122
)
80
123
81
124
assert . deepEqual (
82
125
pointStart ( noPosition ) ,
83
- generated ,
84
- 'should return an empty point without position'
126
+ undefined ,
127
+ 'should return nothing when without position'
85
128
)
86
129
87
130
assert . deepEqual (
88
131
pointStart ( ) ,
89
- generated ,
90
- 'should return an empty point without node'
132
+ undefined ,
133
+ 'should return nothing when without node'
91
134
)
92
135
} )
93
136
@@ -98,27 +141,48 @@ test('pointEnd', () => {
98
141
'should get a side'
99
142
)
100
143
144
+ assert . deepEqual (
145
+ pointEnd ( {
146
+ type : 'x' ,
147
+ position : {
148
+ start : { line : 0 , column : 0 , offset : - 1 } ,
149
+ end : { line : 0 , column : 0 , offset : - 1 }
150
+ }
151
+ } ) ,
152
+ undefined ,
153
+ 'should not get too low values'
154
+ )
155
+
156
+ assert . deepEqual (
157
+ pointEnd ( {
158
+ type : 'x' ,
159
+ position : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 2 } }
160
+ } ) ,
161
+ { line : 1 , column : 2 , offset : undefined } ,
162
+ 'should support points w/o `offset`'
163
+ )
164
+
101
165
assert . deepEqual (
102
166
pointEnd ( noFields ) ,
103
- generated ,
104
- 'should return an empty point without fields'
167
+ undefined ,
168
+ 'should return nothing when without fields'
105
169
)
106
170
107
171
assert . deepEqual (
108
172
pointEnd ( noPoints ) ,
109
- generated ,
110
- 'should return an empty point without points'
173
+ undefined ,
174
+ 'should return nothing when without points'
111
175
)
112
176
113
177
assert . deepEqual (
114
178
pointEnd ( noPosition ) ,
115
- generated ,
116
- 'should return an empty point without position'
179
+ undefined ,
180
+ 'should return nothing when without position'
117
181
)
118
182
119
183
assert . deepEqual (
120
184
pointEnd ( ) ,
121
- generated ,
122
- 'should return an empty point without node'
185
+ undefined ,
186
+ 'should return nothing when without node'
123
187
)
124
188
} )
0 commit comments