-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23725 from mkouba/issue-23677
Qute type-safe expressions - ignore wildcards in parameter declarations
- Loading branch information
Showing
12 changed files
with
160 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...t/src/test/java/io/quarkus/qute/deployment/typesafe/CheckedTemplatePrimitiveTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.quarkus.qute.deployment.typesafe; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.CheckedTemplate; | ||
import io.quarkus.qute.TemplateInstance; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class CheckedTemplatePrimitiveTypeTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Templates.class) | ||
.addAsResource(new StringAsset("Hello {val}!"), | ||
"templates/CheckedTemplatePrimitiveTypeTest/integers.txt")); | ||
|
||
@Test | ||
public void testPrimitiveParamBinding() { | ||
assertEquals("Hello 1!", Templates.integers(1).render()); | ||
} | ||
|
||
@CheckedTemplate | ||
public static class Templates { | ||
|
||
static native TemplateInstance integers(int val); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,8 @@ static boolean negate(boolean val) { | |
return !val; | ||
} | ||
|
||
static int toInt(Movie movie, int val) { | ||
return val; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
independent-projects/qute/core/src/test/java/io/quarkus/qute/ScopeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.qute; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ScopeTest { | ||
|
||
@Test | ||
public void testSanitizeType() { | ||
assertBinding("List<? extends Foo>", "List<Foo>"); | ||
assertBinding("List<? super Foo>", "List<Foo>"); | ||
assertBinding("List< ? super Foo>", "List<Foo>"); | ||
assertBinding("List<?>", "List<java.lang.Object>"); | ||
assertBinding("Map<String, ?>", "Map<String,java.lang.Object>"); | ||
assertBinding("Map<String, ? extends Foo>", "Map<String,Foo>"); | ||
assertBinding("Map<String, ? extends List<Foo>>", "Map<String,List<Foo>>"); | ||
assertBinding("Map<? extend java.lang.Object, ?>", "Map<java.lang.Object,java.lang.Object>"); | ||
} | ||
|
||
private void assertBinding(String type, String sanitizedType) { | ||
Scope scope = new Scope(null); | ||
scope.putBinding("foo", sanitizedType); | ||
assertEquals(sanitizedType, scope.getBinding("foo")); | ||
} | ||
|
||
} |