Reformat Kotlin code (#1560)

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

This PR just reformats every single Kotlin file so we don't have to deal
with this churn in future PRs that touch Kotlin code.
This commit is contained in:
Daniel Chao
2026-04-25 06:14:44 -07:00
committed by GitHub
parent c4f56bf20d
commit 2b3603b544
44 changed files with 2862 additions and 2848 deletions
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,11 +48,11 @@ class AnalyzerTest {
.resolve("test.pkl")
.writeString(
"""
amends "pkl:base"
amends "pkl:base"
import "pkl:json"
import "pkl:json"
myProp = import("pkl:xml")
myProp = import("pkl:xml")
"""
.trimIndent()
)
@@ -76,7 +76,7 @@ class AnalyzerTest {
.resolve("file1.pkl")
.writeString(
"""
import* "*.pkl"
import* "*.pkl"
"""
.trimIndent()
)
@@ -143,11 +143,11 @@ class AnalyzerTest {
.resolve("PklProject")
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] { uri = "package://localhost:0/birds@0.5.0" }
}
dependencies {
["birds"] { uri = "package://localhost:0/birds@0.5.0" }
}
"""
.trimIndent()
)
@@ -155,25 +155,25 @@ class AnalyzerTest {
.resolve("PklProject.deps.json")
.writeString(
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
},
"package://localhost:0/fruit@1": {
"type": "remote",
"uri": "projectpackage://localhost:0/fruit@1.0.5",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
},
"package://localhost:0/fruit@1": {
"type": "remote",
"uri": "projectpackage://localhost:0/fruit@1.0.5",
"checksums": {
"sha256": "${'$'}skipChecksumVerification"
}
}
}
}
"""
.trimIndent()
)
@@ -200,7 +200,7 @@ class AnalyzerTest {
.resolve("file1.pkl")
.writeString(
"""
import "@birds/Bird.pkl"
import "@birds/Bird.pkl"
"""
.trimIndent()
)
@@ -236,11 +236,11 @@ class AnalyzerTest {
.createParentDirectories()
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] = import("../birds/PklProject")
}
dependencies {
["birds"] = import("../birds/PklProject")
}
"""
.trimIndent()
)
@@ -250,14 +250,14 @@ class AnalyzerTest {
.createParentDirectories()
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
package {
name = "birds"
version = "1.0.0"
packageZipUrl = "https://localhost:0/foo.zip"
baseUri = "package://localhost:0/birds"
}
package {
name = "birds"
version = "1.0.0"
packageZipUrl = "https://localhost:0/foo.zip"
baseUri = "package://localhost:0/birds"
}
"""
.trimIndent()
)
@@ -268,16 +268,16 @@ class AnalyzerTest {
.resolve("PklProject.deps.json")
.writeString(
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@1": {
"type": "local",
"uri": "projectpackage://localhost:0/birds@1.0.0",
"path": "../birds"
}
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@1": {
"type": "local",
"uri": "projectpackage://localhost:0/birds@1.0.0",
"path": "../birds"
}
}
}
"""
.trimIndent()
)
@@ -286,7 +286,7 @@ class AnalyzerTest {
.resolve("main.pkl")
.writeString(
"""
import "@birds/bird.pkl"
import "@birds/bird.pkl"
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +27,14 @@ class ClassInheritanceTest {
evaluator.evaluateSchema(
ModuleSource.text(
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing {}
}
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing {}
}
"""
.trimIndent()
)
)
@@ -54,14 +54,14 @@ class ClassInheritanceTest {
evaluator.evaluateSchema(
ModuleSource.text(
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing: Thing = new {}
}
"""
class Thing
open class Base {
hidden thing: Thing
}
class Derived extends Base {
thing: Thing = new {}
}
"""
.trimIndent()
)
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class EvaluateExpressionTest {
res3 = 3
res4 = 4
}
"""
"""
.trimIndent()
assertThat(evaluate(program, "res1")).isEqualTo(1L)
val res2 = evaluate(program, "res2")
@@ -59,10 +59,10 @@ class EvaluateExpressionTest {
val resp =
evaluate(
"""
foo {
bar = 2
}
"""
foo {
bar = 2
}
"""
.trimIndent(),
"foo.bar",
)
@@ -75,14 +75,14 @@ class EvaluateExpressionTest {
val result =
evaluate(
"""
foo {
bar = 2
}
output {
renderer = new YamlRenderer {}
}
"""
foo {
bar = 2
}
output {
renderer = new YamlRenderer {}
}
"""
.trimIndent(),
"output.text",
)
@@ -90,10 +90,10 @@ class EvaluateExpressionTest {
assertThat(result)
.isEqualTo(
"""
foo:
bar: 2
foo:
bar: 2
"""
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class EvaluateMultipleFileOutputTest {
}
}
}
"""
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(text(program))
assertThat(output.keys).isEqualTo(setOf("foo.yml", "bar.yml", "bar/biz.yml", "bar/../bark.yml"))
@@ -74,18 +74,18 @@ class EvaluateMultipleFileOutputTest {
}
}
}
"""
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(text(program))
assertThat(output["foo.json"]?.text)
.isEqualTo(
"""
{
"foo": "fooey",
"bar": "barrey"
}
"""
{
"foo": "fooey",
"bar": "barrey"
}
"""
.trimIndent()
)
}
@@ -106,7 +106,7 @@ class EvaluateMultipleFileOutputTest {
}
}
}
"""
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(text(program))
evaluator.close()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,9 +57,9 @@ class EvaluateSchemaTest {
evaluator.evaluateSchema(
text(
"""
class Foo {}
local class Baz {}
"""
class Foo {}
local class Baz {}
"""
.trimIndent()
)
)
@@ -36,15 +36,15 @@ class EvaluateTestsTest {
evaluator.evaluateTest(
text(
"""
amends "pkl:test"
amends "pkl:test"
facts {
["should pass"] {
1 == 1
"foo" == "foo"
}
}
"""
facts {
["should pass"] {
1 == 1
"foo" == "foo"
}
}
"""
.trimIndent()
),
true,
@@ -64,15 +64,15 @@ class EvaluateTestsTest {
evaluator.evaluateTest(
text(
"""
amends "pkl:test"
facts {
["should fail"] {
1 == 2
"foo" == "bar"
amends "pkl:test"
facts {
["should fail"] {
1 == 2
"foo" == "bar"
}
}
}
"""
"""
.trimIndent()
),
true,
@@ -91,10 +91,10 @@ class EvaluateTestsTest {
assertThat(fail1.message)
.isEqualTo(
"""
1 == 2 (repl:text)
false
"""
1 == 2 (repl:text)
false
"""
.trimIndent()
)
@@ -102,10 +102,10 @@ class EvaluateTestsTest {
assertThat(fail2.message)
.isEqualTo(
"""
"foo" == "bar" (repl:text)
false
"""
"foo" == "bar" (repl:text)
false
"""
.trimIndent()
)
}
@@ -116,15 +116,15 @@ class EvaluateTestsTest {
evaluator.evaluateTest(
text(
"""
amends "pkl:test"
facts {
["should fail"] {
1 == 2
throw("got an error")
amends "pkl:test"
facts {
["should fail"] {
1 == 2
throw("got an error")
}
}
}
"""
"""
.trimIndent()
),
true,
@@ -144,14 +144,14 @@ class EvaluateTestsTest {
assertThat(error.exception().message)
.isEqualTo(
"""
–– Pkl Error ––
got an error
–– Pkl Error ––
got an error
6 | throw("got an error")
^^^^^^^^^^^^^^^^^^^^^
at text#facts["should fail"][#2] (repl:text)
6 | throw("got an error")
^^^^^^^^^^^^^^^^^^^^^
at text#facts["should fail"][#2] (repl:text)
"""
"""
.trimIndent()
)
}
@@ -163,7 +163,7 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["user"] {
new {
@@ -172,7 +172,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -187,7 +187,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -222,7 +222,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -237,7 +237,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -275,7 +275,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -290,7 +290,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -320,7 +320,7 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["user"] {
new {
@@ -329,7 +329,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -344,7 +344,7 @@ class EvaluateTestsTest {
}
}
}
"""
"""
.trimIndent(),
)
@@ -386,13 +386,13 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["myStr"] {
"my \"string\""
}
}
"""
"""
.trimIndent(),
)
evaluator.evaluateTest(path(file), false)
@@ -401,13 +401,13 @@ class EvaluateTestsTest {
assertThat(expectedFile)
.hasContent(
"""
examples {
["myStr"] {
#"my "string""#
examples {
["myStr"] {
#"my "string""#
}
}
}
"""
"""
.trimIndent()
)
}
@@ -420,25 +420,25 @@ class EvaluateTestsTest {
file,
"""
amends "pkl:test"
examples {
["myStr"] {
"my \"string\""
}
}
"""
"""
.trimIndent(),
)
createExpected(file)
.writeString(
"""
examples {
["myStr"] {
"my \"string\""
examples {
["myStr"] {
"my \"string\""
}
}
}
"""
"""
.trimIndent()
)
val result = evaluator.evaluateTest(path(file), false)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ class PcfRendererTest {
corge = List(null, 1337, null, "Hello World")
grault = Map("garply", null, "waldo", 42, "pigeon", null)
}
"""
"""
.trimIndent(),
false to
"""
@@ -72,7 +72,7 @@ class PcfRendererTest {
corge = List(null, 1337, null, "Hello World")
grault = Map("garply", null, "waldo", 42, "pigeon", null)
}
"""
"""
.trimIndent(),
)
@@ -81,24 +81,24 @@ class PcfRendererTest {
.evaluate(
ModuleSource.text(
"""
foo = null
bar = null
baz {
qux = 42
quux = null
corge = new Listing {
null
1337
null
"Hello World"
}
grault = new Mapping {
["garply"] = null
["waldo"] = 42
["pigeon"] = null
}
}
"""
foo = null
bar = null
baz {
qux = 42
quux = null
corge = new Listing {
null
1337
null
"Hello World"
}
grault = new Mapping {
["garply"] = null
["waldo"] = 42
["pigeon"] = null
}
}
"""
.trimIndent()
)
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,25 +47,25 @@ class YamlRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
stream = new Listing {
new Dynamic {
name = "Pigeon"
age = 42
stream = new Listing {
new Dynamic {
name = "Pigeon"
age = 42
}
new Listing {
"one"
"two"
"three"
}
new Mapping {
["one"] = 1
["two"] = 2
["three"] = 3
}
"Blue Rock Ltd."
12345
}
new Listing {
"one"
"two"
"three"
}
new Mapping {
["one"] = 1
["two"] = 2
["three"] = 3
}
"Blue Rock Ltd."
12345
}
"""
"""
.trimIndent()
)
)
@@ -79,19 +79,19 @@ class YamlRendererTest {
assertThat(output.trim())
.isEqualTo(
"""
name: Pigeon
age: 42
---
- one
- two
- three
---
one: 1
two: 2
three: 3
--- Blue Rock Ltd.
--- 12345
"""
name: Pigeon
age: 42
---
- one
- two
- three
---
one: 1
two: 2
three: 3
--- Blue Rock Ltd.
--- 12345
"""
.trimIndent()
)
}
@@ -116,13 +116,13 @@ class YamlRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
num1 = "50"
num2 = "50.123"
`60.123` = "60.123"
yes = "yes"
truth = "true"
octalNumber = "0777"
"""
num1 = "50"
num2 = "50.123"
`60.123` = "60.123"
yes = "yes"
truth = "true"
octalNumber = "0777"
"""
.trimIndent()
)
)
@@ -136,13 +136,13 @@ class YamlRendererTest {
assertThat(output.trim())
.isEqualTo(
"""
num1: '50'
num2: '50.123'
'60.123': '60.123'
'yes': 'yes'
truth: 'true'
octalNumber: '0777'
"""
num1: '50'
num2: '50.123'
'60.123': '60.123'
'yes': 'yes'
truth: 'true'
octalNumber: '0777'
"""
.trimIndent()
)
}
@@ -154,10 +154,10 @@ class YamlRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
res1 = Bytes()
res2 = Bytes(1, 2, 3)
res3 = IntSeq(0, 127).toList().toBytes()
"""
res1 = Bytes()
res2 = Bytes(1, 2, 3)
res3 = IntSeq(0, 127).toList().toBytes()
"""
.trimIndent()
)
)
@@ -171,10 +171,10 @@ class YamlRendererTest {
assertThat(output.trim())
.isEqualTo(
"""
res1: !!binary ''
res2: !!binary 'AQID'
res3: !!binary 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8='
"""
res1: !!binary ''
res2: !!binary 'AQID'
res3: !!binary 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn8='
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ class ImportsAndReadsParserTest {
}
}
}
"""
"""
.trimIndent()
val moduleKey = ModuleKeys.synthetic(URI("repl:text"), moduleText)
val imports =
@@ -70,7 +70,7 @@ class ImportsAndReadsParserTest {
fun `invalid syntax`() {
val moduleText =
"""
not valid Pkl syntax
not valid Pkl syntax
"""
.trimIndent()
val moduleKey = ModuleKeys.synthetic(URI("repl:text"), moduleText)
@@ -81,12 +81,12 @@ class ImportsAndReadsParserTest {
assertThat(err.toPklException(StackFrameTransformers.defaultTransformer, false))
.hasMessage(
"""
–– Pkl Error ––
Invalid property definition. Expected a type annotation, `=` or `{`.
1 | not valid Pkl syntax
^^^
at text (repl:text)
–– Pkl Error ––
Invalid property definition. Expected a type annotation, `=` or `{`.
1 | not valid Pkl syntax
^^^
at text (repl:text)
"""
.trimIndent()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ class TestExternalModuleReader : ExternalModuleReader {
"""
name = "Pigeon"
age = 40
"""
"""
.trimIndent()
override fun listElements(uri: URI): List<PathElement> = emptyList()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,110 +69,110 @@ class DependencyMetadataTest {
)
private val dependencyMetadataStr =
"""
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {
"foo": {
"uri": "package://example.com/foo@0.5.3",
"checksums": {
"sha256": "abc123"
}
}
},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
},
"properties": {
"since": "0.26.1",
"message": "don't use"
}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"string": "bar",
"boolean": true,
"long": 1,
"double": 1.66,
"null": null,
"list": [
"a",
"b"
],
"set": {
"type": "Set",
"value": [
"a",
"b"
]
},
"map": {
"type": "Map",
"value": [
{
"key": true,
"value": "t"
},
{
"key": false,
"value": "f"
}
]
},
"dataSize": {
"type": "DataSize",
"unit": "gb",
"value": 1.5
},
"duration": {
"type": "Duration",
"unit": "h",
"value": 2.9
},
"pair": {
"type": "Pair",
"first": 1,
"second": "1"
}
}
}
]
}
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {
"foo": {
"uri": "package://example.com/foo@0.5.3",
"checksums": {
"sha256": "abc123"
}
}
},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
},
"properties": {
"since": "0.26.1",
"message": "don't use"
}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"string": "bar",
"boolean": true,
"long": 1,
"double": 1.66,
"null": null,
"list": [
"a",
"b"
],
"set": {
"type": "Set",
"value": [
"a",
"b"
]
},
"map": {
"type": "Map",
"value": [
{
"key": true,
"value": "t"
},
{
"key": false,
"value": "f"
}
]
},
"dataSize": {
"type": "DataSize",
"unit": "gb",
"value": 1.5
},
"duration": {
"type": "Duration",
"unit": "h",
"value": 2.9
},
"pair": {
"type": "Pair",
"first": 1,
"second": "1"
}
}
}
]
}
"""
.trimIndent()
@@ -210,43 +210,43 @@ class DependencyMetadataTest {
)
val dependencyMetadataStr =
"""
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"pattern": {
"type": "Pattern",
"value": ".*"
}
}
}
]
}
"""
{
"name": "my-proj-name",
"packageUri": "package://example.com/my-proj-name@0.10.0",
"version": "0.10.0",
"packageZipUrl": "https://example.com/foo/bar@0.5.3.zip",
"packageZipChecksums": {
"sha256": "abc123"
},
"dependencies": {},
"sourceCodeUrlScheme": "https://example.com/my/source/0.5.3/blob%{path}#L%{line}-L%{endLine}",
"sourceCode": "https://example.com/my/source",
"documentation": "https://example.com/my/docs",
"license": "MIT",
"licenseText": "The MIT License, you know it",
"authors": [
"birdy@bird.com"
],
"issueTracker": "https://example.com/issues",
"description": "Some package description",
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "myModule",
"class": "MyAnnotation",
"moduleUri": "pkl:fake"
},
"properties": {
"pattern": {
"type": "Pattern",
"value": ".*"
}
}
}
]
}
"""
.trimIndent()
val parsed = DependencyMetadata.parse(dependencyMetadataStr)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,13 +87,13 @@ class PackageResolversTest {
assertThat(bytes)
.isEqualTo(
"""
Bird.pkl
allFruit.pkl
catalog
catalog.pkl
some
Bird.pkl
allFruit.pkl
catalog
catalog.pkl
some
"""
"""
.trimIndent()
)
}
@@ -203,9 +203,9 @@ class PackageResolversTest {
assertThat(error)
.hasMessageContaining(
"""
Computed checksum: "a6bf858cdd1c09da475c2abe50525902580910ee5cc1ff624999170591bf8f69"
Expected checksum: "intentionally bogus checksum"
"""
Computed checksum: "a6bf858cdd1c09da475c2abe50525902580910ee5cc1ff624999170591bf8f69"
Expected checksum: "intentionally bogus checksum"
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ class ShebangTest {
"""
#!/usr/local/bin/pkl
x = 1
"""
"""
.trimIndent()
)
)
@@ -28,19 +28,19 @@ class TrailingCommasTest {
Parser()
.parseModule(
"""
class Foo<
Key,
Value,
>
class Bar<
Key,
Value,
> {
baz: Key
buzz: Value
}
"""
class Foo<
Key,
Value,
>
class Bar<
Key,
Value,
> {
baz: Key
buzz: Value
}
"""
.trimIndent()
)
@@ -63,11 +63,11 @@ class TrailingCommasTest {
Parser()
.parseModule(
"""
function foo<
A,
B,
>(a: A, b: B,): Value? = "\(a):\(b)"
"""
function foo<
A,
B,
>(a: A, b: B,): Value? = "\(a):\(b)"
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,25 +27,25 @@ import org.pkl.core.util.EconomicMaps
class ProjectDepsTest {
private val projectDepsStr =
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "package://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "abc123"
}
},
"package://localhost:0/fruit@1": {
"type": "local",
"uri": "package://localhost:0/fruit@1.1.0",
"path": "../fruit"
}
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "package://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "abc123"
}
},
"package://localhost:0/fruit@1": {
"type": "local",
"uri": "package://localhost:0/fruit@1.1.0",
"path": "../fruit"
}
"""
}
}
"""
.trimIndent()
private val projectDeps = let {
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,9 +51,9 @@ class ProjectTest {
"MIT",
"""
# Some License text
This is my license text
"""
"""
.trimIndent(),
URI("https://example.com/my/issues"),
listOf(Path.of("apiTest1.pkl"), Path.of("apiTest2.pkl")),
@@ -143,12 +143,12 @@ class ProjectTest {
exclude { "*.exe" }
issueTracker = "https://example.com/my/issues"
}
tests {
"test1.pkl"
"test2.pkl"
}
"""
"""
.trimIndent()
)
val project = Project.loadFromPath(projectPath)
@@ -167,7 +167,7 @@ class ProjectTest {
module com.apple.Foo
foo = 1
"""
"""
.trimIndent()
)
assertThatCode { Project.loadFromPath(projectPath, SecurityManagers.defaultManager, null) }
@@ -218,7 +218,7 @@ class ProjectTest {
"""
–– Pkl Error ––
Local project dependencies cannot be circular.
Cycle:
┌─>
│ file:///org/pkl/core/project/projectCycle2/PklProject
@@ -240,23 +240,23 @@ class ProjectTest {
"""
–– Pkl Error ––
Local project dependencies cannot be circular.
The following circular imports were found.
Not all of them are necessarily problematic.
The problematic cycles are those declared as local dependencies.
Cycle 1:
┌─>
│ file:///org/pkl/core/project/projectCycle2/PklProject
│ file:///org/pkl/core/project/projectCycle3/PklProject
└─
Cycle 2:
┌─>
│ file:///org/pkl/core/project/projectCycle4/PklProject
└─
"""
.trimIndent()
)
@@ -35,14 +35,14 @@ class CommandSpecParserTest {
"""
extends "pkl:Command"
import "pkl:Command"
options: Options
output {
value = options
}
"""
"""
.trimIndent()
private val evaluator = Evaluator.preconfigured()
@@ -75,8 +75,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options = new {}
extends "pkl:Command"
options = new {}
"""
.trimIndent(),
)
@@ -92,8 +92,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options {}
extends "pkl:Command"
options {}
"""
.trimIndent(),
)
@@ -109,8 +109,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
parent = new {}
extends "pkl:Command"
parent = new {}
"""
.trimIndent(),
)
@@ -126,8 +126,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
parent {}
extends "pkl:Command"
parent {}
"""
.trimIndent(),
)
@@ -143,8 +143,8 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options: "nope" | "try again"
extends "pkl:Command"
options: "nope" | "try again"
"""
.trimIndent(),
)
@@ -163,9 +163,9 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
options: Options
abstract class Options {}
extends "pkl:Command"
options: Options
abstract class Options {}
"""
.trimIndent(),
)
@@ -181,9 +181,9 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
command = new Foo {}
class Foo
extends "pkl:Command"
command = new Foo {}
class Foo
"""
.trimIndent(),
)
@@ -220,7 +220,7 @@ class CommandSpecParserTest {
@CountedFlag { shortName = "z" }
baz: Int
}
"""
"""
.trimIndent(),
)
@@ -258,12 +258,12 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Flag
@Argument
foo: String
}
"""
class Options {
@Flag
@Argument
foo: String
}
"""
.trimIndent(),
)
@@ -280,10 +280,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo = "bar"
}
"""
class Options {
foo = "bar"
}
"""
.trimIndent(),
)
@@ -299,10 +299,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: "oops" | String
}
"""
class Options {
foo: "oops" | String
}
"""
.trimIndent(),
)
@@ -319,11 +319,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Argument
foo: String = "bar"
}
"""
class Options {
@Argument
foo: String = "bar"
}
"""
.trimIndent(),
)
@@ -339,11 +339,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Argument
foo: String?
}
"""
class Options {
@Argument
foo: String?
}
"""
.trimIndent(),
)
@@ -367,7 +367,7 @@ class CommandSpecParserTest {
qux: Map<String, String> = baz
quux: Int = 5
}
"""
"""
.trimIndent(),
)
@@ -411,10 +411,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
help: Boolean
}
"""
class Options {
help: Boolean
}
"""
.trimIndent(),
)
@@ -430,11 +430,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Flag { shortName = "h" }
showHelp: Boolean
}
"""
class Options {
@Flag { shortName = "h" }
showHelp: Boolean
}
"""
.trimIndent(),
)
@@ -451,10 +451,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
`root-dir`: String
}
"""
class Options {
`root-dir`: String
}
"""
.trimIndent(),
)
@@ -471,13 +471,13 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Argument
list: List<String>
@Argument
set: Set<String>
}
"""
class Options {
@Argument
list: List<String>
@Argument
set: Set<String>
}
"""
.trimIndent(),
)
@@ -495,10 +495,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: List<List<"a" | "b">>
}
"""
class Options {
foo: List<List<"a" | "b">>
}
"""
.trimIndent(),
)
@@ -515,10 +515,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: List<Map<String, "a" | "b">>
}
"""
class Options {
foo: List<Map<String, "a" | "b">>
}
"""
.trimIndent(),
)
@@ -537,10 +537,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<String, List<"a" | "b">>
}
"""
class Options {
foo: Map<String, List<"a" | "b">>
}
"""
.trimIndent(),
)
@@ -557,10 +557,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<String, Map<String, "a" | "b">>
}
"""
class Options {
foo: Map<String, Map<String, "a" | "b">>
}
"""
.trimIndent(),
)
@@ -579,10 +579,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
.trimIndent(),
)
@@ -601,10 +601,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
class Options {
foo: Map<Map<String, "a" | "b">, String>
}
"""
.trimIndent(),
)
@@ -623,11 +623,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@Flag { convert = (it) -> Pair("foo", "a") }
foo: Map<Map<String, "a" | "b">, String>
}
"""
class Options {
@Flag { convert = (it) -> Pair("foo", "a") }
foo: Map<Map<String, "a" | "b">, String>
}
"""
.trimIndent(),
)
@@ -641,11 +641,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Foo
}
class Foo
"""
class Options {
foo: Foo
}
class Foo
"""
.trimIndent(),
)
@@ -661,16 +661,16 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
a: String(true)
b: String?(true)
c: String(true)?
d: List<String(true)>
e: List<String(true)>(true)
f: List<String(true)>(true)?(true)
g: (Map<String(true), String(true)>(true)?(true))(true)
}
"""
class Options {
a: String(true)
b: String?(true)
c: String(true)?
d: List<String(true)>
e: List<String(true)>(true)
f: List<String(true)>(true)?(true)
g: (Map<String(true), String(true)>(true)?(true))(true)
}
"""
.trimIndent(),
)
@@ -683,17 +683,17 @@ class CommandSpecParserTest {
writePklFile(
"cmd.pkl",
"""
extends "pkl:Command"
import "pkl:Command"
command {
subcommands {
new Sub { command { name = "foo" } }
new Sub { command { name = "foo" } }
extends "pkl:Command"
import "pkl:Command"
command {
subcommands {
new Sub { command { name = "foo" } }
new Sub { command { name = "foo" } }
}
}
}
class Sub extends Command
"""
class Sub extends Command
"""
.trimIndent(),
)
@@ -731,10 +731,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
foo: Map
}
"""
class Options {
foo: Map
}
"""
.trimIndent(),
)
@@ -751,11 +751,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@BooleanFlag
foo: String
}
"""
class Options {
@BooleanFlag
foo: String
}
"""
.trimIndent(),
)
@@ -773,11 +773,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
@CountedFlag
foo: String
}
"""
class Options {
@CountedFlag
foo: String
}
"""
.trimIndent(),
)
@@ -795,10 +795,10 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
class Options {
format: "json" | "yaml" | "toml"
}
"""
class Options {
format: "json" | "yaml" | "toml"
}
"""
.trimIndent(),
)
@@ -822,11 +822,11 @@ class CommandSpecParserTest {
"cmd.pkl",
renderOptions +
"""
typealias OptionalString = String?
class Options {
foo: OptionalString
}
"""
typealias OptionalString = String?
class Options {
foo: OptionalString
}
"""
.trimIndent(),
)
@@ -41,8 +41,8 @@ class StackTraceRendererTest {
evaluator.evaluate(
ModuleSource.text(
"""
self: String = "Strings; if they were lazy, you could tie the knot on \(self.take(7))"
"""
self: String = "Strings; if they were lazy, you could tie the knot on \(self.take(7))"
"""
.trimIndent()
)
)
@@ -71,7 +71,7 @@ class StackTraceRendererTest {
bar: String = "BAR:" + baz
baz: String = "BAZ:" + qux
qux: String = "QUX:" + foo
"""
"""
.trimIndent()
)
)
@@ -108,35 +108,35 @@ class StackTraceRendererTest {
fun `reduce stack overflow from actual Pkl code`() {
val pklCode =
"""
function suffix(n: UInt): UInt =
if (n == 0)
0
else
suffix(n - 1)
function suffix(n: UInt): UInt =
if (n == 0)
0
else
suffix(n - 1)
function loopBody4(n: UInt): UInt =
if (n == 0)
loop()
else
loopBody1(n - 1)
function loopBody4(n: UInt): UInt =
if (n == 0)
loop()
else
loopBody1(n - 1)
function loopBody3(n: UInt) = loopBody4(n)
function loopBody2(n: UInt) = loopBody3(n)
function loopBody1(n: UInt) = loopBody2(n)
function loopBody3(n: UInt) = loopBody4(n)
function loopBody2(n: UInt) = loopBody3(n)
function loopBody1(n: UInt) = loopBody2(n)
function loop(): UInt =
if (suffix(100) > 0)
1
else
loopBody1(5)
function loop(): UInt =
if (suffix(100) > 0)
1
else
loopBody1(5)
function prefix(n: UInt): UInt =
if (n == 0)
loop()
else
prefix(n - 1)
function prefix(n: UInt): UInt =
if (n == 0)
loop()
else
prefix(n - 1)
result = prefix(13)
result = prefix(13)
"""
.trimIndent()
val message =
@@ -197,27 +197,27 @@ class StackTraceRendererTest {
assertThat(renderedFrames)
.isEqualTo(
"""
1 | foo
^
at <unknown> (file:bar)
1 | foo
^
at <unknown> (file:bar)
2 | foo
^
at <unknown> (file:baz)
2 | foo
^
at <unknown> (file:baz)
1 | foo
^
at <unknown> (file:foo)
1 | foo
^
at <unknown> (file:foo)
2 | foo
^
at <unknown> (file:foo)
2 | foo
^
at <unknown> (file:foo)
3 | foo
^
at <unknown> (file:foo)
3 | foo
^
at <unknown> (file:foo)
"""
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,15 +128,15 @@ class PklSettingsTest {
evaluator.evaluate(
ModuleSource.text(
"""
import "pkl:settings"
system = settings.System
idea = settings.Idea
textMate = settings.TextMate
sublime = settings.Sublime
atom = settings.Atom
vsCode = settings.VsCode
"""
import "pkl:settings"
system = settings.System
idea = settings.Idea
textMate = settings.TextMate
sublime = settings.Sublime
atom = settings.Atom
vsCode = settings.VsCode
"""
.trimIndent()
)
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,8 +65,8 @@ class SimpleReportTest {
val expectedOutput =
"""
0.0% tests pass [2/2 failed], 99.9% asserts pass [2/754444 failed]
"""
0.0% tests pass [2/2 failed], 99.9% asserts pass [2/754444 failed]
"""
.trimIndent()
assertThat(writer.toString().trimIndent()).isEqualTo(expectedOutput)