@@ -51,18 +51,34 @@ class SyntaxErrors extends RenderTest {
51
51
) ;
52
52
}
53
53
54
+ @test
55
+ 'Block params in HTML syntax - requires a space between as and pipes' ( ) {
56
+ this . assert . throws (
57
+ ( ) => {
58
+ preprocess ( '<x-bar as|foo|>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
59
+ } ,
60
+ syntaxErrorFor (
61
+ 'Invalid block parameters syntax: expecting at least one space character between "as" and "|"' ,
62
+ 'as|' ,
63
+ 'test-module' ,
64
+ 1 ,
65
+ 7
66
+ )
67
+ ) ;
68
+ }
69
+
54
70
@test
55
71
'Block params in HTML syntax - Throws exception if given zero parameters' ( ) {
56
72
this . assert . throws (
57
73
( ) => {
58
74
preprocess ( '<x-bar as ||>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
59
75
} ,
60
76
syntaxErrorFor (
61
- 'Cannot use zero block parameters' ,
62
- '<x-bar as ||>foo</x-bar> ' ,
77
+ 'Invalid block parameters syntax: empty parameters list, expecting at least one identifier ' ,
78
+ 'as ||' ,
63
79
'test-module' ,
64
80
1 ,
65
- 0
81
+ 7
66
82
)
67
83
) ;
68
84
@@ -71,11 +87,108 @@ class SyntaxErrors extends RenderTest {
71
87
preprocess ( '<x-bar as | |>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
72
88
} ,
73
89
syntaxErrorFor (
74
- 'Cannot use zero block parameters' ,
75
- '<x-bar as | |>foo</x-bar> ' ,
90
+ 'Invalid block parameters syntax: empty parameters list, expecting at least one identifier ' ,
91
+ 'as | |' ,
76
92
'test-module' ,
77
93
1 ,
78
- 0
94
+ 7
95
+ )
96
+ ) ;
97
+ }
98
+
99
+ @test
100
+ 'Block params in HTML syntax - invalid mustaches in block params list' ( ) {
101
+ this . assert . throws (
102
+ ( ) => {
103
+ preprocess ( '<x-bar as |{{foo}}|>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
104
+ } ,
105
+ syntaxErrorFor (
106
+ 'Invalid block parameters syntax: mustaches cannot be used inside parameters list' ,
107
+ '{{foo}}' ,
108
+ 'test-module' ,
109
+ 1 ,
110
+ 11
111
+ )
112
+ ) ;
113
+
114
+ this . assert . throws (
115
+ ( ) => {
116
+ preprocess ( '<x-bar as |foo{{bar}}|>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
117
+ } ,
118
+ syntaxErrorFor (
119
+ 'Invalid block parameters syntax: mustaches cannot be used inside parameters list' ,
120
+ '{{bar}}' ,
121
+ 'test-module' ,
122
+ 1 ,
123
+ 14
124
+ )
125
+ ) ;
126
+
127
+ this . assert . throws (
128
+ ( ) => {
129
+ preprocess ( '<x-bar as |foo {{bar}}|>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
130
+ } ,
131
+ syntaxErrorFor (
132
+ 'Invalid block parameters syntax: mustaches cannot be used inside parameters list' ,
133
+ '{{bar}}' ,
134
+ 'test-module' ,
135
+ 1 ,
136
+ 15
137
+ )
138
+ ) ;
139
+
140
+ this . assert . throws (
141
+ ( ) => {
142
+ preprocess ( '<x-bar as |foo| {{bar}}>foo</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
143
+ } ,
144
+ syntaxErrorFor (
145
+ 'Invalid block parameters syntax: modifiers cannot follow parameters list' ,
146
+ '{{bar}}' ,
147
+ 'test-module' ,
148
+ 1 ,
149
+ 16
150
+ )
151
+ ) ;
152
+ }
153
+
154
+ @test
155
+ 'Block params in HTML syntax - EOF in block params list' ( ) {
156
+ this . assert . throws (
157
+ ( ) => {
158
+ preprocess ( '<x-bar as |' , { meta : { moduleName : 'test-module' } } ) ;
159
+ } ,
160
+ syntaxErrorFor (
161
+ 'Invalid block parameters syntax: expecting the tag to be closed with ">" or "/>" after parameters list' ,
162
+ 'as |' ,
163
+ 'test-module' ,
164
+ 1 ,
165
+ 7
166
+ )
167
+ ) ;
168
+
169
+ this . assert . throws (
170
+ ( ) => {
171
+ preprocess ( '<x-bar as |foo' , { meta : { moduleName : 'test-module' } } ) ;
172
+ } ,
173
+ syntaxErrorFor (
174
+ 'Invalid block parameters syntax: expecting the tag to be closed with ">" or "/>" after parameters list' ,
175
+ 'as |foo' ,
176
+ 'test-module' ,
177
+ 1 ,
178
+ 7
179
+ )
180
+ ) ;
181
+
182
+ this . assert . throws (
183
+ ( ) => {
184
+ preprocess ( '<x-bar as |foo|' , { meta : { moduleName : 'test-module' } } ) ;
185
+ } ,
186
+ syntaxErrorFor (
187
+ 'Invalid block parameters syntax: expecting the tag to be closed with ">" or "/>" after parameters list' ,
188
+ 'as |foo|' ,
189
+ 'test-module' ,
190
+ 1 ,
191
+ 7
79
192
)
80
193
) ;
81
194
}
@@ -87,24 +200,26 @@ class SyntaxErrors extends RenderTest {
87
200
preprocess ( '<x-bar as |x y>{{x}},{{y}}</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
88
201
} ,
89
202
syntaxErrorFor (
90
- " Invalid block parameters syntax, 'as |x y'" ,
91
- '<x-bar as |x y>{{x}},{{y}}</x-bar >' ,
203
+ ' Invalid block parameters syntax: expecting "|" but the tag was closed prematurely' ,
204
+ 'as |x y>' ,
92
205
'test-module' ,
93
206
1 ,
94
- 0
207
+ 7
95
208
)
96
209
) ;
97
210
98
211
this . assert . throws (
99
212
( ) => {
100
- preprocess ( '<x-bar as |x| y>{{x}},{{y}}</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
213
+ preprocess ( '<x-bar as |x| wat>{{x}},{{y}}</x-bar>' , {
214
+ meta : { moduleName : 'test-module' } ,
215
+ } ) ;
101
216
} ,
102
217
syntaxErrorFor (
103
- " Invalid block parameters syntax, 'as |x| y'" ,
104
- '<x-bar as |x| y>{{x}},{{y}}</x-bar> ' ,
218
+ ' Invalid block parameters syntax: expecting the tag to be closed with ">" or "/>" after parameters list' ,
219
+ 'wat ' ,
105
220
'test-module' ,
106
221
1 ,
107
- 0
222
+ 14
108
223
)
109
224
) ;
110
225
@@ -113,11 +228,11 @@ class SyntaxErrors extends RenderTest {
113
228
preprocess ( '<x-bar as |x| y|>{{x}},{{y}}</x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
114
229
} ,
115
230
syntaxErrorFor (
116
- " Invalid block parameters syntax, 'as |x| y|'" ,
117
- '<x-bar as |x| y|>{{x}},{{y}}</x-bar> ' ,
231
+ ' Invalid block parameters syntax: expecting the tag to be closed with ">" or "/>" after parameters list' ,
232
+ 'y| ' ,
118
233
'test-module' ,
119
234
1 ,
120
- 0
235
+ 14
121
236
)
122
237
) ;
123
238
}
@@ -129,31 +244,37 @@ class SyntaxErrors extends RenderTest {
129
244
preprocess ( '<x-bar as |x foo.bar|></x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
130
245
} ,
131
246
syntaxErrorFor (
132
- " Invalid identifier for block parameters, ' foo.bar'" ,
133
- '<x-bar as |x foo.bar|></x-bar> ' ,
247
+ ' Invalid block parameters syntax: invalid identifier name ` foo.bar`' ,
248
+ 'foo.bar' ,
134
249
'test-module' ,
135
250
1 ,
136
- 0
251
+ 13
137
252
)
138
253
) ;
139
254
140
255
this . assert . throws (
141
256
( ) => {
142
257
preprocess ( '<x-bar as |x "foo"|></x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
143
258
} ,
144
- syntaxErrorFor ( '" is not a valid character within attribute names' , '' , 'test-module' , 1 , 17 )
259
+ syntaxErrorFor (
260
+ 'Invalid block parameters syntax: invalid identifier name `"foo"`' ,
261
+ '"foo"' ,
262
+ 'test-module' ,
263
+ 1 ,
264
+ 13
265
+ )
145
266
) ;
146
267
147
268
this . assert . throws (
148
269
( ) => {
149
270
preprocess ( '<x-bar as |foo[bar]|></x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
150
271
} ,
151
272
syntaxErrorFor (
152
- " Invalid identifier for block parameters, ' foo[bar]'" ,
153
- '<x-bar as | foo[bar]|></x-bar> ' ,
273
+ ' Invalid block parameters syntax: invalid identifier name ` foo[bar]`' ,
274
+ 'foo[bar]' ,
154
275
'test-module' ,
155
276
1 ,
156
- 0
277
+ 11
157
278
)
158
279
) ;
159
280
}
@@ -165,11 +286,11 @@ class SyntaxErrors extends RenderTest {
165
286
preprocess ( '<x-bar |x|></x-bar>' , { meta : { moduleName : 'test-module' } } ) ;
166
287
} ,
167
288
syntaxErrorFor (
168
- 'Block parameters must be preceded by the `as` keyword, detected block parameters without `as` ' ,
169
- '<x-bar |x|></x-bar> ' ,
289
+ 'Invalid block parameters syntax: block parameters must be preceded by the `as` keyword' ,
290
+ '|x|' ,
170
291
'test-module' ,
171
292
1 ,
172
- 0
293
+ 7
173
294
)
174
295
) ;
175
296
@@ -180,11 +301,11 @@ class SyntaxErrors extends RenderTest {
180
301
} ) ;
181
302
} ,
182
303
syntaxErrorFor (
183
- 'Block parameters must be preceded by the `as` keyword, detected block parameters without `as` ' ,
184
- '<:baz |x|></:baz> ' ,
304
+ 'Invalid block parameters syntax: block parameters must be preceded by the `as` keyword' ,
305
+ '|x|' ,
185
306
'test-module' ,
186
307
1 ,
187
- 7
308
+ 13
188
309
)
189
310
) ;
190
311
}
0 commit comments