mirror of
https://github.com/apple/pkl.git
synced 2026-04-20 23:41:27 +02:00
Fix length of listings with computed index (#797)
Motivation:
The following expression evaluates to 2 instead of 1:
new Listing { "value" } { [0 + 0] = "override" }.length
Changes:
- fix length computation in EntriesLiteralNode
- improve `api/listing` tests
- make snippet test failures diffable in IntelliJ
Result:
- fixes https://github.com/apple/pkl/issues/780
- improved dev experience in IntelliJ
This commit is contained in:
@@ -19,6 +19,7 @@ import java.nio.file.Path
|
||||
import java.util.stream.Collectors
|
||||
import kotlin.io.path.*
|
||||
import org.assertj.core.api.Assertions.fail
|
||||
import org.opentest4j.AssertionFailedError
|
||||
import org.pkl.commons.*
|
||||
|
||||
object FileTestUtils {
|
||||
@@ -110,5 +111,11 @@ data class SnippetOutcome(val expectedOutFile: Path, val actual: String, val suc
|
||||
}
|
||||
|
||||
private fun failWithDiff(message: String): Nothing =
|
||||
throw PklAssertionFailedError(message, expected, actual)
|
||||
if (System.getProperty("sun.java.command", "").contains("intellij")) {
|
||||
// IntelliJ only shows diffs for AssertionFailedError
|
||||
throw AssertionFailedError(message, expected, actual)
|
||||
} else {
|
||||
// Gradle test logging/report only shows diffs for PklAssertionFailedError
|
||||
throw PklAssertionFailedError(message, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user