11import {
22 jitSuite ,
3+ parseErrorFor ,
34 preprocess ,
45 RenderTest ,
5- syntaxErrorFor ,
66 test ,
77} from '@glimmer-workspace/integration-tests' ;
88
@@ -17,12 +17,13 @@ class CompileErrorTests extends RenderTest {
1717 meta : { moduleName : 'test-module' } ,
1818 } ) ;
1919 } ,
20- syntaxErrorFor (
20+ parseErrorFor (
2121 'Unclosed element `div`' ,
22- '<div class="my-div" \n foo={{bar}}>' ,
22+ '\n <div class="my-div" \n foo={{bar}}>\n<span>\n</span>\n ' ,
2323 'test-module' ,
2424 2 ,
25- 0
25+ 0 ,
26+ 20
2627 )
2728 ) ;
2829
@@ -32,7 +33,14 @@ class CompileErrorTests extends RenderTest {
3233 meta : { moduleName : 'test-module' } ,
3334 } ) ;
3435 } ,
35- syntaxErrorFor ( 'Unclosed element `span`' , '<span>' , 'test-module' , 3 , 0 )
36+ parseErrorFor (
37+ 'Unclosed element `span`' ,
38+ '\n<div class="my-div">\n<span>\n' ,
39+ 'test-module' ,
40+ 3 ,
41+ 0 ,
42+ 6
43+ )
3644 ) ;
3745 }
3846
@@ -42,7 +50,7 @@ class CompileErrorTests extends RenderTest {
4250 ( ) => {
4351 preprocess ( '</p>' , { meta : { moduleName : 'test-module' } } ) ;
4452 } ,
45- syntaxErrorFor ( 'Closing tag </p> without an open tag' , '</p>' , 'test-module' , 1 , 0 )
53+ parseErrorFor ( 'Closing tag </p> without an open tag' , '</p>' , 'test-module' , 1 , 0 , 4 )
4654 ) ;
4755
4856 this . assert . throws (
@@ -51,7 +59,14 @@ class CompileErrorTests extends RenderTest {
5159 meta : { moduleName : 'test-module' } ,
5260 } ) ;
5361 } ,
54- syntaxErrorFor ( 'Closing tag </div> without an open tag' , '</div>' , 'test-module' , 3 , 0 )
62+ parseErrorFor (
63+ 'Closing tag </div> without an open tag' ,
64+ '<em>{{ foo }}</em> \n {{ bar }}\n</div>' ,
65+ 'test-module' ,
66+ 3 ,
67+ 0 ,
68+ 6
69+ )
5570 ) ;
5671 }
5772
@@ -61,38 +76,41 @@ class CompileErrorTests extends RenderTest {
6176 ( ) => {
6277 preprocess ( '<input></input>' , { meta : { moduleName : 'test-module' } } ) ;
6378 } ,
64- syntaxErrorFor (
79+ parseErrorFor (
6580 '<input> elements do not need end tags. You should remove it' ,
66- '</input>' ,
81+ '<input>< /input>' ,
6782 'test-module' ,
6883 1 ,
69- 7
84+ 7 ,
85+ 1
7086 )
7187 ) ;
7288
7389 this . assert . throws (
7490 ( ) => {
7591 preprocess ( '<div>\n <input></input>\n</div>' , { meta : { moduleName : 'test-module' } } ) ;
7692 } ,
77- syntaxErrorFor (
93+ parseErrorFor (
7894 '<input> elements do not need end tags. You should remove it' ,
79- '</input>' ,
95+ '<div>\n <input>< /input>\n</div >' ,
8096 'test-module' ,
8197 2 ,
82- 9
98+ 9 ,
99+ 1
83100 )
84101 ) ;
85102
86103 this . assert . throws (
87104 ( ) => {
88105 preprocess ( '\n\n</br>' , { meta : { moduleName : 'test-module' } } ) ;
89106 } ,
90- syntaxErrorFor (
107+ parseErrorFor (
91108 '<br> elements do not need end tags. You should remove it' ,
92- '</br>' ,
109+ '\n\n </br>' ,
93110 'test-module' ,
94111 3 ,
95- 0
112+ 0 ,
113+ 5
96114 )
97115 ) ;
98116 }
@@ -103,12 +121,13 @@ class CompileErrorTests extends RenderTest {
103121 ( ) => {
104122 preprocess ( '<div>\nSomething\n\n</div foo="bar">' , { meta : { moduleName : 'test-module' } } ) ;
105123 } ,
106- syntaxErrorFor (
124+ parseErrorFor (
107125 'Invalid end tag: closing tag must not have attributes' ,
108- '</div foo="bar"' ,
126+ '<div>\nSomething\n\n< /div foo="bar"> ' ,
109127 'test-module' ,
110128 4 ,
111- 0
129+ 0 ,
130+ 15
112131 )
113132 ) ;
114133 }
@@ -119,12 +138,13 @@ class CompileErrorTests extends RenderTest {
119138 ( ) => {
120139 preprocess ( '<div>\n<p>\nSomething\n\n</div>' , { meta : { moduleName : 'test-module' } } ) ;
121140 } ,
122- syntaxErrorFor (
141+ parseErrorFor (
123142 'Closing tag </div> did not match last open tag <p> (on line 2)' ,
124- '</div>' ,
143+ '<div>\n<p>\nSomething\n\n< /div>' ,
125144 'test-module' ,
126145 5 ,
127- 0
146+ 0 ,
147+ 6
128148 )
129149 ) ;
130150 }
@@ -137,12 +157,13 @@ class CompileErrorTests extends RenderTest {
137157 meta : { moduleName : 'test-module' } ,
138158 } ) ;
139159 } ,
140- syntaxErrorFor (
160+ parseErrorFor (
141161 'Closing tag </div> did not match last open tag <p> (on line 2)' ,
142- '</div>' ,
162+ '<div>\n<p>\n{{! some comment}}\n\n< /div>' ,
143163 'test-module' ,
144164 5 ,
145- 0
165+ 0 ,
166+ 6
146167 )
147168 ) ;
148169 }
@@ -153,12 +174,13 @@ class CompileErrorTests extends RenderTest {
153174 ( ) => {
154175 preprocess ( '<div>\n<p>\n{{someProp}}\n\n</div>' , { meta : { moduleName : 'test-module' } } ) ;
155176 } ,
156- syntaxErrorFor (
177+ parseErrorFor (
157178 'Closing tag </div> did not match last open tag <p> (on line 2)' ,
158- '</div>' ,
179+ '<div>\n<p>\n{{someProp}}\n\n< /div>' ,
159180 'test-module' ,
160181 5 ,
161- 0
182+ 0 ,
183+ 6
162184 )
163185 ) ;
164186 }
@@ -171,12 +193,13 @@ class CompileErrorTests extends RenderTest {
171193 meta : { moduleName : 'test-module' } ,
172194 } ) ;
173195 } ,
174- syntaxErrorFor (
196+ parseErrorFor (
175197 'Closing tag </div> did not match last open tag <p> (on line 2)' ,
176- '</div>' ,
198+ '<div>\n<p>\n{{#some-comment}}\n{{/some-comment}}\n< /div>' ,
177199 'test-module' ,
178200 5 ,
179- 0
201+ 0 ,
202+ 6
180203 )
181204 ) ;
182205 }
@@ -189,12 +212,13 @@ class CompileErrorTests extends RenderTest {
189212 meta : { moduleName : 'test-module' } ,
190213 } ) ;
191214 } ,
192- syntaxErrorFor (
215+ parseErrorFor (
193216 'Closing tag </div> did not match last open tag <p> (on line 2)' ,
194- '</div>' ,
217+ '<div>\n<p>\n{{someProp~}}\n\n< /div>{{some-comment}} ' ,
195218 'test-module' ,
196219 5 ,
197- 0
220+ 0 ,
221+ 6
198222 )
199223 ) ;
200224 }
@@ -207,12 +231,13 @@ class CompileErrorTests extends RenderTest {
207231 meta : { moduleName : 'test-module' } ,
208232 } ) ;
209233 } ,
210- syntaxErrorFor (
234+ parseErrorFor (
211235 'Closing tag </div> did not match last open tag <p> (on line 2)' ,
212- '</div>' ,
236+ '<div>\n<p>\n{{some-comment}}< /div>{{some-comment}} ' ,
213237 'test-module' ,
214238 3 ,
215- 16
239+ 16 ,
240+ 1
216241 )
217242 ) ;
218243 }
@@ -221,31 +246,32 @@ class CompileErrorTests extends RenderTest {
221246 'Unquoted attribute with expression throws an exception' ( ) {
222247 this . assert . throws (
223248 ( ) => preprocess ( '<img class=foo{{bar}}>' , { meta : { moduleName : 'test-module' } } ) ,
224- expectedError ( 'class=foo{{bar}}' , 1 , 5 )
249+ expectedError ( '<img class=foo{{bar}}> ' , 1 , 5 , 1 )
225250 ) ;
226251 this . assert . throws (
227252 ( ) => preprocess ( '<img class={{foo}}{{bar}}>' , { meta : { moduleName : 'test-module' } } ) ,
228- expectedError ( 'class={{foo}}{{bar}}' , 1 , 5 )
253+ expectedError ( '<img class={{foo}}{{bar}}> ' , 1 , 5 , 1 )
229254 ) ;
230255 this . assert . throws (
231256 ( ) => preprocess ( '<img \nclass={{foo}}bar>' , { meta : { moduleName : 'test-module' } } ) ,
232- expectedError ( 'class ={{foo}}bar' , 2 , 0 )
257+ expectedError ( '<img \nclass ={{foo}}bar> ' , 2 , 0 , 16 )
233258 ) ;
234259 this . assert . throws (
235260 ( ) =>
236261 preprocess ( '<div \nclass\n=\n{{foo}}&bar ></div>' , {
237262 meta : { moduleName : 'test-module' } ,
238263 } ) ,
239- expectedError ( 'class\ n=\n{{foo}}&bar' , 2 , 0 )
264+ expectedError ( '<div \nclass\ n=\n{{foo}}&bar ></div> ' , 2 , 0 , 5 )
240265 ) ;
241266
242- function expectedError ( code : string , line : number , column : number ) {
243- return syntaxErrorFor (
267+ function expectedError ( source : string , line : number , column : number , spanLength : number ) {
268+ return parseErrorFor (
244269 `An unquoted attribute value must be a string or a mustache, preceded by whitespace or a '=' character, and followed by whitespace, a '>' character, or '/>'` ,
245- code ,
270+ source ,
246271 'test-module' ,
247272 line ,
248- column
273+ column ,
274+ spanLength
249275 ) ;
250276 }
251277 }
0 commit comments