Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* If you wish your version of this file to be governed by only the CDDL |
28 |
* or only the GPL Version 2, indicate your decision by adding |
29 |
* "[Contributor] elects to include this software in this distribution |
30 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
31 |
* single choice of license, a recipient has the option to distribute |
32 |
* your version of this file under either the CDDL, the GPL Version 2 or |
33 |
* to extend the choice of license to its licensees as provided above. |
34 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
35 |
* Version 2 license, then the option applies only if the new code is |
36 |
* made subject to such option by the copyright holder. |
37 |
* |
38 |
* Contributor(s): |
39 |
*/ |
40 |
package org.netbeans.modules.php.twig.editor.typinghooks; |
41 |
|
42 |
public class TwigTypedTextInterceptorTest extends TwigTypinghooksTestBase { |
43 |
|
44 |
public TwigTypedTextInterceptorTest(String testName) { |
45 |
super(testName); |
46 |
} |
47 |
|
48 |
private void insertChar(String original, char insertText, String expected) throws Exception { |
49 |
insertChar(original, insertText, expected, null); |
50 |
} |
51 |
|
52 |
private void insertChar(String original, char insertText, String expected, String selection) throws Exception { |
53 |
insertChar(original, insertText, expected, selection, false); |
54 |
} |
55 |
|
56 |
// surround with quotes or brackets |
57 |
public void testSurroundWithDoubleQuoteInBlock_01() throws Exception { |
58 |
String original = "{% test^ %}"; |
59 |
String expected = "{% \"test\"^ %}"; |
60 |
insertChar(original, '"', expected, "test"); |
61 |
} |
62 |
|
63 |
public void testSurroundWithDoubleQuoteInBlock_02() throws Exception { |
64 |
String original = "{% test^ %}"; |
65 |
String expected = "{% te\"st\"^ %}"; |
66 |
insertChar(original, '"', expected, "st"); |
67 |
} |
68 |
|
69 |
public void testSurroundWithDoubleQuoteInBlock_03() throws Exception { |
70 |
String original = "{% 'test'^ %}"; |
71 |
String expected = "{% \"test\"^ %}"; |
72 |
insertChar(original, '"', expected, "'test'"); |
73 |
} |
74 |
|
75 |
public void testSurroundWithSingleQuoteInBlock_01() throws Exception { |
76 |
String original = "{% test^ %}"; |
77 |
String expected = "{% 'test'^ %}"; |
78 |
insertChar(original, '\'', expected, "test"); |
79 |
} |
80 |
|
81 |
public void testSurroundWithSingleQuoteInBlock_02() throws Exception { |
82 |
String original = "{% test^ %}"; |
83 |
String expected = "{% te'st'^ %}"; |
84 |
insertChar(original, '\'', expected, "st"); |
85 |
} |
86 |
|
87 |
public void testSurroundWithSingleQuoteInBlock_03() throws Exception { |
88 |
String original = "{% \"test\"^ %}"; |
89 |
String expected = "{% 'test'^ %}"; |
90 |
insertChar(original, '\'', expected, "\"test\""); |
91 |
} |
92 |
|
93 |
public void testSurroundWithCurlyInBlock_01() throws Exception { |
94 |
String original = "{% test^ %}"; |
95 |
String expected = "{% {test}^ %}"; |
96 |
insertChar(original, '{', expected, "test"); |
97 |
} |
98 |
|
99 |
public void testSurroundWithCurlyInBlock_02() throws Exception { |
100 |
String original = "{% test^ %}"; |
101 |
String expected = "{% te{st}^ %}"; |
102 |
insertChar(original, '{', expected, "st"); |
103 |
} |
104 |
|
105 |
public void testSurroundWithCurlyInBlock_03() throws Exception { |
106 |
String original = "{% \"test\"^ %}"; |
107 |
String expected = "{% {test}^ %}"; |
108 |
insertChar(original, '{', expected, "\"test\""); |
109 |
} |
110 |
|
111 |
public void testSurroundWithParenthesisInBlock_01() throws Exception { |
112 |
String original = "{% test^ %}"; |
113 |
String expected = "{% (test)^ %}"; |
114 |
insertChar(original, '(', expected, "test"); |
115 |
} |
116 |
|
117 |
public void testSurroundWithParenthesisInBlock_02() throws Exception { |
118 |
String original = "{% test^ %}"; |
119 |
String expected = "{% te(st)^ %}"; |
120 |
insertChar(original, '(', expected, "st"); |
121 |
} |
122 |
|
123 |
public void testSurroundWithParenthesisInBlock_03() throws Exception { |
124 |
String original = "{% \"test\"^ %}"; |
125 |
String expected = "{% (test)^ %}"; |
126 |
insertChar(original, '(', expected, "\"test\""); |
127 |
} |
128 |
|
129 |
public void testSurroundWithBracketInBlock_01() throws Exception { |
130 |
String original = "{% test^ %}"; |
131 |
String expected = "{% [test]^ %}"; |
132 |
insertChar(original, '[', expected, "test"); |
133 |
} |
134 |
|
135 |
public void testSurroundWithBracketInBlock_02() throws Exception { |
136 |
String original = "{% tes^t %}"; |
137 |
String expected = "{% t[es]^t %}"; |
138 |
insertChar(original, '[', expected, "es"); |
139 |
} |
140 |
|
141 |
public void testSurroundWithBracketInBlock_03() throws Exception { |
142 |
String original = "{% \"test\"^ %}"; |
143 |
String expected = "{% [test]^ %}"; |
144 |
insertChar(original, '[', expected, "\"test\""); |
145 |
} |
146 |
|
147 |
// complete quotes and brackets |
148 |
public void testInsertDoubleQuoteInBlock_01() throws Exception { |
149 |
String original = "{% ^ %}"; |
150 |
String expected = "{% \"^\" %}"; |
151 |
insertChar(original, '"', expected); |
152 |
} |
153 |
|
154 |
public void testInsertDoubleQuoteInBlock_02() throws Exception { |
155 |
String original = "{% \"^ %}"; |
156 |
String expected = "{% \"\"^ %}"; |
157 |
insertChar(original, '"', expected); |
158 |
} |
159 |
|
160 |
public void testInsertDoubleQuoteInBlock_03() throws Exception { |
161 |
String original = "{% ^\" %}"; |
162 |
String expected = "{% \"^\" %}"; |
163 |
insertChar(original, '"', expected); |
164 |
} |
165 |
|
166 |
public void testInsertDoubleQuoteInBlock_04() throws Exception { |
167 |
String original = "{% \"test^ %}"; |
168 |
String expected = "{% \"test\"^ %}"; |
169 |
insertChar(original, '"', expected); |
170 |
} |
171 |
|
172 |
public void testInsertDoubleQuoteInBlock_05() throws Exception { |
173 |
String original = "{% ^test\" %}"; |
174 |
String expected = "{% \"^test\" %}"; |
175 |
insertChar(original, '"', expected); |
176 |
} |
177 |
|
178 |
public void testInsertDoubleQuoteInBlock_06() throws Exception { |
179 |
String original = "{% \"test\" %}^"; |
180 |
String expected = "{% \"test\" %}\"^"; |
181 |
insertChar(original, '"', expected); |
182 |
} |
183 |
|
184 |
public void testInsertDoubleQuoteInBlock_07() throws Exception { |
185 |
String original = "{%^%}"; |
186 |
String expected = "{%\"^\"%}"; |
187 |
insertChar(original, '"', expected); |
188 |
} |
189 |
|
190 |
public void testInsertSingleQuoteInBlock_01() throws Exception { |
191 |
String original = "{% ^ %}"; |
192 |
String expected = "{% '^' %}"; |
193 |
insertChar(original, '\'', expected); |
194 |
} |
195 |
|
196 |
public void testInsertSingleQuoteInBlock_02() throws Exception { |
197 |
String original = "{% '^ %}"; |
198 |
String expected = "{% ''^ %}"; |
199 |
insertChar(original, '\'', expected); |
200 |
} |
201 |
|
202 |
public void testInsertSingleQuoteInBlock_03() throws Exception { |
203 |
String original = "{% ^' %}"; |
204 |
String expected = "{% '^' %}"; |
205 |
insertChar(original, '\'', expected); |
206 |
} |
207 |
|
208 |
public void testInsertSingleQuoteInBlock_04() throws Exception { |
209 |
String original = "{% 'test^ %}"; |
210 |
String expected = "{% 'test'^ %}"; |
211 |
insertChar(original, '\'', expected); |
212 |
} |
213 |
|
214 |
public void testInsertSingleQuoteInBlock_05() throws Exception { |
215 |
String original = "{% ^test' %}"; |
216 |
String expected = "{% '^test' %}"; |
217 |
insertChar(original, '\'', expected); |
218 |
} |
219 |
|
220 |
public void testInsertSingleQuoteInBlock_06() throws Exception { |
221 |
String original = "{% 'test' %}^"; |
222 |
String expected = "{% 'test' %}'^"; |
223 |
insertChar(original, '\'', expected); |
224 |
} |
225 |
|
226 |
public void testInsertSingleQuoteInBlock_07() throws Exception { |
227 |
String original = "{%^%}"; |
228 |
String expected = "{%'^'%}"; |
229 |
insertChar(original, '\'', expected); |
230 |
} |
231 |
|
232 |
public void testInsertCurlyInBlock_01() throws Exception { |
233 |
String original = "{% ^ %}"; |
234 |
String expected = "{% {^} %}"; |
235 |
insertChar(original, '{', expected); |
236 |
} |
237 |
|
238 |
public void testInsertCurlyInBlock_02() throws Exception { |
239 |
String original = "{%^%}"; |
240 |
String expected = "{%{^}%}"; |
241 |
insertChar(original, '{', expected); |
242 |
} |
243 |
|
244 |
public void testInsertParenthesisInBlock_01() throws Exception { |
245 |
String original = "{% ^ %}"; |
246 |
String expected = "{% (^) %}"; |
247 |
insertChar(original, '(', expected); |
248 |
} |
249 |
|
250 |
public void testInsertParenthesisInBlock_02() throws Exception { |
251 |
String original = "{%^%}"; |
252 |
String expected = "{%(^)%}"; |
253 |
insertChar(original, '(', expected); |
254 |
} |
255 |
|
256 |
public void testInsertBracketInBlock_01() throws Exception { |
257 |
String original = "{% ^ %}"; |
258 |
String expected = "{% [^] %}"; |
259 |
insertChar(original, '[', expected); |
260 |
} |
261 |
|
262 |
public void testInsertBracketInBlock_02() throws Exception { |
263 |
String original = "{%^%}"; |
264 |
String expected = "{%[^]%}"; |
265 |
insertChar(original, '[', expected); |
266 |
} |
267 |
|
268 |
// skip closing bracket |
269 |
public void testSkipClosingCurlyInBlock_01() throws Exception { |
270 |
String original = "{% {^} %}"; |
271 |
String expected = "{% {}^ %}"; |
272 |
insertChar(original, '}', expected); |
273 |
} |
274 |
|
275 |
public void testSkipClosingCurlyInBlock_02() throws Exception { |
276 |
String original = "{% {'foo' : {^}} %}"; |
277 |
String expected = "{% {'foo' : {}^} %}"; |
278 |
insertChar(original, '}', expected); |
279 |
} |
280 |
|
281 |
public void testSkipClosingCurlyInBlock_03() throws Exception { |
282 |
String original = "{% {'foo' : {^}} { %}"; |
283 |
String expected = "{% {'foo' : {}^} { %}"; |
284 |
insertChar(original, '}', expected); |
285 |
} |
286 |
|
287 |
public void testSkipClosingParenthesisInBlock_01() throws Exception { |
288 |
String original = "{% (^) %}"; |
289 |
String expected = "{% ()^ %}"; |
290 |
insertChar(original, ')', expected); |
291 |
} |
292 |
|
293 |
public void testSkipClosingParenthesisInBlock_02() throws Exception { |
294 |
String original = "{% ((^)) %}"; |
295 |
String expected = "{% (()^) %}"; |
296 |
insertChar(original, ')', expected); |
297 |
} |
298 |
|
299 |
public void testSkipClosingParenthesisInBlock_03() throws Exception { |
300 |
String original = "{% ((^)) ( %}"; |
301 |
String expected = "{% (()^) ( %}"; |
302 |
insertChar(original, ')', expected); |
303 |
} |
304 |
|
305 |
public void testSkipClosingBracketInBlock_01() throws Exception { |
306 |
String original = "{% [^] %}"; |
307 |
String expected = "{% []^ %}"; |
308 |
insertChar(original, ']', expected); |
309 |
} |
310 |
|
311 |
public void testSkipClosingBracketInBlock_02() throws Exception { |
312 |
String original = "{% [[^]] %}"; |
313 |
String expected = "{% [[]^] %}"; |
314 |
insertChar(original, ']', expected); |
315 |
} |
316 |
|
317 |
public void testSkipClosingBracketInBlock_03() throws Exception { |
318 |
String original = "{% [[(^]] [ %}"; |
319 |
String expected = "{% [[(]^] [ %}"; |
320 |
insertChar(original, ']', expected); |
321 |
} |
322 |
|
323 |
// missing closing bracket |
324 |
public void testMissingClosingCurlyInBlock_01() throws Exception { |
325 |
String original = "{% {'foo' : {^} %}"; |
326 |
String expected = "{% {'foo' : {}^} %}"; |
327 |
insertChar(original, '}', expected); |
328 |
} |
329 |
|
330 |
public void testMissingClosingCurlyInBlock_02() throws Exception { |
331 |
String original = "{% {'foo' : {}^ %}"; |
332 |
String expected = "{% {'foo' : {}}^ %}"; |
333 |
insertChar(original, '}', expected); |
334 |
} |
335 |
|
336 |
public void testMissingClosingCurlyInBlock_03() throws Exception { |
337 |
String original = "{% {'foo' : {}^ { %}"; |
338 |
String expected = "{% {'foo' : {}}^ { %}"; |
339 |
insertChar(original, '}', expected); |
340 |
} |
341 |
|
342 |
public void testMissingClosingParenthesisInBlock_01() throws Exception { |
343 |
String original = "{% ((^) %}"; |
344 |
String expected = "{% (()^) %}"; |
345 |
insertChar(original, ')', expected); |
346 |
} |
347 |
|
348 |
public void testMissingClosingParenthesisInBlock_02() throws Exception { |
349 |
String original = "{% (()^ %}"; |
350 |
String expected = "{% (())^ %}"; |
351 |
insertChar(original, ')', expected); |
352 |
} |
353 |
|
354 |
public void testMissingClosingParenthesisInBlock_03() throws Exception { |
355 |
String original = "{% (()^ () %}"; |
356 |
String expected = "{% (())^ () %}"; |
357 |
insertChar(original, ')', expected); |
358 |
} |
359 |
|
360 |
public void testMissingClosingBracketInBlock_01() throws Exception { |
361 |
String original = "{% [[^] %}"; |
362 |
String expected = "{% [[]^] %}"; |
363 |
insertChar(original, ']', expected); |
364 |
} |
365 |
|
366 |
public void testMissingClosingBracketInBlock_02() throws Exception { |
367 |
String original = "{% [[]^ %}"; |
368 |
String expected = "{% [[]]^ %}"; |
369 |
insertChar(original, ']', expected); |
370 |
} |
371 |
|
372 |
public void testMissingClosingBracketInBlock_03() throws Exception { |
373 |
String original = "{% [[]^ [] %}"; |
374 |
String expected = "{% [[]]^ [] %}"; |
375 |
insertChar(original, ']', expected); |
376 |
} |
377 |
|
378 |
// Variable |
379 |
// surround with quotes or brackets |
380 |
public void testSurroundWithDoubleQuoteInVariable_01() throws Exception { |
381 |
String original = "{{ test^ }}"; |
382 |
String expected = "{{ \"test\"^ }}"; |
383 |
insertChar(original, '"', expected, "test"); |
384 |
} |
385 |
|
386 |
public void testSurroundWithDoubleQuoteInVariable_02() throws Exception { |
387 |
String original = "{{ test^ }}"; |
388 |
String expected = "{{ te\"st\"^ }}"; |
389 |
insertChar(original, '"', expected, "st"); |
390 |
} |
391 |
|
392 |
public void testSurroundWithDoubleQuoteInVariable_03() throws Exception { |
393 |
String original = "{{ 'test'^ }}"; |
394 |
String expected = "{{ \"test\"^ }}"; |
395 |
insertChar(original, '"', expected, "'test'"); |
396 |
} |
397 |
|
398 |
public void testSurroundWithSingleQuoteInVariable_01() throws Exception { |
399 |
String original = "{{ test^ }}"; |
400 |
String expected = "{{ 'test'^ }}"; |
401 |
insertChar(original, '\'', expected, "test"); |
402 |
} |
403 |
|
404 |
public void testSurroundWithSingleQuoteInVariable_02() throws Exception { |
405 |
String original = "{{ test^ }}"; |
406 |
String expected = "{{ te'st'^ }}"; |
407 |
insertChar(original, '\'', expected, "st"); |
408 |
} |
409 |
|
410 |
public void testSurroundWithSingleQuoteInVariable_03() throws Exception { |
411 |
String original = "{{ \"test\"^ }}"; |
412 |
String expected = "{{ 'test'^ }}"; |
413 |
insertChar(original, '\'', expected, "\"test\""); |
414 |
} |
415 |
|
416 |
public void testSurroundWithCurlyInVariable_01() throws Exception { |
417 |
String original = "{{ test^ }}"; |
418 |
String expected = "{{ {test}^ }}"; |
419 |
insertChar(original, '{', expected, "test"); |
420 |
} |
421 |
|
422 |
public void testSurroundWithCurlyInVariable_02() throws Exception { |
423 |
String original = "{{ test^ }}"; |
424 |
String expected = "{{ te{st}^ }}"; |
425 |
insertChar(original, '{', expected, "st"); |
426 |
} |
427 |
|
428 |
public void testSurroundWithCurlyInVariable_03() throws Exception { |
429 |
String original = "{{ \"test\"^ }}"; |
430 |
String expected = "{{ {test}^ }}"; |
431 |
insertChar(original, '{', expected, "\"test\""); |
432 |
} |
433 |
|
434 |
public void testSurroundWithParenthesisInVariable_01() throws Exception { |
435 |
String original = "{{ test^ }}"; |
436 |
String expected = "{{ (test)^ }}"; |
437 |
insertChar(original, '(', expected, "test"); |
438 |
} |
439 |
|
440 |
public void testSurroundWithParenthesisInVariable_02() throws Exception { |
441 |
String original = "{{ test^ }}"; |
442 |
String expected = "{{ te(st)^ }}"; |
443 |
insertChar(original, '(', expected, "st"); |
444 |
} |
445 |
|
446 |
public void testSurroundWithParenthesisInVariable_03() throws Exception { |
447 |
String original = "{{ \"test\"^ }}"; |
448 |
String expected = "{{ (test)^ }}"; |
449 |
insertChar(original, '(', expected, "\"test\""); |
450 |
} |
451 |
|
452 |
public void testSurroundWithBracketInVariable_01() throws Exception { |
453 |
String original = "{{ test^ }}"; |
454 |
String expected = "{{ [test]^ }}"; |
455 |
insertChar(original, '[', expected, "test"); |
456 |
} |
457 |
|
458 |
public void testSurroundWithBracketInVariable_02() throws Exception { |
459 |
String original = "{{ tes^t }}"; |
460 |
String expected = "{{ t[es]^t }}"; |
461 |
insertChar(original, '[', expected, "es"); |
462 |
} |
463 |
|
464 |
public void testSurroundWithBracketInVariable_03() throws Exception { |
465 |
String original = "{{ \"test\"^ }}"; |
466 |
String expected = "{{ [test]^ }}"; |
467 |
insertChar(original, '[', expected, "\"test\""); |
468 |
} |
469 |
|
470 |
// complete quotes and brackets |
471 |
public void testInsertDoubleQuoteInVariable_01() throws Exception { |
472 |
String original = "{{ ^ }}"; |
473 |
String expected = "{{ \"^\" }}"; |
474 |
insertChar(original, '"', expected); |
475 |
} |
476 |
|
477 |
public void testInsertDoubleQuoteInVariable_02() throws Exception { |
478 |
String original = "{{ \"^ }}"; |
479 |
String expected = "{{ \"\"^ }}"; |
480 |
insertChar(original, '"', expected); |
481 |
} |
482 |
|
483 |
public void testInsertDoubleQuoteInVariable_03() throws Exception { |
484 |
String original = "{{ ^\" }}"; |
485 |
String expected = "{{ \"^\" }}"; |
486 |
insertChar(original, '"', expected); |
487 |
} |
488 |
|
489 |
public void testInsertDoubleQuoteInVariable_04() throws Exception { |
490 |
String original = "{{ \"test^ }}"; |
491 |
String expected = "{{ \"test\"^ }}"; |
492 |
insertChar(original, '"', expected); |
493 |
} |
494 |
|
495 |
public void testInsertDoubleQuoteInVariable_05() throws Exception { |
496 |
String original = "{{ ^test\" }}"; |
497 |
String expected = "{{ \"^test\" }}"; |
498 |
insertChar(original, '"', expected); |
499 |
} |
500 |
|
501 |
public void testInsertDoubleQuoteInVariable_06() throws Exception { |
502 |
String original = "{{ \"test\" }}^"; |
503 |
String expected = "{{ \"test\" }}\"^"; |
504 |
insertChar(original, '"', expected); |
505 |
} |
506 |
|
507 |
public void testInsertDoubleQuoteInVariable_07() throws Exception { |
508 |
String original = "{{^}}"; |
509 |
String expected = "{{\"^\"}}"; |
510 |
insertChar(original, '"', expected); |
511 |
} |
512 |
|
513 |
public void testInsertSingleQuoteInVariable_01() throws Exception { |
514 |
String original = "{{ ^ }}"; |
515 |
String expected = "{{ '^' }}"; |
516 |
insertChar(original, '\'', expected); |
517 |
} |
518 |
|
519 |
public void testInsertSingleQuoteInVariable_02() throws Exception { |
520 |
String original = "{{ '^ }}"; |
521 |
String expected = "{{ ''^ }}"; |
522 |
insertChar(original, '\'', expected); |
523 |
} |
524 |
|
525 |
public void testInsertSingleQuoteInVariable_03() throws Exception { |
526 |
String original = "{{ ^' }}"; |
527 |
String expected = "{{ '^' }}"; |
528 |
insertChar(original, '\'', expected); |
529 |
} |
530 |
|
531 |
public void testInsertSingleQuoteInVariable_04() throws Exception { |
532 |
String original = "{{ 'test^ }}"; |
533 |
String expected = "{{ 'test'^ }}"; |
534 |
insertChar(original, '\'', expected); |
535 |
} |
536 |
|
537 |
public void testInsertSingleQuoteInVariable_05() throws Exception { |
538 |
String original = "{{ ^test' }}"; |
539 |
String expected = "{{ '^test' }}"; |
540 |
insertChar(original, '\'', expected); |
541 |
} |
542 |
|
543 |
public void testInsertSingleQuoteInVariable_06() throws Exception { |
544 |
String original = "{{ 'test' }}^"; |
545 |
String expected = "{{ 'test' }}'^"; |
546 |
insertChar(original, '\'', expected); |
547 |
} |
548 |
|
549 |
public void testInsertSingleQuoteInVariable_07() throws Exception { |
550 |
String original = "{{^}}"; |
551 |
String expected = "{{'^'}}"; |
552 |
insertChar(original, '\'', expected); |
553 |
} |
554 |
|
555 |
public void testInsertCurlyInVariable_01() throws Exception { |
556 |
String original = "{{ ^ }}"; |
557 |
String expected = "{{ {^} }}"; |
558 |
insertChar(original, '{', expected); |
559 |
} |
560 |
|
561 |
public void testInsertCurlyInVariable_02() throws Exception { |
562 |
String original = "{{^}}"; |
563 |
String expected = "{{{^}}}"; |
564 |
insertChar(original, '{', expected); |
565 |
} |
566 |
|
567 |
public void testInsertParenthesisInVariable_01() throws Exception { |
568 |
String original = "{{ ^ }}"; |
569 |
String expected = "{{ (^) }}"; |
570 |
insertChar(original, '(', expected); |
571 |
} |
572 |
|
573 |
public void testInsertParenthesisInVariable_02() throws Exception { |
574 |
String original = "{{^}}"; |
575 |
String expected = "{{(^)}}"; |
576 |
insertChar(original, '(', expected); |
577 |
} |
578 |
|
579 |
public void testInsertBracketInVariable_01() throws Exception { |
580 |
String original = "{{ ^ }}"; |
581 |
String expected = "{{ [^] }}"; |
582 |
insertChar(original, '[', expected); |
583 |
} |
584 |
|
585 |
public void testInsertBracketInVariable_02() throws Exception { |
586 |
String original = "{{^}}"; |
587 |
String expected = "{{[^]}}"; |
588 |
insertChar(original, '[', expected); |
589 |
} |
590 |
|
591 |
// skip closing bracket |
592 |
// curly can be used in variable? |
593 |
public void testSkipClosingCurlyInVariable_01() throws Exception { |
594 |
String original = "{{ {^} }}"; |
595 |
String expected = "{{ {}^ }}"; |
596 |
insertChar(original, '}', expected); |
597 |
} |
598 |
|
599 |
public void testSkipClosingCurlyInVariable_02() throws Exception { |
600 |
// }} is delimiter, so add a space between }} |
601 |
String original = "{{ {'foo' : {^} } }}"; |
602 |
String expected = "{{ {'foo' : {}^ } }}"; |
603 |
insertChar(original, '}', expected); |
604 |
} |
605 |
|
606 |
public void testSkipClosingCurlyInVariable_03() throws Exception { |
607 |
// }} is delimiter, so add a space between }} |
608 |
String original = "{{ {'foo' : {^} } { }}"; |
609 |
String expected = "{{ {'foo' : {}^ } { }}"; |
610 |
insertChar(original, '}', expected); |
611 |
} |
612 |
|
613 |
public void testSkipClosingParenthesisInVariable_01() throws Exception { |
614 |
String original = "{{ (^) }}"; |
615 |
String expected = "{{ ()^ }}"; |
616 |
insertChar(original, ')', expected); |
617 |
} |
618 |
|
619 |
public void testSkipClosingParenthesisInVariable_02() throws Exception { |
620 |
String original = "{{ ((^)) }}"; |
621 |
String expected = "{{ (()^) }}"; |
622 |
insertChar(original, ')', expected); |
623 |
} |
624 |
|
625 |
public void testSkipClosingParenthesisInVariable_03() throws Exception { |
626 |
String original = "{{ ((^)) ( }}"; |
627 |
String expected = "{{ (()^) ( }}"; |
628 |
insertChar(original, ')', expected); |
629 |
} |
630 |
|
631 |
public void testSkipClosingBracketInVariable_01() throws Exception { |
632 |
String original = "{{ [^] }}"; |
633 |
String expected = "{{ []^ }}"; |
634 |
insertChar(original, ']', expected); |
635 |
} |
636 |
|
637 |
public void testSkipClosingBracketInVariable_02() throws Exception { |
638 |
String original = "{{ [[^]] }}"; |
639 |
String expected = "{{ [[]^] }}"; |
640 |
insertChar(original, ']', expected); |
641 |
} |
642 |
|
643 |
public void testSkipClosingBracketInVariable_03() throws Exception { |
644 |
String original = "{{ [[(^]] [ }}"; |
645 |
String expected = "{{ [[(]^] [ }}"; |
646 |
insertChar(original, ']', expected); |
647 |
} |
648 |
|
649 |
// missing closing bracket |
650 |
public void testMissingClosingCurlyInVariable_01() throws Exception { |
651 |
String original = "{{ {'foo' : {^} }}"; |
652 |
String expected = "{{ {'foo' : {}^} }}"; |
653 |
insertChar(original, '}', expected); |
654 |
} |
655 |
|
656 |
public void testMissingClosingCurlyInVariable_02() throws Exception { |
657 |
String original = "{{ {'foo' : {}^ }}"; |
658 |
String expected = "{{ {'foo' : {}}^ }}"; |
659 |
insertChar(original, '}', expected); |
660 |
} |
661 |
|
662 |
public void testMissingClosingCurlyInVariable_03() throws Exception { |
663 |
String original = "{{ {'foo' : {}^ { }}"; |
664 |
String expected = "{{ {'foo' : {}}^ { }}"; |
665 |
insertChar(original, '}', expected); |
666 |
} |
667 |
|
668 |
public void testMissingClosingParenthesisInVariable_01() throws Exception { |
669 |
String original = "{{ ((^) }}"; |
670 |
String expected = "{{ (()^) }}"; |
671 |
insertChar(original, ')', expected); |
672 |
} |
673 |
|
674 |
public void testMissingClosingParenthesisInVariable_02() throws Exception { |
675 |
String original = "{{ (()^ }}"; |
676 |
String expected = "{{ (())^ }}"; |
677 |
insertChar(original, ')', expected); |
678 |
} |
679 |
|
680 |
public void testMissingClosingParenthesisInVariable_03() throws Exception { |
681 |
String original = "{{ (()^ () }}"; |
682 |
String expected = "{{ (())^ () }}"; |
683 |
insertChar(original, ')', expected); |
684 |
} |
685 |
|
686 |
public void testMissingClosingBracketInVariable_01() throws Exception { |
687 |
String original = "{{ [[^] }}"; |
688 |
String expected = "{{ [[]^] }}"; |
689 |
insertChar(original, ']', expected); |
690 |
} |
691 |
|
692 |
public void testMissingClosingBracketInVariable_02() throws Exception { |
693 |
String original = "{{ [[]^ }}"; |
694 |
String expected = "{{ [[]]^ }}"; |
695 |
insertChar(original, ']', expected); |
696 |
} |
697 |
|
698 |
public void testMissingClosingBracketInVariable_03() throws Exception { |
699 |
String original = "{{ [[]^ [] }}"; |
700 |
String expected = "{{ [[]]^ [] }}"; |
701 |
insertChar(original, ']', expected); |
702 |
} |
703 |
|
704 |
public void testInsertCurlyInHtml() throws Exception { |
705 |
String original = "{% {} %}^"; |
706 |
String expected = "{% {} %}{^"; |
707 |
insertChar(original, '{', expected); |
708 |
} |
709 |
|
710 |
public void testInsertParenthesisInHtml() throws Exception { |
711 |
String original = "{% () %}^"; |
712 |
String expected = "{% () %}(^"; |
713 |
insertChar(original, '(', expected); |
714 |
} |
715 |
|
716 |
public void testInsertBracketInHtml() throws Exception { |
717 |
String original = "{% [] %}^"; |
718 |
String expected = "{% [] %}[^"; |
719 |
insertChar(original, '[', expected); |
720 |
} |
721 |
|
722 |
public void testCurlyInHtml() throws Exception { |
723 |
String original = "<html><body>^</body></html>"; |
724 |
String expected = "<html><body>{^</body></html>"; |
725 |
insertChar(original, '{', expected); |
726 |
} |
727 |
|
728 |
public void testVariableInHtml() throws Exception { |
729 |
String original = "<html><body>{^</body></html>"; |
730 |
String expected = "<html><body>{{ ^ }}</body></html>"; |
731 |
insertChar(original, '{', expected); |
732 |
} |
733 |
|
734 |
public void testBlockInHtml() throws Exception { |
735 |
String original = "<html><body>{^</body></html>"; |
736 |
String expected = "<html><body>{% ^ %}</body></html>"; |
737 |
insertChar(original, '%', expected); |
738 |
} |
739 |
|
740 |
public void testCurlyInHtmlAttribute() throws Exception { |
741 |
String original |
742 |
= "<html>\n" |
743 |
+ " <body>\n" |
744 |
+ " <ul id=\"navigation\">\n" |
745 |
+ " {% for item in navigation %}\n" |
746 |
+ " <li><a href=\"^\">{{ item.caption }}</a></li>\n" // here |
747 |
+ " {% endfor %}\n" |
748 |
+ " </ul>\n" |
749 |
+ " </body>\n" |
750 |
+ "</html>"; |
751 |
String expected |
752 |
= "<html>\n" |
753 |
+ " <body>\n" |
754 |
+ " <ul id=\"navigation\">\n" |
755 |
+ " {% for item in navigation %}\n" |
756 |
+ " <li><a href=\"{^\">{{ item.caption }}</a></li>\n" // here |
757 |
+ " {% endfor %}\n" |
758 |
+ " </ul>\n" |
759 |
+ " </body>\n" |
760 |
+ "</html>"; |
761 |
insertChar(original, '{', expected); |
762 |
} |
763 |
|
764 |
public void testVariableInHtmlAttribute() throws Exception { |
765 |
String original |
766 |
= "<html>\n" |
767 |
+ " <body>\n" |
768 |
+ " <ul id=\"navigation\">\n" |
769 |
+ " {% for item in navigation %}\n" |
770 |
+ " <li><a href=\"{^\">{{ item.caption }}</a></li>\n" // here |
771 |
+ " {% endfor %}\n" |
772 |
+ " </ul>\n" |
773 |
+ " </body>\n" |
774 |
+ "</html>"; |
775 |
String expected |
776 |
= "<html>\n" |
777 |
+ " <body>\n" |
778 |
+ " <ul id=\"navigation\">\n" |
779 |
+ " {% for item in navigation %}\n" |
780 |
+ " <li><a href=\"{{ ^ }}\">{{ item.caption }}</a></li>\n" // here |
781 |
+ " {% endfor %}\n" |
782 |
+ " </ul>\n" |
783 |
+ " </body>\n" |
784 |
+ "</html>"; |
785 |
insertChar(original, '{', expected); |
786 |
} |
787 |
|
788 |
public void testCurlyInTwigBlock() throws Exception { |
789 |
String original |
790 |
= "<html>\n" |
791 |
+ " <body>\n" |
792 |
+ " <ul id=\"navigation\">\n" |
793 |
+ " {% for item in navigation %}\n" |
794 |
+ " ^\n" // here |
795 |
+ " {% endfor %}\n" |
796 |
+ " </ul>\n" |
797 |
+ " </body>\n" |
798 |
+ "</html>"; |
799 |
String expected |
800 |
= "<html>\n" |
801 |
+ " <body>\n" |
802 |
+ " <ul id=\"navigation\">\n" |
803 |
+ " {% for item in navigation %}\n" |
804 |
+ " {^\n" // here |
805 |
+ " {% endfor %}\n" |
806 |
+ " </ul>\n" |
807 |
+ " </body>\n" |
808 |
+ "</html>"; |
809 |
insertChar(original, '{', expected); |
810 |
} |
811 |
|
812 |
public void testVariableInTwigBlock() throws Exception { |
813 |
String original |
814 |
= "<html>\n" |
815 |
+ " <body>\n" |
816 |
+ " <ul id=\"navigation\">\n" |
817 |
+ " {% for item in navigation %}\n" |
818 |
+ " {^\n" // here |
819 |
+ " {% endfor %}\n" |
820 |
+ " </ul>\n" |
821 |
+ " </body>\n" |
822 |
+ "</html>"; |
823 |
String expected |
824 |
= "<html>\n" |
825 |
+ " <body>\n" |
826 |
+ " <ul id=\"navigation\">\n" |
827 |
+ " {% for item in navigation %}\n" |
828 |
+ " {{ ^ }}\n" // here |
829 |
+ " {% endfor %}\n" |
830 |
+ " </ul>\n" |
831 |
+ " </body>\n" |
832 |
+ "</html>"; |
833 |
insertChar(original, '{', expected); |
834 |
} |
835 |
|
836 |
public void testBlockInTwigBlock() throws Exception { |
837 |
String original |
838 |
= "<html>\n" |
839 |
+ " <body>\n" |
840 |
+ " <ul id=\"navigation\">\n" |
841 |
+ " {% for item in navigation %}\n" |
842 |
+ " {^\n" // here |
843 |
+ " {% endfor %}\n" |
844 |
+ " </ul>\n" |
845 |
+ " </body>\n" |
846 |
+ "</html>"; |
847 |
String expected |
848 |
= "<html>\n" |
849 |
+ " <body>\n" |
850 |
+ " <ul id=\"navigation\">\n" |
851 |
+ " {% for item in navigation %}\n" |
852 |
+ " {% ^ %}\n" // here |
853 |
+ " {% endfor %}\n" |
854 |
+ " </ul>\n" |
855 |
+ " </body>\n" |
856 |
+ "</html>"; |
857 |
insertChar(original, '%', expected); |
858 |
} |
859 |
|
860 |
} |