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