Reformat Kotlin code (#1560)

ktfmt has much improved how it formats Kotlin code. Unfortunately, this
means that whenever we touch a single line in a Kotlin file, we get a
_lot_ more changes thanks to ratcheting now picking up this file for
formatting.

This PR just reformats every single Kotlin file so we don't have to deal
with this churn in future PRs that touch Kotlin code.
This commit is contained in:
Daniel Chao
2026-04-25 06:14:44 -07:00
committed by GitHub
parent c4f56bf20d
commit 2b3603b544
44 changed files with 2862 additions and 2848 deletions
+113 -101
View File
@@ -1,3 +1,22 @@
/*
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.nio.file.Files
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
import kotlin.io.path.useDirectoryEntries
import org.junit.platform.commons.annotation.Testable
import org.junit.platform.engine.*
import org.junit.platform.engine.TestDescriptor.Type
@@ -16,23 +35,18 @@ import org.pkl.core.Loggers
import org.pkl.core.SecurityManagers
import org.pkl.core.StackFrameTransformers
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.repl.ReplRequest
import org.pkl.core.repl.ReplResponse
import org.pkl.core.repl.ReplServer
import org.pkl.core.resource.ResourceReaders
import org.pkl.core.util.IoUtils
import org.pkl.core.http.HttpClient
import org.pkl.parser.Parser
import org.pkl.parser.ParserError
import org.pkl.parser.syntax.ClassProperty
import org.pkl.core.resource.ResourceReaders
import java.nio.file.Files
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
import kotlin.io.path.useDirectoryEntries
@Testable
class DocSnippetTests
@Testable class DocSnippetTests
class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.ExecutionContext>() {
private val projectDir = rootProjectDir.resolve("docs")
@@ -41,7 +55,8 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
private companion object {
val headingRegex = Regex("""(?u)^\s*(=++)\s*(.+)""")
val collapsibleBlockRegex = Regex("""(?u)^\s*\[%collapsible""")
val codeBlockRegex = Regex("""(?u)^\s*\[source(?:%(tested|parsed)(%error)?)?(?:,\{?([a-zA-Z-_]+)}?)?""")
val codeBlockRegex =
Regex("""(?u)^\s*\[source(?:%(tested|parsed)(%error)?)?(?:,\{?([a-zA-Z-_]+)}?)?""")
val codeBlockNameRegex = Regex("""(?u)^\s*\.(.+)""")
val codeBlockDelimiterRegex = Regex("""(?u)^\s*----""")
val graphicsRegex = Regex("\\[small]#.+#")
@@ -51,7 +66,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
override fun discover(
discoveryRequest: EngineDiscoveryRequest,
uniqueId: UniqueId
uniqueId: UniqueId,
): TestDescriptor {
val packageSelectors = discoveryRequest.getSelectorsByType(PackageSelector::class.java)
val classSelectors = discoveryRequest.getSelectorsByType(ClassSelector::class.java)
@@ -62,12 +77,14 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
val packageName = testClass.`package`.name
val className = testClass.name
if (methodSelectors.isEmpty()
&& (packageSelectors.isEmpty() || packageSelectors.any { it.packageName == packageName })
&& (classSelectors.isEmpty() || classSelectors.any { it.className == className })
if (
methodSelectors.isEmpty() &&
(packageSelectors.isEmpty() || packageSelectors.any { it.packageName == packageName }) &&
(classSelectors.isEmpty() || classSelectors.any { it.className == className })
) {
val rootDescriptor = Descriptor.Path(uniqueId, docsDir.fileName.toString(), ClassSource.from(testClass), docsDir)
val rootDescriptor =
Descriptor.Path(uniqueId, docsDir.fileName.toString(), ClassSource.from(testClass), docsDir)
doDiscover(rootDescriptor, uniqueIdSelectors)
return rootDescriptor
}
@@ -77,36 +94,34 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
}
override fun createExecutionContext(request: ExecutionRequest): ExecutionContext {
val replServer = ReplServer(
SecurityManagers.defaultManager,
HttpClient.dummyClient(),
Loggers.stdErr(),
listOf(
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.classPath(DocSnippetTests::class.java.classLoader),
ModuleKeyFactories.file
),
listOf(
ResourceReaders.environmentVariable(),
ResourceReaders.externalProperty()
),
System.getenv(),
emptyMap(),
null,
null,
null,
IoUtils.getCurrentWorkingDir(),
StackFrameTransformers.defaultTransformer,
false,
TraceMode.COMPACT,
)
val replServer =
ReplServer(
SecurityManagers.defaultManager,
HttpClient.dummyClient(),
Loggers.stdErr(),
listOf(
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.classPath(DocSnippetTests::class.java.classLoader),
ModuleKeyFactories.file,
),
listOf(ResourceReaders.environmentVariable(), ResourceReaders.externalProperty()),
System.getenv(),
emptyMap(),
null,
null,
null,
IoUtils.getCurrentWorkingDir(),
StackFrameTransformers.defaultTransformer,
false,
TraceMode.COMPACT,
)
return ExecutionContext(replServer)
}
private fun doDiscover(rootDescriptor: TestDescriptor, selectors: List<UniqueIdSelector>) {
fun isMatch(other: UniqueId) = selectors.isEmpty() || selectors.any {
it.uniqueId.hasPrefix(other) || other.hasPrefix(it.uniqueId)
}
fun isMatch(other: UniqueId) =
selectors.isEmpty() ||
selectors.any { it.uniqueId.hasPrefix(other) || other.hasPrefix(it.uniqueId) }
docsDir.useDirectoryEntries { docsDirEntries ->
for (docsDirEntry in docsDirEntries) {
@@ -116,12 +131,13 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
val docsDirEntryId = rootDescriptor.uniqueId.append("dir", docsDirEntryName)
if (!isMatch(docsDirEntryId)) continue
val docsDirEntryDescriptor = Descriptor.Path(
docsDirEntryId,
docsDirEntryName,
DirectorySource.from(docsDirEntry.toFile()),
docsDirEntry
)
val docsDirEntryDescriptor =
Descriptor.Path(
docsDirEntryId,
docsDirEntryName,
DirectorySource.from(docsDirEntry.toFile()),
docsDirEntry,
)
rootDescriptor.addChild(docsDirEntryDescriptor)
val pagesDir = docsDirEntry.resolve("pages")
@@ -131,17 +147,20 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
for (pagesDirEntry in pagesDirEntries) {
val pagesDirEntryName = pagesDirEntry.fileName.toString()
val pagesDirEntryId = docsDirEntryId.append("file", pagesDirEntryName)
if (!pagesDirEntry.isRegularFile() ||
!pagesDirEntryName.endsWith(".adoc") ||
!isMatch(pagesDirEntryId)
) continue
val pagesDirEntryDescriptor = Descriptor.Path(
pagesDirEntryId,
pagesDirEntryName,
FileSource.from(pagesDirEntry.toFile()),
pagesDirEntry
if (
!pagesDirEntry.isRegularFile() ||
!pagesDirEntryName.endsWith(".adoc") ||
!isMatch(pagesDirEntryId)
)
continue
val pagesDirEntryDescriptor =
Descriptor.Path(
pagesDirEntryId,
pagesDirEntryName,
FileSource.from(pagesDirEntry.toFile()),
pagesDirEntry,
)
docsDirEntryDescriptor.addChild(pagesDirEntryDescriptor)
parseAsciidoc(pagesDirEntryDescriptor, selectors)
@@ -174,17 +193,15 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
}
val parent = sections.firstOrNull() ?: docDescriptor
val normalizedTitle = title
.replace("<code>", "")
.replace("</code>", "")
.replace(graphicsRegex, "")
.trim()
val childSection = Descriptor.Section(
parent.uniqueId.append("section", normalizedTitle),
normalizedTitle,
FileSource.from(docDescriptor.path.toFile(), FilePosition.from(lineNum)),
newLevel
)
val normalizedTitle =
title.replace("<code>", "").replace("</code>", "").replace(graphicsRegex, "").trim()
val childSection =
Descriptor.Section(
parent.uniqueId.append("section", normalizedTitle),
normalizedTitle,
FileSource.from(docDescriptor.path.toFile(), FilePosition.from(lineNum)),
newLevel,
)
sections.addFirst(childSection)
parent.addChild(childSection)
@@ -217,7 +234,8 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
codeBlockNum += 1
val (testMode, error, language) = codeBlockMatch.destructured
if (testMode.isNotEmpty()) {
val blockName = codeBlockNameRegex.find(prevLine)?.groupValues?.get(1) ?: "snippet$codeBlockNum"
val blockName =
codeBlockNameRegex.find(prevLine)?.groupValues?.get(1) ?: "snippet$codeBlockNum"
while (linesIterator.hasNext()) {
advance()
val startDelimiterMatch = codeBlockDelimiterRegex.find(line)
@@ -236,10 +254,13 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
snippetId,
blockName,
language,
FileSource.from(docDescriptor.path.toFile(), FilePosition.from(jumpToLineNum)),
FileSource.from(
docDescriptor.path.toFile(),
FilePosition.from(jumpToLineNum),
),
builder.toString(),
testMode == "parsed",
error.isNotEmpty()
error.isNotEmpty(),
)
)
}
@@ -261,28 +282,21 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
}
}
private sealed class Descriptor(
uniqueId: UniqueId,
displayName: String,
source: TestSource
) : AbstractTestDescriptor(uniqueId, displayName, source), Node<ExecutionContext> {
private sealed class Descriptor(uniqueId: UniqueId, displayName: String, source: TestSource) :
AbstractTestDescriptor(uniqueId, displayName, source), Node<ExecutionContext> {
class Path(
uniqueId: UniqueId,
displayName: String,
source: TestSource,
val path: java.nio.file.Path
val path: java.nio.file.Path,
) : Descriptor(uniqueId, displayName, source) {
override fun getType() = Type.CONTAINER
}
class Section(
uniqueId: UniqueId,
displayName: String,
source: TestSource,
val level: Int
) : Descriptor(uniqueId, displayName, source) {
class Section(uniqueId: UniqueId, displayName: String, source: TestSource, val level: Int) :
Descriptor(uniqueId, displayName, source) {
override fun getType() = Type.CONTAINER
@@ -299,7 +313,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
source: TestSource,
private val code: String,
private val parseOnly: Boolean,
private val expectError: Boolean
private val expectError: Boolean,
) : Descriptor(uniqueId, displayName, source) {
override fun getType() = Type.TEST
@@ -308,11 +322,14 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
when (language) {
"pkl" -> Parser().parseModule(code)
"pkl-expr" -> Parser().parseExpressionInput(code)
else -> throw(Exception("Unrecognized language: $language"))
else -> throw (Exception("Unrecognized language: $language"))
}
}
override fun execute(context: ExecutionContext, executor: DynamicTestExecutor): ExecutionContext {
override fun execute(
context: ExecutionContext,
executor: DynamicTestExecutor,
): ExecutionContext {
if (parseOnly) {
try {
parsed
@@ -328,12 +345,7 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
}
context.replServer.handleRequest(
ReplRequest.Eval(
"snippet",
code,
!expectError,
!expectError
)
ReplRequest.Eval("snippet", code, !expectError, !expectError)
)
val properties = parsed.children()?.filterIsInstance<ClassProperty>() ?: emptyList()
@@ -342,21 +354,21 @@ class DocSnippetTestsEngine : HierarchicalTestEngine<DocSnippetTestsEngine.Execu
// force each property
for (prop in properties) {
responses.addAll(context.replServer.handleRequest(
ReplRequest.Eval(
"snippet",
prop.name.value,
false,
true
responses.addAll(
context.replServer.handleRequest(
ReplRequest.Eval("snippet", prop.name.value, false, true)
)
))
)
}
if (expectError) {
if (responses.dropLast(1).any { it !is ReplResponse.EvalSuccess } ||
responses.last() !is ReplResponse.EvalError) {
if (
responses.dropLast(1).any { it !is ReplResponse.EvalSuccess } ||
responses.last() !is ReplResponse.EvalError
) {
throw AssertionError(
"Expected %error snippet to fail at the end, but got the following REPL responses:\n\n" +
responses.joinToString("\n\n") { it.message })
responses.joinToString("\n\n") { it.message }
)
}
return context
@@ -44,19 +44,19 @@ constructor(
private val sourceModule =
ModuleSource.text(
"""
import "pkl:analyze"
import "pkl:analyze"
local importStrings = read*("prop:pkl.analyzeImports.**").toMap().values.toSet()
local importStrings = read*("prop:pkl.analyzeImports.**").toMap().values.toSet()
output {
value = analyze.importGraph(importStrings)
renderer {
converters {
[Map] = (it) -> it.toMapping()
[Set] = (it) -> it.toListing()
}
output {
value = analyze.importGraph(importStrings)
renderer {
converters {
[Map] = (it) -> it.toMapping()
[Set] = (it) -> it.toListing()
}
}
}
"""
.trimIndent()
)
@@ -53,9 +53,9 @@ constructor(
throw CliException(
"""
Usage: pkl test [<options>] <modules>...
Error: missing argument <modules>
"""
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ internal object ReplMessages {
* Incomplete input will be continued on the next line.
* Multi-line programs can be copy-pasted into the REPL.
"""
"""
.trimIndent()
val examples: String =
File diff suppressed because it is too large Load Diff
@@ -58,7 +58,7 @@ class CliEvaluatorTest {
name = "pigeon"
age = 20 + 10
}
"""
"""
.trimIndent()
private val packageServer = PackageServer()
@@ -243,12 +243,12 @@ person:
.resolve("test2.pkl")
.writeString(
"""
amends "test.pkl"
person {
name = "barn owl"
}
"""
amends "test.pkl"
person {
name = "barn owl"
}
"""
.trimIndent()
)
@@ -655,9 +655,9 @@ result = someLib.x
"output.pcf",
"""
x = 1
y = 2
z = 3
"""
.trimIndent(),
@@ -739,7 +739,7 @@ result = someLib.x
}
}
}
"""
"""
.trimIndent(),
)
)
@@ -815,31 +815,31 @@ result = someLib.x
writePklFile(
"test0.pkl",
"""
output {
files {
["foo.pcf"] {
value = new Dynamic {
["bar"] = "baz"
output {
files {
["foo.pcf"] {
value = new Dynamic {
["bar"] = "baz"
}
}
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"test1.pkl",
"""
output {
files {
["bar.pcf"] {
value = new Dynamic {
["bar"] = "baz"
output {
files {
["bar.pcf"] {
value = new Dynamic {
["bar"] = "baz"
}
}
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -860,27 +860,27 @@ result = someLib.x
writePklFile(
"bar.pkl",
"""
output {
files {
["foo.pcf"] {
text = "myBar"
output {
files {
["foo.pcf"] {
text = "myBar"
}
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"foo.pkl",
"""
output {
files {
["foo.pcf"] {
text = "myFoo"
output {
files {
["foo.pcf"] {
text = "myFoo"
}
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -918,7 +918,7 @@ result = someLib.x
}
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -949,7 +949,7 @@ result = someLib.x
}
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -970,23 +970,23 @@ result = someLib.x
writePklFile(
"test1.pkl",
"""
output {
files {
["."] { text = "bar" }
output {
files {
["."] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"test2.pkl",
"""
output {
files {
["myDir"] { text = "bar" }
output {
files {
["myDir"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -1009,23 +1009,23 @@ result = someLib.x
writePklFile(
"test1.pkl",
"""
output {
files {
["foo.txt"] { text = "bar" }
output {
files {
["foo.txt"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"test2.pkl",
"""
output {
files {
["foo.txt"] { text = "bar" }
output {
files {
["foo.txt"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -1045,13 +1045,13 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
output {
files {
["foo.txt"] { text = "bar" }
["./foo.txt"] { text = "bar" }
output {
files {
["foo.txt"] { text = "bar" }
["./foo.txt"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -1071,12 +1071,12 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
output {
files {
["foo:bar"] { text = "bar" }
output {
files {
["foo:bar"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
)
@@ -1096,12 +1096,12 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
output {
files {
["foo\\bar"] { text = "bar" }
output {
files {
["foo\\bar"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
)
@@ -1120,10 +1120,10 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
foo {
bar = 1
}
"""
foo {
bar = 1
}
"""
.trimIndent(),
)
val options =
@@ -1136,8 +1136,8 @@ result = someLib.x
assertThat(buffer.toString(StandardCharsets.UTF_8))
.isEqualTo(
"""
new Dynamic { bar = 1 }
"""
new Dynamic { bar = 1 }
"""
.trimIndent()
)
}
@@ -1148,13 +1148,13 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
class Person {
name: String
class Person {
name: String
function toString() = "Person(\(name))"
}
person: Person = new { name = "Frodo" }
"""
function toString() = "Person(\(name))"
}
person: Person = new { name = "Frodo" }
"""
.trimIndent(),
)
val options =
@@ -1173,10 +1173,10 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
person {
friend { name = "Bilbo" }
}
"""
person {
friend { name = "Bilbo" }
}
"""
.trimIndent(),
)
val options =
@@ -1196,17 +1196,17 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
res = 1
"""
res = 1
"""
.trimIndent(),
)
writePklFile(
"PklProject",
"""
amends "pkl:Project"
package = throw("invalid project package")
"""
"""
.trimIndent(),
)
val options =
@@ -1225,8 +1225,8 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
res = read*("env:**")
"""
res = read*("env:**")
"""
.trimIndent(),
)
writePklFile(
@@ -1234,14 +1234,14 @@ result = someLib.x
// language=Pkl
"""
amends "pkl:Project"
evaluatorSettings {
env {
["foo"] = "foo"
["bar"] = "bar"
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -1251,12 +1251,12 @@ result = someLib.x
assertThat(buffer.toString(StandardCharsets.UTF_8))
.isEqualTo(
"""
res {
["env:bar"] = "bar"
["env:foo"] = "foo"
}
"""
res {
["env:bar"] = "bar"
["env:foo"] = "foo"
}
"""
.trimIndent()
)
}
@@ -1353,10 +1353,10 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
import "package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"
res = Swallow
"""
import "package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"
res = Swallow
"""
.trimIndent(),
)
val buffer = ByteArrayOutputStream()
@@ -1375,14 +1375,14 @@ result = someLib.x
assertThat(buffer.toString(StandardCharsets.UTF_8))
.isEqualTo(
"""
res {
name = "Swallow"
favoriteFruit {
name = "Apple"
res {
name = "Swallow"
favoriteFruit {
name = "Apple"
}
}
}
"""
"""
.trimIndent()
)
assertThat(tempDir.resolve("package-2")).doesNotExist()
@@ -1481,13 +1481,13 @@ result = someLib.x
assertThat(output)
.isEqualTo(
"""
name = "Ostrich"
name = "Ostrich"
favoriteFruit {
name = "Orange"
}
favoriteFruit {
name = "Orange"
}
"""
"""
.trimIndent()
)
verify(getRequestedFor(urlEqualTo("birds@0.5.0")))
@@ -1590,13 +1590,13 @@ result = someLib.x
homeDir.writeFile(
"settings.pkl",
"""
amends "pkl:settings"
amends "pkl:settings"
http {
proxy {
address = "http://invalid.proxy.address"
}
http {
proxy {
address = "http://invalid.proxy.address"
}
}
"""
.trimIndent(),
)
@@ -1677,26 +1677,26 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
pigeon {
name = "Pigeon"
diet = "Seeds"
}
parrot {
name = "Parrot"
diet = "Seeds"
}
output {
files {
["pigeon.json"] {
value = pigeon
renderer = new JsonRenderer {}
}
["birds/parrot.yaml"] {
value = parrot
renderer = new YamlRenderer {}
}
pigeon {
name = "Pigeon"
diet = "Seeds"
}
parrot {
name = "Parrot"
diet = "Seeds"
}
output {
files {
["pigeon.json"] {
value = pigeon
renderer = new JsonRenderer {}
}
["birds/parrot.yaml"] {
value = parrot
renderer = new YamlRenderer {}
}
}
}
"""
.trimIndent(),
)
@@ -1713,10 +1713,10 @@ result = someLib.x
realOutputDir.resolve("pigeon.json"),
"pigeon.json",
"""
{
"name": "Pigeon",
"diet": "Seeds"
}
{
"name": "Pigeon",
"diet": "Seeds"
}
"""
.trimIndent(),
)
@@ -1725,8 +1725,8 @@ result = someLib.x
realOutputDir.resolve("birds/parrot.yaml"),
"parrot.yaml",
"""
name: Parrot
diet: Seeds
name: Parrot
diet: Seeds
"""
.trimIndent(),
)
@@ -1735,10 +1735,10 @@ result = someLib.x
symlinkOutputDir.resolve("pigeon.json"),
"pigeon.json",
"""
{
"name": "Pigeon",
"diet": "Seeds"
}
{
"name": "Pigeon",
"diet": "Seeds"
}
"""
.trimIndent(),
)
@@ -1747,8 +1747,8 @@ result = someLib.x
symlinkOutputDir.resolve("birds/parrot.yaml"),
"parrot.yaml",
"""
name: Parrot
diet: Seeds
name: Parrot
diet: Seeds
"""
.trimIndent(),
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,12 +69,12 @@ class CliMainTest {
val code =
"""
x = 3
output {
value = x
renderer = new JsonRenderer {}
}
"""
"""
.trimIndent()
val inputFile = tempDir.resolve("test.pkl").writeString(code).toString()
val outputFile = makeSymdir(tempDir, "out", "linkOut").resolve("test.pkl").toString()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,11 +70,11 @@ class CliPackageDownloaderTest {
"PklProject",
"""
amends "pkl:Project"
evaluatorSettings {
moduleCacheDir = ".my-cache"
}
"""
"""
.trimIndent(),
)
@@ -210,7 +210,7 @@ class CliPackageDownloaderTest {
Exception when making request `GET https://bogus.domain/notAPackage@1.0.0`:
Error connecting to host `bogus.domain`.
"""
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,8 +85,8 @@ class CliProjectPackagerTest {
.resolve("PklProject")
.writeString(
"""
amends "pkl:Project"
"""
amends "pkl:Project"
"""
.trimIndent()
)
val packager =
@@ -108,20 +108,20 @@ class CliProjectPackagerTest {
"myTest.pkl",
"""
amends "pkl:test"
facts {
["1 == 2"] {
1 == 2
}
}
"""
"""
.trimIndent(),
)
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
@@ -129,7 +129,7 @@ class CliProjectPackagerTest {
packageZipUrl = "https://foo.com"
apiTests { "myTest.pkl" }
}
"""
"""
.trimIndent(),
)
val buffer = StringWriter()
@@ -154,13 +154,13 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:test"
facts {
["1 == 1"] {
1 == 1
}
}
"""
"""
.trimIndent()
)
tempDir
@@ -168,7 +168,7 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
@@ -176,7 +176,7 @@ class CliProjectPackagerTest {
packageZipUrl = "https://foo.com"
apiTests { "myTest.pkl" }
}
"""
"""
.trimIndent()
)
val buffer = StringWriter()
@@ -203,13 +203,13 @@ class CliProjectPackagerTest {
"""
amends "pkl:test"
import "@birds/Bird.pkl"
examples {
["Bird"] {
new Bird { name = "Finch"; favoriteFruit { name = "Tangerine" } }
}
}
"""
"""
.trimIndent()
)
projectDir
@@ -226,8 +226,8 @@ class CliProjectPackagerTest {
}
}
}
"""
"""
.trimIndent()
)
projectDir
@@ -235,7 +235,7 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
@@ -249,7 +249,7 @@ class CliProjectPackagerTest {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
"""
.trimIndent()
)
projectDir
@@ -298,9 +298,9 @@ class CliProjectPackagerTest {
"a/b/foo.pkl",
"""
module foo
name: String
"""
"""
.trimIndent(),
)
@@ -311,7 +311,7 @@ class CliProjectPackagerTest {
foo
bar
baz
"""
"""
.trimIndent(),
)
@@ -320,14 +320,14 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
"""
.trimIndent()
)
val packager =
@@ -348,18 +348,18 @@ class CliProjectPackagerTest {
assertThat(expectedMetadata)
.hasContent(
"""
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "e83b67722ea17ba41717ce6e99ae8ee02d66df6294bd319ce403075b1071c3e0"
},
"dependencies": {},
"authors": []
}
"""
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "e83b67722ea17ba41717ce6e99ae8ee02d66df6294bd319ce403075b1071c3e0"
},
"dependencies": {},
"authors": []
}
"""
.trimIndent()
)
assertThat(expectedArchive).exists()
@@ -395,21 +395,21 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
exclude {
"*.bin"
"child/main.pkl"
"*.test.pkl"
"examples/Ex1.pkl"
"tests/**"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
exclude {
"*.bin"
"child/main.pkl"
"*.test.pkl"
"examples/Ex1.pkl"
"tests/**"
}
}
"""
.trimIndent(),
)
@@ -444,21 +444,21 @@ class CliProjectPackagerTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
}
"""
.trimIndent(),
)
@@ -489,24 +489,24 @@ class CliProjectPackagerTest {
project2Dir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
"""
.trimIndent(),
)
project2Dir.writeFile(
"PklProject.deps.json",
"""
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
"""
.trimIndent(),
)
@@ -557,18 +557,18 @@ class CliProjectPackagerTest {
assertThat(project2Metadata.readString())
.isEqualTo(
"""
{
"name": "project2",
"packageUri": "package://localhost:0/project2@5.0.0",
"version": "5.0.0",
"packageZipUrl": "https://foo.com/project2.zip",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
"dependencies": {},
"authors": []
}
"""
{
"name": "project2",
"packageUri": "package://localhost:0/project2@5.0.0",
"version": "5.0.0",
"packageZipUrl": "https://foo.com/project2.zip",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
"dependencies": {},
"authors": []
}
"""
.trimIndent()
)
}
@@ -582,44 +582,44 @@ class CliProjectPackagerTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
}
"""
.trimIndent(),
)
projectDir.writeFile(
"PklProject.deps.json",
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "0a5ad2dc13f06f73f96ba94e8d01d48252bc934e2de71a837620ca0fef8a7453"
}
},
"package://localhost:0/project2@5": {
"type": "local",
"uri": "projectpackage://localhost:0/project2@5.0.0",
"path": "../project2"
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "0a5ad2dc13f06f73f96ba94e8d01d48252bc934e2de71a837620ca0fef8a7453"
}
},
"package://localhost:0/project2@5": {
"type": "local",
"uri": "projectpackage://localhost:0/project2@5.0.0",
"path": "../project2"
}
}
}
"""
.trimIndent(),
)
@@ -627,24 +627,24 @@ class CliProjectPackagerTest {
project2Dir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
"""
.trimIndent(),
)
project2Dir.writeFile(
"PklProject.deps.json",
"""
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
"""
.trimIndent(),
)
@@ -667,23 +667,23 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"main.pkl",
"""
import "../foo.pkl"
res = foo
import "../foo.pkl"
res = foo
"""
.trimIndent(),
)
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -702,12 +702,12 @@ class CliProjectPackagerTest {
assertThat(e.message)
.startsWith(
"""
–– Pkl Error ––
Path `../foo.pkl` includes path segments that are outside the project root directory.
1 | import "../foo.pkl"
^^^^^^^^^^^^
"""
–– Pkl Error ––
Path `../foo.pkl` includes path segments that are outside the project root directory.
1 | import "../foo.pkl"
^^^^^^^^^^^^
"""
.trimIndent()
)
}
@@ -730,14 +730,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -776,14 +776,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -814,21 +814,21 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"foo/bar.pkl",
"""
import "baz.pkl"
import "baz.pkl"
"""
.trimIndent(),
)
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -849,14 +849,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"project1/PklProject",
"""
amends "pkl:Project"
package {
name = "project1"
version = "1.0.0"
baseUri = "package://example.com/project1"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "project1"
version = "1.0.0"
baseUri = "package://example.com/project1"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -864,14 +864,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"project2/PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
version = "2.0.0"
baseUri = "package://example.com/project2"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "project2"
version = "2.0.0"
baseUri = "package://example.com/project2"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -914,14 +914,14 @@ class CliProjectPackagerTest {
"project/PklProject",
// intentionally conflict with localhost:0/birds@0.5.0 from our test fixtures
"""
amends "pkl:Project"
package {
name = "birds"
version = "0.5.0"
baseUri = "package://localhost:0/birds"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "birds"
version = "0.5.0"
baseUri = "package://localhost:0/birds"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -959,14 +959,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"project/PklProject",
"""
amends "pkl:Project"
package {
name = "mangos"
version = "1.0.0"
baseUri = "package://localhost:0/mangos"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mangos"
version = "1.0.0"
baseUri = "package://localhost:0/mangos"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -1008,14 +1008,14 @@ class CliProjectPackagerTest {
@Deprecated { since = "0.26.1"; message = "do not use" }
@ModuleInfo { minPklVersion = "0.26.0" }
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
"""
.trimIndent()
)
val packager =
@@ -1033,53 +1033,53 @@ class CliProjectPackagerTest {
assertThat(expectedMetadata)
.hasContent(
"""
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
"dependencies": {},
"authors": [],
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
"dependencies": {},
"authors": [],
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
},
"properties": {
"since": "0.26.1",
"message": "do not use",
"replaceWith": null
}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "ModuleInfo",
"moduleUri": "pkl:base"
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
},
"properties": {
"since": "0.26.1",
"message": "do not use",
"replaceWith": null
}
},
"properties": {
"minPklVersion": "0.26.0"
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "ModuleInfo",
"moduleUri": "pkl:base"
},
"properties": {
"minPklVersion": "0.26.0"
}
}
}
]
}
"""
]
}
"""
.trimIndent()
)
}
@@ -74,13 +74,13 @@ class CliProjectResolverTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
.trimIndent(),
)
@@ -129,13 +129,13 @@ class CliProjectResolverTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
.trimIndent(),
)
@@ -185,35 +185,35 @@ class CliProjectResolverTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
}
"""
.trimIndent(),
)
projectDir.writeFile(
"../project2/PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/package2"
version = "5.0.0"
packageZipUrl = "https://foo.com/package2.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.0.5"
}
["project3"] = import("../project3/PklProject")
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/package2"
version = "5.0.0"
packageZipUrl = "https://foo.com/package2.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.0.5"
}
["project3"] = import("../project3/PklProject")
}
"""
.trimIndent(),
)
@@ -221,20 +221,20 @@ class CliProjectResolverTest {
projectDir.writeFile(
"../project3/PklProject",
"""
amends "pkl:Project"
package {
name = "project3"
baseUri = "package://localhost:0/package3"
version = "5.0.0"
packageZipUrl = "https://foo.com/package3.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.1.0"
}
amends "pkl:Project"
package {
name = "project3"
baseUri = "package://localhost:0/package3"
version = "5.0.0"
packageZipUrl = "https://foo.com/package3.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.1.0"
}
}
"""
.trimIndent(),
)
@@ -293,28 +293,28 @@ class CliProjectResolverTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["fruit"] = import("../fruit/PklProject")
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["fruit"] = import("../fruit/PklProject")
}
"""
.trimIndent(),
)
projectDir.writeFile(
"../fruit/PklProject",
"""
amends "pkl:Project"
package {
name = "fruit"
baseUri = "package://localhost:0/fruit"
version = "1.0.0"
packageZipUrl = "https://foo.com/fruit.zip"
}
amends "pkl:Project"
package {
name = "fruit"
baseUri = "package://localhost:0/fruit"
version = "1.0.0"
packageZipUrl = "https://foo.com/fruit.zip"
}
"""
.trimIndent(),
)
@@ -375,7 +375,7 @@ class CliProjectResolverTest {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
"""
.trimIndent(),
)
@@ -389,7 +389,7 @@ class CliProjectResolverTest {
uri = "package://localhost:0/fruit@1.1.0"
}
}
"""
"""
.trimIndent(),
)
@@ -469,14 +469,14 @@ class CliProjectResolverTest {
.resolve("PklProject")
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
}
}
"""
"""
.trimIndent()
)
// coerce an IOException by making this a directory
@@ -47,7 +47,7 @@ class CliTestRunnerTest {
3 == 3
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -65,13 +65,13 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualTo(
"""
module test
facts
✔ succeed
100.0% tests pass [1 passed], 100.0% asserts pass [2 passed]
module test
facts
✔ succeed
"""
100.0% tests pass [1 passed], 100.0% asserts pass [2 passed]
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -89,7 +89,7 @@ class CliTestRunnerTest {
1 == 5
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -136,7 +136,7 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -154,19 +154,19 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualToNormalizingNewlines(
"""
module test
facts
✘ fail
–– Pkl Error ––
uh oh
module test
facts
✘ fail
–– Pkl Error ––
uh oh
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#facts["fail"][#1] (/tempDir/test.pkl, line xx)
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#facts["fail"][#1] (/tempDir/test.pkl, line xx)
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
"""
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -183,7 +183,7 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -201,19 +201,19 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualTo(
"""
module test
examples
✘ fail
–– Pkl Error ––
uh oh
module test
examples
✘ fail
–– Pkl Error ––
uh oh
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
"""
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -232,19 +232,19 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
tempDir
.resolve("test.pkl-expected.pcf")
.writeString(
"""
examples {
["fail"] {
"never compared to"
examples {
["fail"] {
"never compared to"
}
}
}
"""
"""
.trimIndent()
)
val out = StringWriter()
@@ -262,19 +262,19 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualToNormalizingNewlines(
"""
module test
examples
✘ fail
–– Pkl Error ––
uh oh
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
module test
examples
✘ fail
–– Pkl Error ––
uh oh
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
"""
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -296,7 +296,7 @@ class CliTestRunnerTest {
5 == 9
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val noopWriter = noopWriter()
@@ -314,19 +314,19 @@ class CliTestRunnerTest {
assertThat(junitReport)
.isEqualTo(
"""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="bar">
<failure message="Fact Failure">5 == 9 (/tempDir/test.pkl, line xx)
false</failure>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="bar">
<failure message="Fact Failure">5 == 9 (/tempDir/test.pkl, line xx)
false</failure>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
"""
"""
.trimIndent()
)
}
@@ -346,7 +346,7 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val noopWriter = noopWriter()
@@ -364,23 +364,23 @@ class CliTestRunnerTest {
assertThat(junitReport)
.isEqualTo(
"""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="fail">
<error message="uh oh">–– Pkl Error ––
uh oh
9 | throw(&quot;uh oh&quot;)
^^^^^^^^^^^^^^
at test#facts[&quot;fail&quot;][#1] (/tempDir/test.pkl, line xx)
</error>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
"""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="fail">
<error message="uh oh">–– Pkl Error ––
uh oh
9 | throw(&quot;uh oh&quot;)
^^^^^^^^^^^^^^
at test#facts[&quot;fail&quot;][#1] (/tempDir/test.pkl, line xx)
</error>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
"""
.trimIndent()
)
}
@@ -390,7 +390,7 @@ class CliTestRunnerTest {
val foo =
"""
module foo
amends "pkl:test"
facts {
@@ -398,13 +398,13 @@ class CliTestRunnerTest {
1 == 1
}
}
"""
"""
.trimIndent()
val bar =
"""
module foo
amends "pkl:test"
facts {
@@ -412,7 +412,7 @@ class CliTestRunnerTest {
1 == 1
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(foo).toString()
val input2 = tempDir.resolve("test.pkl").writeString(bar).toString()
@@ -438,7 +438,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val code2 =
@@ -450,7 +450,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val input1 = tempDir.resolve("test1.pkl").writeString(code1).toString()
val input2 = tempDir.resolve("test2.pkl").writeString(code2).toString()
@@ -482,7 +482,7 @@ class CliTestRunnerTest {
5 == 9
}
}
"""
"""
.trimIndent()
val code2 =
@@ -500,7 +500,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val input1 = tempDir.resolve("test1.pkl").writeString(code1).toString()
val input2 = tempDir.resolve("test2.pkl").writeString(code2).toString()
@@ -547,7 +547,7 @@ class CliTestRunnerTest {
</testsuite>
</testsuites>
"""
"""
.trimIndent()
)
}
@@ -563,7 +563,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val code2 =
@@ -575,7 +575,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val input1 = tempDir.resolve("test1.pkl").writeString(code1).toString()
val input2 = tempDir.resolve("test2.pkl").writeString(code2).toString()
@@ -620,19 +620,19 @@ class CliTestRunnerTest {
2
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
tempDir
.resolve("test.pkl-expected.pcf")
.writeString(
"""
examples {
["nums"] {
1
examples {
["nums"] {
1
}
}
}
"""
"""
.trimIndent()
)
val out = StringWriter()
@@ -676,7 +676,7 @@ class CliTestRunnerTest {
2
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -694,13 +694,13 @@ class CliTestRunnerTest {
assertThat(out.toString())
.isEqualTo(
"""
module test
examples
✍️ nums
module test
examples
✍️ nums
1 examples written
"""
1 examples written
"""
.trimIndent()
)
}
@@ -738,13 +738,13 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualTo(
"""
module test
facts
✔ localeTest
module test
facts
✔ localeTest
100.0% tests pass [1 passed], 100.0% asserts pass [1 passed]
100.0% tests pass [1 passed], 100.0% asserts pass [1 passed]
"""
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -102,10 +102,10 @@ class PklJavaCodegenCommand : ModulesCommand(name = "pkl-codegen-java", helpLink
names = arrayOf("--non-null-annotation"),
help =
"""
Fully qualified name of the annotation type to use for annotating non-null types.
The specified annotation type must be annotated with `@java.lang.annotation.Target(ElementType.TYPE_USE)`
or the generated code may not compile.
"""
Fully qualified name of the annotation type to use for annotating non-null types.
The specified annotation type must be annotated with `@java.lang.annotation.Target(ElementType.TYPE_USE)`
or the generated code may not compile.
"""
.trimIndent(),
)
@@ -122,10 +122,10 @@ class PklJavaCodegenCommand : ModulesCommand(name = "pkl-codegen-java", helpLink
metavar = "old_name=new_name",
help =
"""
Replace a prefix in the names of the generated Java classes (repeatable).
By default, the names of generated classes are derived from the Pkl module names.
With this option, you can override or modify the default names, renaming entire
classes or just their packages.
Replace a prefix in the names of the generated Java classes (repeatable).
By default, the names of generated classes are derived from the Pkl module names.
With this option, you can override or modify the default names, renaming entire
classes or just their packages.
"""
.trimIndent(),
)
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -91,10 +91,10 @@ class PklKotlinCodegenCommand : ModulesCommand(name = "pkl-codegen-kotlin", help
metavar = "old_name=new_name",
help =
"""
Replace a prefix in the names of the generated Kotlin classes (repeatable).
By default, the names of generated classes are derived from the Pkl module names.
With this option, you can override or modify the default names, renaming entire
classes or just their packages.
Replace a prefix in the names of the generated Kotlin classes (repeatable).
By default, the names of generated classes are derived from the Pkl module names.
With this option, you can override or modify the default names, renaming entire
classes or just their packages.
"""
.trimIndent(),
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ class CliKotlinCodeGeneratorTest {
open class Mod1(
open val pigeon: Person
) {
"""
"""
.trimIndent(),
module1KotlinFile.readString(),
)
@@ -88,7 +88,7 @@ class CliKotlinCodeGeneratorTest {
pigeon: Mod1.Person,
val parrot: Mod1.Person
) : Mod1(pigeon) {
"""
"""
.trimIndent(),
module2KotlinFile.readString(),
)
File diff suppressed because it is too large Load Diff
@@ -192,10 +192,9 @@ data class CliBaseOptions(
// sort modules to make cli output independent of source module order
.sorted()
val normalizedSettingsModule: URI? =
settings?.let { uri ->
if (uri.isAbsolute) uri else IoUtils.resolve(normalizedWorkingDir.toUri(), uri)
}
val normalizedSettingsModule: URI? = settings?.let { uri ->
if (uri.isAbsolute) uri else IoUtils.resolve(normalizedWorkingDir.toUri(), uri)
}
/** [modulePath] after normalization. */
val normalizedModulePath: List<Path>? = modulePath?.map(normalizedWorkingDir::resolve)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,34 +62,34 @@ class KotlinObjectMappingTest {
val code =
"""
module KotlinGenericTypesTest
class Foo {
value: Int
}
// Sets
stringSet: Set<String> = Set("in set")
intSet: Set<Int> = Set(1,2,4,8,16,32)
booleanSetSet: Set<Set<Boolean>> = Set(Set(false), Set(true), Set(true, false))
// Lists
stringList: List<String> = List("in list")
intList: List<Int> = List(1,2,3,5,7,11)
booleanListList: List<List<Boolean>> = List(List(false), List(true), List(true, false))
// Maps
intStringMap: Map<Int, String> = Map(0, "in map")
booleanIntStringMapMap: Map<Boolean, Map<Int, String>> = Map(false, Map(0, "in map in map"))
booleanIntMapStringMap: Map<Map<Boolean, Int>, String> = Map(Map(true, 42), "in map with map keys")
// Listings
stringSetListing: Listing<Set<String>> = new { Set("in set in listing") }
intListingListing: Listing<Listing<Int>> = new { new { 1337 } new { 100 } }
// Mappings
intStringMapping: Mapping<Int, String> = new { [42] = "in map" }
stringStringSetMapping: Mapping<String, Set<String>> = new { ["key"] = Set("in set in map") }
// Map & Mappings with structured keys
intSetListStringMap: Map<List<Set<Int>>, String> = Map(List(Set(27)), "in map with structured key")
typedStringMap: Map<Foo, String> = Map(
@@ -98,7 +98,7 @@ class KotlinObjectMappingTest {
dynamicStringMap: Map<Dynamic, String> = Map(
new Dynamic { value = 42 }, "using Dynamics",
new Dynamic { hello = "world" }, "also works")
intListingStringMapping: Mapping<Listing<Int>, String> = new {
[new Listing { 42 1337 }] = "structured key works"
}
@@ -109,7 +109,7 @@ class KotlinObjectMappingTest {
thisOneGoesToEleven: Mapping<List<Set<Int>>, Map<Listing<Int>, Mapping<Int, String>>> = new {
[List(Set(0), Set(0), Set(7))] = Map(intListing, intStringMapping)
}
"""
"""
.trimIndent()
val result = ConfigEvaluator.preconfigured().forKotlin().evaluate(text(code))
assertDoesNotThrow { result.to<KotlinGenericTypesTest>() }
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,11 +48,11 @@ class AnalyzerTest {
.resolve("test.pkl")
.writeString(
"""
amends "pkl:base"
amends "pkl:base"
import "pkl:json"
import "pkl:json"
myProp = import("pkl:xml")
myProp = import("pkl:xml")
"""
.trimIndent()
)
@@ -76,7 +76,7 @@ class AnalyzerTest {
.resolve("file1.pkl")
.writeString(
"""
import* "*.pkl"
import* "*.pkl"
"""
.trimIndent()
)
@@ -143,11 +143,11 @@ class AnalyzerTest {
.resolve("PklProject")
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] { uri = "package://localhost:0/birds@0.5.0" }
}
dependencies {
["birds"] { uri = "package://localhost:0/birds@0.5.0" }
}
"""
.trimIndent()
)
@@ -155,25 +155,25 @@ class AnalyzerTest {
.resolve("PklProject.deps.json")
.writeString(
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
},
"package://localhost:0/fruit@1": {
"type": "remote",
"uri": "projectpackage://localhost:0/fruit@1.0.5",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
},
"package://localhost:0/fruit@1": {
"type": "remote",
"uri": "projectpackage://localhost:0/fruit@1.0.5",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
}
}
}
"""
.trimIndent()
)
@@ -200,7 +200,7 @@ class AnalyzerTest {
.resolve("file1.pkl")
.writeString(
"""
import "@birds/Bird.pkl"
import "@birds/Bird.pkl"
"""
.trimIndent()
)
@@ -236,11 +236,11 @@ class AnalyzerTest {
.createParentDirectories()
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] = import("../birds/PklProject")
}
dependencies {
["birds"] = import("../birds/PklProject")
}
"""
.trimIndent()
)
@@ -250,14 +250,14 @@ class AnalyzerTest {
.createParentDirectories()
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
package {
name = "birds"
version = "1.0.0"
packageZipUrl = "https://localhost:0/foo.zip"
baseUri = "package://localhost:0/birds"
}
package {
name = "birds"
version = "1.0.0"
packageZipUrl = "https://localhost:0/foo.zip"
baseUri = "package://localhost:0/birds"
}
"""
.trimIndent()
)
@@ -268,16 +268,16 @@ class AnalyzerTest {
.resolve("PklProject.deps.json")
.writeString(
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@1": {
"type": "local",
"uri": "projectpackage://localhost:0/birds@1.0.0",
"path": "../birds"
}
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@1": {
"type": "local",
"uri": "projectpackage://localhost:0/birds@1.0.0",
"path": "../birds"
}
}
}
"""
.trimIndent()
)
@@ -286,7 +286,7 @@ class AnalyzerTest {
.resolve("main.pkl")
.writeString(
"""
import "@birds/bird.pkl"
import "@birds/bird.pkl"
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +27,14 @@ class ClassInheritanceTest {
evaluator.evaluateSchema(
ModuleSource.text(
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing {}
}
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing {}
}
"""
.trimIndent()
)
)
@@ -54,14 +54,14 @@ class ClassInheritanceTest {
evaluator.evaluateSchema(
ModuleSource.text(
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing: Thing = new {}
}
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing: Thing = new {}
}
"""
.trimIndent()
)
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class EvaluateExpressionTest {
res3 = 3
res4 = 4
}
"""
"""
.trimIndent()
assertThat(evaluate(program, "res1")).isEqualTo(1L)
val res2 = evaluate(program, "res2")
@@ -59,10 +59,10 @@ class EvaluateExpressionTest {
val resp =
evaluate(
"""
foo {
bar = 2
}
"""
foo {
bar = 2
}
"""
.trimIndent(),
"foo.bar",
)
@@ -75,14 +75,14 @@ class EvaluateExpressionTest {
val result =
evaluate(
"""
foo {
bar = 2
}
output {
renderer = new YamlRenderer {}
}
"""
foo {
bar = 2
}
output {
renderer = new YamlRenderer {}
}
"""
.trimIndent(),
"output.text",
)
@@ -90,10 +90,10 @@ class EvaluateExpressionTest {
assertThat(result)
.isEqualTo(
"""
foo:
bar: 2
foo:
bar: 2
"""
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class EvaluateMultipleFileOutputTest {
}
}
}
"""
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(text(program))
assertThat(output.keys).isEqualTo(setOf("foo.yml", "bar.yml", "bar/biz.yml", "bar/../bark.yml"))
@@ -74,18 +74,18 @@ class EvaluateMultipleFileOutputTest {
}
}
}
"""
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(text(program))
assertThat(output["foo.json"]?.text)
.isEqualTo(
"""
{
"foo": "fooey",
"bar": "barrey"
}
"""
{
"foo": "fooey",
"bar": "barrey"
}
"""
.trimIndent()
)
}
@@ -106,7 +106,7 @@ class EvaluateMultipleFileOutputTest {
}
}
}
"""
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(text(program))
evaluator.close()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,9 +57,9 @@ class EvaluateSchemaTest {
evaluator.evaluateSchema(
text(
"""
class Foo {}
local class Baz {}
"""
class Foo {}
local class Baz {}
"""
.trimIndent()
)
)
@@ -36,15 +36,15 @@ class EvaluateTestsTest {
evaluator.evaluateTest(
text(
"""
amends "pkl:test"
amends "pkl:test"
facts {
["should pass"] {
1 == 1
"foo" == "foo"
}
}
"""
facts {
["should pass"] {
1 == 1
"foo" == "foo"
}
}
"""
.trimIndent()
),
true,
@@ -64,15 +64,15 @@ class EvaluateTestsTest {
evaluator.evaluateTest(
text(
"""
amends "pkl:test"
facts {
["should fail"] {
1 == 2
"foo" == "bar"
amends "pkl:test"
facts {
["should fail"] {
1 == 2
"foo" == "bar"
}
}
}
"""
"""
.trimIndent()
),
true,
@@ -91,10 +91,10 @@ class EvaluateTestsTest {
assertThat(fail1.message)
.isEqualTo(
"""
1 == 2 (repl:text)
false
"""
1 == 2 (repl:text)
false
"""
.trimIndent()
)
@@ -102,10 +102,10 @@ class EvaluateTestsTest {
assertThat(fail2.message)
.isEqualTo(
"""
"foo" == "bar" (repl:text)
false
"""
"foo" == "bar" (repl:text)
false
"""
.trimIndent()
)
}
@@ -116,15 +116,15 @@ class EvaluateTestsTest {
evaluator.evaluateTest(
text(
"""
amends "pkl:test"
facts {
["should fail"] {
1 == 2
throw("got an error")
amends "pkl:test"
facts {
["should fail"] {
1 == 2
throw("got an error")
}
}
}
"""
"""
.trimIndent()
),
true,
@@ -144,14 +144,14 @@ class EvaluateTestsTest {
assertThat(error.exception().message)
.isEqualTo(
"""
Pkl Error
got an error
Pkl Error
got an error
6 | throw("got an error")
^^^^^^^^^^^^^^^^^^^^^
at text#facts["should fail"][#2] (repl:text)
6 | throw("got an error")
^^^^^^^^^^^^^^^^^^^^^
at text#facts["should fail"][#2] (repl:text)
"""
"""
.trimIndent()
)
}
@@ -163,7 +163,7 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["user"] {
new {
@@ -172,7 +172,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -187,7 +187,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -222,7 +222,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -237,7 +237,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -275,7 +275,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -290,7 +290,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -320,7 +320,7 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["user"] {
new {
@@ -329,7 +329,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -344,7 +344,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -386,13 +386,13 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["myStr"] {
"my \"string\""
}
}
"""
"""
.trimIndent(),
)
evaluator.evaluateTest(path(file), false)
@@ -401,13 +401,13 @@ class EvaluateTestsTest {
assertThat(expectedFile)
.hasContent(
"""
examples {
["myStr"] {
#"my "string""#
examples {
["myStr"] {
#"my "string""#
}
}
}
"""
"""
.trimIndent()
)
}
@@ -420,25 +420,25 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["myStr"] {
"my \"string\""
}
}
"""
"""
.trimIndent(),
)
createExpected(file)
.writeString(
"""
examples {
["myStr"] {
"my \"string\""
examples {
["myStr"] {
"my \"string\""
}
}
}
"""
"""
.trimIndent()
)
val result = evaluator.evaluateTest(path(file), false)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ class PcfRendererTest {
corge = List(null, 1337, null, "Hello World")
grault = Map("garply", null, "waldo", 42, "pigeon", null)
}
"""
"""
.trimIndent(),
false to
"""
@@ -72,7 +72,7 @@ class PcfRendererTest {
corge = List(null, 1337, null, "Hello World")
grault = Map("garply", null, "waldo", 42, "pigeon", null)
}
"""
"""
.trimIndent(),
)
@@ -81,24 +81,24 @@ class PcfRendererTest {
.evaluate(
ModuleSource.text(
"""
foo = null
bar = null
baz {
qux = 42
quux = null
corge = new Listing {
null
1337
null
"Hello World"
}
grault = new Mapping {
["garply"] = null
["waldo"] = 42
["pigeon"] = null
}
}
"""
foo = null
bar = null
baz {
qux = 42
quux = null
corge = new Listing {
null
1337
null
"Hello World"
}
grault = new Mapping {
["garply"] = null
["waldo"] = 42
["pigeon"] = null
}
}
"""
.trimIndent()
)
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,25 +47,25 @@ class YamlRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
stream = new Listing {
new Dynamic {
name = "Pigeon"
age = 42
stream = new Listing {
new Dynamic {
name = "Pigeon"
age = 42
}
new Listing {
"one"
"two"
"three"
}
new Mapping {
["one"] = 1
["two"] = 2
["three"] = 3
}
"Blue Rock Ltd."
12345
}
new Listing {
"one"
"two"
"three"
}
new Mapping {
["one"] = 1
["two"] = 2
["three"] = 3
}
"Blue Rock Ltd."
12345
}
"""
"""
.trimIndent()
)
)
@@ -79,19 +79,19 @@ class YamlRendererTest {
assertThat(output.trim())
.isEqualTo(
"""
name: Pigeon
age: 42
---
- one
- two
- three
---
one: 1
two: 2
three: 3
--- Blue Rock Ltd.
--- 12345
"""
name: Pigeon
age: 42
---
- one
- two
- three
---
one: 1
two: 2
three: 3
--- Blue Rock Ltd.
--- 12345
"""
.trimIndent()
)
}
@@ -116,13 +116,13 @@ class YamlRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
num1 = "50"
num2 = "50.123"
`60.123` = "60.123"
yes = "yes"
truth = "true"
octalNumber = "0777"
"""
num1 = "50"
num2 = "50.123"
`60.123` = "60.123"
yes = "yes"
truth = "true"
octalNumber = "0777"
"""
.trimIndent()
)
)
@@ -136,13 +136,13 @@ class YamlRendererTest {
assertThat(output.trim())
.isEqualTo(
"""
num1: '50'
num2: '50.123'
'60.123': '60.123'
'yes': 'yes'
truth: 'true'
octalNumber: '0777'
"""
num1: '50'
num2: '50.123'
'60.123': '60.123'
'yes': 'yes'
truth: 'true'
octalNumber: '0777'
"""
.trimIndent()
)
}
@@ -154,10 +154,10 @@ class YamlRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
res1 = Bytes()
res2 = Bytes(1, 2, 3)
res3 = IntSeq(0, 127).toList().toBytes()
"""
res1 = Bytes()
res2 = Bytes(1, 2, 3)
res3 = IntSeq(0, 127).toList().toBytes()
"""
.trimIndent()
)
)
@@ -171,10 +171,10 @@ class YamlRendererTest {
assertThat(output.trim())
.isEqualTo(
"""
res1: !!binary ''
res2: !!binary 'AQID'
res3: !!binary 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8='
"""
res1: !!binary ''
res2: !!binary 'AQID'
res3: !!binary 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8='
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ class ImportsAndReadsParserTest {
}
}
}
"""
"""
.trimIndent()
val moduleKey = ModuleKeys.synthetic(URI("repl:text"), moduleText)
val imports =
@@ -70,7 +70,7 @@ class ImportsAndReadsParserTest {
fun `invalid syntax`() {
val moduleText =
"""
not valid Pkl syntax
not valid Pkl syntax
"""
.trimIndent()
val moduleKey = ModuleKeys.synthetic(URI("repl:text"), moduleText)
@@ -81,12 +81,12 @@ class ImportsAndReadsParserTest {
assertThat(err.toPklException(StackFrameTransformers.defaultTransformer, false))
.hasMessage(
"""
Pkl Error
Invalid property definition. Expected a type annotation, `=` or `{`.
1 | not valid Pkl syntax
^^^
at text (repl:text)
Pkl Error
Invalid property definition. Expected a type annotation, `=` or `{`.
1 | not valid Pkl syntax
^^^
at text (repl:text)
"""
.trimIndent()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ class TestExternalModuleReader : ExternalModuleReader {
"""
name = "Pigeon"
age = 40
"""
"""
.trimIndent()
override fun listElements(uri: URI): List<PathElement> = emptyList()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,110 +69,110 @@ class DependencyMetadataTest {
)
private val dependencyMetadataStr =
"""
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {
"foo": {
"uri": "package://example.com/foo@0.5.3",
"checksums": {
"sha256": "abc123"
}
}
},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
},
"properties": {
"since": "0.26.1",
"message": "don't use"
}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"string": "bar",
"boolean": true,
"long": 1,
"double": 1.66,
"null": null,
"list": [
"a",
"b"
],
"set": {
"type": "Set",
"value": [
"a",
"b"
]
},
"map": {
"type": "Map",
"value": [
{
"key": true,
"value": "t"
},
{
"key": false,
"value": "f"
}
]
},
"dataSize": {
"type": "DataSize",
"unit": "gb",
"value": 1.5
},
"duration": {
"type": "Duration",
"unit": "h",
"value": 2.9
},
"pair": {
"type": "Pair",
"first": 1,
"second": "1"
}
}
}
]
}
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {
"foo": {
"uri": "package://example.com/foo@0.5.3",
"checksums": {
"sha256": "abc123"
}
}
},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
},
"properties": {
"since": "0.26.1",
"message": "don't use"
}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"string": "bar",
"boolean": true,
"long": 1,
"double": 1.66,
"null": null,
"list": [
"a",
"b"
],
"set": {
"type": "Set",
"value": [
"a",
"b"
]
},
"map": {
"type": "Map",
"value": [
{
"key": true,
"value": "t"
},
{
"key": false,
"value": "f"
}
]
},
"dataSize": {
"type": "DataSize",
"unit": "gb",
"value": 1.5
},
"duration": {
"type": "Duration",
"unit": "h",
"value": 2.9
},
"pair": {
"type": "Pair",
"first": 1,
"second": "1"
}
}
}
]
}
"""
.trimIndent()
@@ -210,43 +210,43 @@ class DependencyMetadataTest {
)
val dependencyMetadataStr =
"""
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"pattern": {
"type": "Pattern",
"value": ".*"
}
}
}
]
}
"""
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"pattern": {
"type": "Pattern",
"value": ".*"
}
}
}
]
}
"""
.trimIndent()
val parsed = DependencyMetadata.parse(dependencyMetadataStr)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,13 +87,13 @@ class PackageResolversTest {
assertThat(bytes)
.isEqualTo(
"""
Bird.pkl
allFruit.pkl
catalog
catalog.pkl
some
Bird.pkl
allFruit.pkl
catalog
catalog.pkl
some
"""
"""
.trimIndent()
)
}
@@ -203,9 +203,9 @@ class PackageResolversTest {
assertThat(error)
.hasMessageContaining(
"""
Computed checksum: "a6bf858cdd1c09da475c2abe50525902580910ee5cc1ff624999170591bf8f69"
Expected checksum: "intentionally bogus checksum"
"""
Computed checksum: "a6bf858cdd1c09da475c2abe50525902580910ee5cc1ff624999170591bf8f69"
Expected checksum: "intentionally bogus checksum"
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ class ShebangTest {
"""
#!/usr/local/bin/pkl
x = 1
"""
"""
.trimIndent()
)
)
@@ -28,19 +28,19 @@ class TrailingCommasTest {
Parser()
.parseModule(
"""
class Foo<
Key,
Value,
>
class Bar<
Key,
Value,
> {
baz: Key
buzz: Value
}
"""
class Foo<
Key,
Value,
>
class Bar<
Key,
Value,
> {
baz: Key
buzz: Value
}
"""
.trimIndent()
)
@@ -63,11 +63,11 @@ class TrailingCommasTest {
Parser()
.parseModule(
"""
function foo<
A,
B,
>(a: A, b: B,): Value? = "\(a):\(b)"
"""
function foo<
A,
B,
>(a: A, b: B,): Value? = "\(a):\(b)"
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,25 +27,25 @@ import org.pkl.core.util.EconomicMaps
class ProjectDepsTest {
private val projectDepsStr =
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "package://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "abc123"
}
},
"package://localhost:0/fruit@1": {
"type": "local",
"uri": "package://localhost:0/fruit@1.1.0",
"path": "../fruit"
}
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "package://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "abc123"
}
},
"package://localhost:0/fruit@1": {
"type": "local",
"uri": "package://localhost:0/fruit@1.1.0",
"path": "../fruit"
}
"""
}
}
"""
.trimIndent()
private val projectDeps = let {
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,9 +51,9 @@ class ProjectTest {
"MIT",
"""
# Some License text
This is my license text
"""
"""
.trimIndent(),
URI("https://example.com/my/issues"),
listOf(Path.of("apiTest1.pkl"), Path.of("apiTest2.pkl")),
@@ -143,12 +143,12 @@ class ProjectTest {
exclude { "*.exe" }
issueTracker = "https://example.com/my/issues"
}
tests {
"test1.pkl"
"test2.pkl"
}
"""
"""
.trimIndent()
)
val project = Project.loadFromPath(projectPath)
@@ -167,7 +167,7 @@ class ProjectTest {
module com.apple.Foo
foo = 1
"""
"""
.trimIndent()
)
assertThatCode { Project.loadFromPath(projectPath, SecurityManagers.defaultManager, null) }
@@ -218,7 +218,7 @@ class ProjectTest {
"""
Pkl Error
Local project dependencies cannot be circular.
Cycle:
>
file:///org/pkl/core/project/projectCycle2/PklProject
@@ -240,23 +240,23 @@ class ProjectTest {
"""
Pkl Error
Local project dependencies cannot be circular.
The following circular imports were found.
Not all of them are necessarily problematic.
The problematic cycles are those declared as local dependencies.
Cycle 1:
>
file:///org/pkl/core/project/projectCycle2/PklProject
file:///org/pkl/core/project/projectCycle3/PklProject
Cycle 2:
>
file:///org/pkl/core/project/projectCycle4/PklProject
"""
.trimIndent()
)
@@ -35,14 +35,14 @@ class CommandSpecParserTest {
"""
extends "pkl:Command"
import "pkl:Command"
options: Options
output {
value = options
}
"""
"""
.trimIndent()
private val evaluator = Evaluator.preconfigured()
@@ -75,8 +75,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options = new {}
extends "pkl:Command"
options = new {}
"""
.trimIndent(),
)
@@ -92,8 +92,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options {}
extends "pkl:Command"
options {}
"""
.trimIndent(),
)
@@ -109,8 +109,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
parent = new {}
extends "pkl:Command"
parent = new {}
"""
.trimIndent(),
)
@@ -126,8 +126,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
parent {}
extends "pkl:Command"
parent {}
"""
.trimIndent(),
)
@@ -143,8 +143,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options: "nope" | "try again"
extends "pkl:Command"
options: "nope" | "try again"
"""
.trimIndent(),
)
@@ -163,9 +163,9 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options: Options
abstract class Options {}
extends "pkl:Command"
options: Options
abstract class Options {}
"""
.trimIndent(),
)
@@ -181,9 +181,9 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
command = new Foo {}
class Foo
extends "pkl:Command"
command = new Foo {}
class Foo
"""
.trimIndent(),
)
@@ -220,7 +220,7 @@ class CommandSpecParserTest {
@CountedFlag { shortName = "z" }
baz: Int
}
"""
"""
.trimIndent(),
)
@@ -258,12 +258,12 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Flag
@Argument
foo: String
}
"""
class Options {
@Flag
@Argument
foo: String
}
"""
.trimIndent(),
)
@@ -280,10 +280,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo = "bar"
}
"""
class Options {
foo = "bar"
}
"""
.trimIndent(),
)
@@ -299,10 +299,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: "oops" | String
}
"""
class Options {
foo: "oops" | String
}
"""
.trimIndent(),
)
@@ -319,11 +319,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Argument
foo: String = "bar"
}
"""
class Options {
@Argument
foo: String = "bar"
}
"""
.trimIndent(),
)
@@ -339,11 +339,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Argument
foo: String?
}
"""
class Options {
@Argument
foo: String?
}
"""
.trimIndent(),
)
@@ -367,7 +367,7 @@ class CommandSpecParserTest {
qux: Map<String, String> = baz
quux: Int = 5
}
"""
"""
.trimIndent(),
)
@@ -411,10 +411,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
help: Boolean
}
"""
class Options {
help: Boolean
}
"""
.trimIndent(),
)
@@ -430,11 +430,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Flag { shortName = "h" }
showHelp: Boolean
}
"""
class Options {
@Flag { shortName = "h" }
showHelp: Boolean
}
"""
.trimIndent(),
)
@@ -451,10 +451,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
`root-dir`: String
}
"""
class Options {
`root-dir`: String
}
"""
.trimIndent(),
)
@@ -471,13 +471,13 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Argument
list: List<String>
@Argument
set: Set<String>
}
"""
class Options {
@Argument
list: List<String>
@Argument
set: Set<String>
}
"""
.trimIndent(),
)
@@ -495,10 +495,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: List<List<"a" | "b">>
}
"""
class Options {
foo: List<List<"a" | "b">>
}
"""
.trimIndent(),
)
@@ -515,10 +515,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: List<Map<String, "a" | "b">>
}
"""
class Options {
foo: List<Map<String, "a" | "b">>
}
"""
.trimIndent(),
)
@@ -537,10 +537,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<String, List<"a" | "b">>
}
"""
class Options {
foo: Map<String, List<"a" | "b">>
}
"""
.trimIndent(),
)
@@ -557,10 +557,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<String, Map<String, "a" | "b">>
}
"""
class Options {
foo: Map<String, Map<String, "a" | "b">>
}
"""
.trimIndent(),
)
@@ -579,10 +579,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
.trimIndent(),
)
@@ -601,10 +601,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
.trimIndent(),
)
@@ -623,11 +623,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Flag { convert = (it) -> Pair("foo", "a") }
foo: Map<Map<String, "a" | "b">, String>
}
"""
class Options {
@Flag { convert = (it) -> Pair("foo", "a") }
foo: Map<Map<String, "a" | "b">, String>
}
"""
.trimIndent(),
)
@@ -641,11 +641,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Foo
}
class Foo
"""
class Options {
foo: Foo
}
class Foo
"""
.trimIndent(),
)
@@ -661,16 +661,16 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
a: String(true)
b: String?(true)
c: String(true)?
d: List<String(true)>
e: List<String(true)>(true)
f: List<String(true)>(true)?(true)
g: (Map<String(true), String(true)>(true)?(true))(true)
}
"""
class Options {
a: String(true)
b: String?(true)
c: String(true)?
d: List<String(true)>
e: List<String(true)>(true)
f: List<String(true)>(true)?(true)
g: (Map<String(true), String(true)>(true)?(true))(true)
}
"""
.trimIndent(),
)
@@ -683,17 +683,17 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
import "pkl:Command"
command {
subcommands {
new Sub { command { name = "foo" } }
new Sub { command { name = "foo" } }
extends "pkl:Command"
import "pkl:Command"
command {
subcommands {
new Sub { command { name = "foo" } }
new Sub { command { name = "foo" } }
}
}
}
class Sub extends Command
"""
class Sub extends Command
"""
.trimIndent(),
)
@@ -731,10 +731,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map
}
"""
class Options {
foo: Map
}
"""
.trimIndent(),
)
@@ -751,11 +751,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@BooleanFlag
foo: String
}
"""
class Options {
@BooleanFlag
foo: String
}
"""
.trimIndent(),
)
@@ -773,11 +773,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@CountedFlag
foo: String
}
"""
class Options {
@CountedFlag
foo: String
}
"""
.trimIndent(),
)
@@ -795,10 +795,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
format: "json" | "yaml" | "toml"
}
"""
class Options {
format: "json" | "yaml" | "toml"
}
"""
.trimIndent(),
)
@@ -822,11 +822,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
typealias OptionalString = String?
class Options {
foo: OptionalString
}
"""
typealias OptionalString = String?
class Options {
foo: OptionalString
}
"""
.trimIndent(),
)
@@ -41,8 +41,8 @@ class StackTraceRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
self: String = "Strings; if they were lazy, you could tie the knot on \(self.take(7))"
"""
self: String = "Strings; if they were lazy, you could tie the knot on \(self.take(7))"
"""
.trimIndent()
)
)
@@ -71,7 +71,7 @@ class StackTraceRendererTest {
bar: String = "BAR:" + baz
baz: String = "BAZ:" + qux
qux: String = "QUX:" + foo
"""
"""
.trimIndent()
)
)
@@ -108,35 +108,35 @@ class StackTraceRendererTest {
fun `reduce stack overflow from actual Pkl code`() {
val pklCode =
"""
function suffix(n: UInt): UInt =
if (n == 0)
0
else
suffix(n - 1)
function suffix(n: UInt): UInt =
if (n == 0)
0
else
suffix(n - 1)
function loopBody4(n: UInt): UInt =
if (n == 0)
loop()
else
loopBody1(n - 1)
function loopBody4(n: UInt): UInt =
if (n == 0)
loop()
else
loopBody1(n - 1)
function loopBody3(n: UInt) = loopBody4(n)
function loopBody2(n: UInt) = loopBody3(n)
function loopBody1(n: UInt) = loopBody2(n)
function loopBody3(n: UInt) = loopBody4(n)
function loopBody2(n: UInt) = loopBody3(n)
function loopBody1(n: UInt) = loopBody2(n)
function loop(): UInt =
if (suffix(100) > 0)
1
else
loopBody1(5)
function loop(): UInt =
if (suffix(100) > 0)
1
else
loopBody1(5)
function prefix(n: UInt): UInt =
if (n == 0)
loop()
else
prefix(n - 1)
function prefix(n: UInt): UInt =
if (n == 0)
loop()
else
prefix(n - 1)
result = prefix(13)
result = prefix(13)
"""
.trimIndent()
val message =
@@ -197,27 +197,27 @@ class StackTraceRendererTest {
assertThat(renderedFrames)
.isEqualTo(
"""
1 | foo
^
at <unknown> (file:bar)
1 | foo
^
at <unknown> (file:bar)
2 | foo
^
at <unknown> (file:baz)
2 | foo
^
at <unknown> (file:baz)
1 | foo
^
at <unknown> (file:foo)
1 | foo
^
at <unknown> (file:foo)
2 | foo
^
at <unknown> (file:foo)
2 | foo
^
at <unknown> (file:foo)
3 | foo
^
at <unknown> (file:foo)
3 | foo
^
at <unknown> (file:foo)
"""
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,15 +128,15 @@ class PklSettingsTest {
evaluator.evaluate(
ModuleSource.text(
"""
import "pkl:settings"
system = settings.System
idea = settings.Idea
textMate = settings.TextMate
sublime = settings.Sublime
atom = settings.Atom
vsCode = settings.VsCode
"""
import "pkl:settings"
system = settings.System
idea = settings.Idea
textMate = settings.TextMate
sublime = settings.Sublime
atom = settings.Atom
vsCode = settings.VsCode
"""
.trimIndent()
)
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,8 +65,8 @@ class SimpleReportTest {
val expectedOutput =
"""
0.0% tests pass [2/2 failed], 99.9% asserts pass [2/754444 failed]
"""
0.0% tests pass [2/2 failed], 99.9% asserts pass [2/754444 failed]
"""
.trimIndent()
assertThat(writer.toString().trimIndent()).isEqualTo(expectedOutput)
@@ -69,13 +69,12 @@ internal class MainPageGenerator(
private fun HtmlBlockTag.renderPackages() {
if (packagesData.isEmpty()) return
val sortedPackages =
packagesData.sortedWith { pkg1, pkg2 ->
when {
pkg1.ref.pkg == "pkl" -> -1 // always sort the stdlib first
else -> pkg1.ref.pkg.compareTo(pkg2.ref.pkg)
}
val sortedPackages = packagesData.sortedWith { pkg1, pkg2 ->
when {
pkg1.ref.pkg == "pkl" -> -1 // always sort the stdlib first
else -> pkg1.ref.pkg.compareTo(pkg2.ref.pkg)
}
}
div {
classes = setOf("member-group")
@@ -723,11 +723,13 @@ internal abstract class PageGenerator<out S>(
?.let { markdownRenderer.render(markdownParser.parse(it)).trim().ifEmpty { null } }
}
private val deprecatedAnnotation: PObject? =
annotations.find { it.classInfo == PClassInfo.Deprecated }
private val deprecatedAnnotation: PObject? = annotations.find {
it.classInfo == PClassInfo.Deprecated
}
private val alsoKnownAsAnnotation: PObject? =
annotations.find { it.classInfo == PClassInfo.AlsoKnownAs }
private val alsoKnownAsAnnotation: PObject? = annotations.find {
it.classInfo == PClassInfo.AlsoKnownAs
}
val isDeprecatedMember: Boolean = deprecatedAnnotation != null
@@ -1,5 +1,5 @@
/*
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -96,10 +96,10 @@ class DocMigratorTest {
tempDir.resolve("index.js").also { f ->
f.writeText(
"""
runtimeData.links('known-versions','[{"text":"1.2.3","classes":"current-version"}]');
runtimeData.links('known-usages','[{"text":"Foo","href":"../moduleTypes2/Foo.html"},{"text":"moduleTypes2","href":"../moduleTypes2/index.html"}]');
runtimeData.links('known-subtypes','[{"text":"Foo","href":"../moduleTypes2/Foo.html"}]');
"""
runtimeData.links('known-versions','[{"text":"1.2.3","classes":"current-version"}]');
runtimeData.links('known-usages','[{"text":"Foo","href":"../moduleTypes2/Foo.html"},{"text":"moduleTypes2","href":"../moduleTypes2/index.html"}]');
runtimeData.links('known-subtypes','[{"text":"Foo","href":"../moduleTypes2/Foo.html"}]');
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,19 +25,19 @@ class AnalyzeImportsTest : AbstractTest() {
writeFile(
"build.gradle",
"""
plugins {
id "org.pkl-lang"
}
plugins {
id "org.pkl-lang"
}
pkl {
analyzers {
imports {
analyzeMyImports {
sourceModules = ["input.pkl"]
}
pkl {
analyzers {
imports {
analyzeMyImports {
sourceModules = ["input.pkl"]
}
}
}
}
"""
.trimIndent(),
)
@@ -51,20 +51,20 @@ class AnalyzeImportsTest : AbstractTest() {
writeFile(
"build.gradle",
"""
plugins {
id "org.pkl-lang"
}
plugins {
id "org.pkl-lang"
}
pkl {
analyzers {
imports {
analyzeMyImports {
sourceModules = ["input.pkl"]
outputFile = file("myFile.pcf")
}
pkl {
analyzers {
imports {
analyzeMyImports {
sourceModules = ["input.pkl"]
outputFile = file("myFile.pcf")
}
}
}
}
"""
.trimIndent(),
)
@@ -78,20 +78,20 @@ class AnalyzeImportsTest : AbstractTest() {
writeFile(
"build.gradle",
"""
plugins {
id "org.pkl-lang"
}
plugins {
id "org.pkl-lang"
}
pkl {
analyzers {
imports {
analyzeMyImports {
sourceModules = ["input.pkl"]
outputFormat = "json"
}
pkl {
analyzers {
imports {
analyzeMyImports {
sourceModules = ["input.pkl"]
outputFormat = "json"
}
}
}
}
"""
.trimIndent(),
)
@@ -99,8 +99,8 @@ class AnalyzeImportsTest : AbstractTest() {
assertThat(result.output)
.contains(
"""
{
"imports": {
{
"imports": {
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,19 +36,19 @@ internal fun AutoCloseable.closeQuietly() {
}
}
internal val threadLocalBufferPacker: ThreadLocal<MessageBufferPacker> =
ThreadLocal.withInitial { MessagePack.newDefaultBufferPacker() }
internal val threadLocalBufferPacker: ThreadLocal<MessageBufferPacker> = ThreadLocal.withInitial {
MessagePack.newDefaultBufferPacker()
}
private val threadLocalEncoder: ThreadLocal<(Message) -> ByteArray> =
ThreadLocal.withInitial {
val packer = threadLocalBufferPacker.get()
val encoder = ServerMessagePackEncoder(packer);
{ message: Message ->
packer.clear()
encoder.encode(message)
packer.toByteArray()
}
private val threadLocalEncoder: ThreadLocal<(Message) -> ByteArray> = ThreadLocal.withInitial {
val packer = threadLocalBufferPacker.get()
val encoder = ServerMessagePackEncoder(packer);
{ message: Message ->
packer.clear()
encoder.encode(message)
packer.toByteArray()
}
}
@Suppress("unused")
internal fun encode(message: Message): ByteArray {
@@ -105,7 +105,7 @@ abstract class AbstractServerTest {
foo {
bar = "bar"
}
"""
"""
.trimIndent(),
null,
)
@@ -132,7 +132,7 @@ abstract class AbstractServerTest {
URI("repl:text"),
"""
foo = trace(1 + 2 + 3)
"""
"""
.trimIndent(),
null,
)
@@ -159,7 +159,7 @@ abstract class AbstractServerTest {
function foo() = 5
result = foo()
"""
"""
.trimIndent(),
null,
)
@@ -286,7 +286,7 @@ abstract class AbstractServerTest {
URI("repl:text"),
"""
res = read*("bird:/**.txt").keys
"""
"""
.trimIndent(),
"res",
)
@@ -315,11 +315,11 @@ abstract class AbstractServerTest {
assertThat(evaluateResponse.result?.debugRendering)
.isEqualTo(
"""
- 6
-
- 'bird:/foo.txt'
- 'bird:/subdir/bar.txt'
"""
- 6
-
- 'bird:/foo.txt'
- 'bird:/subdir/bar.txt'
"""
.trimIndent()
)
}
@@ -335,7 +335,7 @@ abstract class AbstractServerTest {
URI("repl:text"),
"""
res = read*("bird:/**.txt").keys
"""
"""
.trimIndent(),
"res",
)
@@ -371,7 +371,7 @@ abstract class AbstractServerTest {
URI("repl:text"),
"""
res = read*("bird:/**.txt").keys
"""
"""
.trimIndent(),
"res",
)
@@ -390,19 +390,19 @@ abstract class AbstractServerTest {
assertThat(evaluateResponse.error)
.isEqualTo(
"""
Pkl Error
I/O error resolving glob pattern `bird:/**.txt`.
IOException: didnt work
Pkl Error
I/O error resolving glob pattern `bird:/**.txt`.
IOException: didnt work
1 | res = read*("bird:/**.txt").keys
^^^^^^^^^^^^^^^^^^^^^
at text#res (repl:text)
1 | res = read*("bird:/**.txt").keys
^^^^^^^^^^^^^^^^^^^^^
at text#res (repl:text)
1 | res
^^^
at (repl:text)
"""
1 | res
^^^
at (repl:text)
"""
.trimIndent()
)
}
@@ -549,14 +549,14 @@ abstract class AbstractServerTest {
assertThat(evaluateResponse.result?.debugRendering)
.isEqualTo(
"""
- 6
-
- 'bird:/Person.pkl'
- 'bird:/birds/parrot.pkl'
- 'bird:/birds/pigeon.pkl'
- 'bird:/majesticBirds/barnOwl.pkl'
- 'bird:/majesticBirds/elfOwl.pkl'
"""
- 6
-
- 'bird:/Person.pkl'
- 'bird:/birds/parrot.pkl'
- 'bird:/birds/pigeon.pkl'
- 'bird:/majesticBirds/barnOwl.pkl'
- 'bird:/majesticBirds/elfOwl.pkl'
"""
.trimIndent()
)
}
@@ -582,9 +582,9 @@ abstract class AbstractServerTest {
assertThat(evaluateResponse.result?.debugRendering)
.isEqualTo(
"""
- 6
- []
"""
- 6
- []
"""
.trimIndent()
)
}
@@ -612,19 +612,19 @@ abstract class AbstractServerTest {
assertThat(evaluateResponse.error)
.isEqualTo(
"""
Pkl Error
I/O error resolving glob pattern `bird:/**.pkl`.
IOException: nope
Pkl Error
I/O error resolving glob pattern `bird:/**.pkl`.
IOException: nope
1 | res = import*("bird:/**.pkl").keys
^^^^^^^^^^^^^^^^^^^^^^^
at text#res (repl:text)
1 | res = import*("bird:/**.pkl").keys
^^^^^^^^^^^^^^^^^^^^^^^
at text#res (repl:text)
1 | res
^^^
at (repl:text)
"""
1 | res
^^^
at (repl:text)
"""
.trimIndent()
)
}
@@ -688,9 +688,9 @@ abstract class AbstractServerTest {
URI("bird:/foo/bar/baz.pkl"),
"""
import ".../buz.pkl"
res = buz.res
"""
"""
.trimIndent(),
"res",
)
@@ -747,9 +747,9 @@ abstract class AbstractServerTest {
readModuleRequest.requestId,
evaluatorId,
"""
firstName = "Pigeon"
lastName = "Bird"
fullName = firstName + " " + lastName
firstName = "Pigeon"
lastName = "Bird"
fullName = firstName + " " + lastName
"""
.trimIndent(),
null,
@@ -766,7 +766,7 @@ abstract class AbstractServerTest {
lastName = "Bird"
fullName = "Pigeon Bird"
"""
"""
.trimIndent()
)
}
@@ -788,9 +788,9 @@ abstract class AbstractServerTest {
response11.requestId,
evaluatorId,
"""
firstName = "Pigeon"
lastName = "Bird"
fullName = firstName + " " + lastName
firstName = "Pigeon"
lastName = "Bird"
fullName = firstName + " " + lastName
"""
.trimIndent(),
null,
@@ -807,7 +807,7 @@ abstract class AbstractServerTest {
lastName = "Bird"
fullName = "Pigeon Bird"
"""
"""
.trimIndent()
)
@@ -819,9 +819,9 @@ abstract class AbstractServerTest {
response21.requestId,
evaluatorId,
"""
firstName = "Parrot"
lastName = "Bird"
fullName = firstName + " " + lastName
firstName = "Parrot"
lastName = "Bird"
fullName = firstName + " " + lastName
"""
.trimIndent(),
null,
@@ -838,7 +838,7 @@ abstract class AbstractServerTest {
lastName = "Bird"
fullName = "Parrot Bird"
"""
"""
.trimIndent()
)
}
@@ -948,23 +948,23 @@ abstract class AbstractServerTest {
.resolve("lib.pkl")
.writeText(
"""
text = "This is from lib"
"""
text = "This is from lib"
"""
.trimIndent()
)
libDir
.resolve("PklProject")
.writeText(
"""
amends "pkl:Project"
package {
name = "lib"
baseUri = "package://localhost:0/lib"
version = "5.0.0"
packageZipUrl = "https://localhost:0/lib.zip"
}
"""
amends "pkl:Project"
package {
name = "lib"
baseUri = "package://localhost:0/lib"
version = "5.0.0"
packageZipUrl = "https://localhost:0/lib.zip"
}
"""
.trimIndent()
)
val projectDir = tempDir.resolve("proj/").createDirectories()
@@ -973,14 +973,14 @@ abstract class AbstractServerTest {
"""
import "@birds/Bird.pkl"
import "@lib/lib.pkl"
res: Bird = new {
name = "Birdie"
favoriteFruit { name = "dragonfruit" }
}
libContents = lib
"""
"""
.trimIndent()
)
val dollar = '$'