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