|
21 | 21 |
|
22 | 22 | import org.junit.jupiter.api.Test;
|
23 | 23 |
|
| 24 | +import io.quarkus.qute.Expression.Part; |
24 | 25 | import io.quarkus.qute.TemplateException.Builder;
|
25 | 26 | import io.quarkus.qute.TemplateLocator.TemplateLocation;
|
26 | 27 | import io.quarkus.qute.TemplateNode.Origin;
|
@@ -460,13 +461,38 @@ public void testSectionParameterWithNestedSingleQuotationMark() {
|
460 | 461 | assertSectionParams(engine, "{#let id=\"'Foo \"}", Map.of("id", "\"'Foo \""));
|
461 | 462 | assertSectionParams(engine, "{#let id=\"'Foo ' \"}", Map.of("id", "\"'Foo ' \""));
|
462 | 463 | assertSectionParams(engine, "{#let id=\"'Foo ' \" bar='baz'}", Map.of("id", "\"'Foo ' \"", "bar", "'baz'"));
|
463 |
| - assertSectionParams(engine, "{#let my=bad id=(\"'Foo ' \" + 1) bar='baz'}", |
464 |
| - Map.of("my", "bad", "id", "(\"'Foo ' \" + 1)", "bar", "'baz'")); |
| 464 | + assertSectionParams(engine, "{#let my=bad id=(foo + 1) bar='baz'}", |
| 465 | + Map.of("my", "bad", "id", "(foo + 1)", "bar", "'baz'")); |
465 | 466 | assertSectionParams(engine, "{#let id = 'Foo'}", Map.of("id", "'Foo'"));
|
466 | 467 | assertSectionParams(engine, "{#let id= 'Foo'}", Map.of("id", "'Foo'"));
|
467 | 468 | assertSectionParams(engine, "{#let my = (bad or not) id=1}", Map.of("my", "(bad or not)", "id", "1"));
|
468 | 469 | assertSectionParams(engine, "{#let my= (bad or not) id=1}", Map.of("my", "(bad or not)", "id", "1"));
|
| 470 | + } |
| 471 | + |
| 472 | + @Test |
| 473 | + public void testVirtualMethodWithNestedLiteralSeparator() { |
| 474 | + Engine engine = Engine.builder().addDefaults().build(); |
| 475 | + List<Part> parts = engine.parse("{foo('Bar \"!')}").findExpression(e -> true).getParts(); |
| 476 | + assertVirtualMethodParam(parts.get(0), "foo", "Bar \"!"); |
| 477 | + |
| 478 | + parts = engine.parse("{foo(\"Bar '!\")}").findExpression(e -> true).getParts(); |
| 479 | + assertVirtualMethodParam(parts.get(0), "foo", "Bar '!"); |
| 480 | + |
| 481 | + parts = engine.parse("{foo(\"Bar '!\").baz(1)}").findExpression(e -> true).getParts(); |
| 482 | + assertVirtualMethodParam(parts.get(0), "foo", "Bar '!"); |
| 483 | + assertVirtualMethodParam(parts.get(1), "baz", "1"); |
| 484 | + |
| 485 | + parts = engine.parse("{str:builder('Qute').append(\"is '\").append(\"cool!\")}").findExpression(e -> true).getParts(); |
| 486 | + assertVirtualMethodParam(parts.get(0), "builder", "Qute"); |
| 487 | + assertVirtualMethodParam(parts.get(1), "append", "is '"); |
| 488 | + assertVirtualMethodParam(parts.get(2), "append", "cool!"); |
| 489 | + } |
469 | 490 |
|
| 491 | + private void assertVirtualMethodParam(Part part, String name, String literal) { |
| 492 | + assertTrue(part.isVirtualMethod()); |
| 493 | + assertEquals(name, part.getName()); |
| 494 | + assertTrue(part.asVirtualMethod().getParameters().get(0).isLiteral()); |
| 495 | + assertEquals(literal, part.asVirtualMethod().getParameters().get(0).getLiteral().toString()); |
470 | 496 | }
|
471 | 497 |
|
472 | 498 | @Test
|
|
0 commit comments