Add net stdlib module with URL support (#1834)
This commit is contained in:
1 parent
dbcecd9677
commit
862c61f2e2
46 files changed
+3682
-15
No files matched your search
@@ -703,6 +703,7 @@ class KotlinCodeGenerator(
|
||||
PClassInfo.Class -> PCLASS
|
||||
PClassInfo.Regex -> REGEX
|
||||
PClassInfo.Version -> VERSION
|
||||
PClassInfo.Url -> URI
|
||||
else ->
|
||||
when {
|
||||
!classInfo.isStandardLibraryClass -> pClass.toKotlinPoetName()
|
||||
|
||||
@@ -1186,6 +1186,52 @@ class KotlinCodeGeneratorTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `pkl_net Url`() {
|
||||
val kotlinCode =
|
||||
generateKotlinCode(
|
||||
"""
|
||||
module mod
|
||||
|
||||
import "pkl:net"
|
||||
|
||||
url: net.Url
|
||||
nullableUrl: net.Url?
|
||||
listing: Listing<net.Url>
|
||||
mapping: Mapping<String, net.Url>
|
||||
|
||||
class Foo {
|
||||
url: net.Url
|
||||
}
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
|
||||
assertThat(kotlinCode)
|
||||
.compilesSuccessfully()
|
||||
.isEqualTo(
|
||||
"""
|
||||
import java.net.URI
|
||||
import kotlin.String
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
data class Mod(
|
||||
val url: URI,
|
||||
val nullableUrl: URI?,
|
||||
val listing: List<URI>,
|
||||
val mapping: Map<String, URI>
|
||||
) {
|
||||
data class Foo(
|
||||
val url: URI
|
||||
)
|
||||
}
|
||||
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `user defined type aliases`() {
|
||||
val kotlinCode =
|
||||
|
||||
Reference in new issue
Block a user