mirror of
https://github.com/apple/pkl.git
synced 2026-09-11 12:21:48 +02:00
Use ChoiceFormat for better plurals in error messages (#1848)
This commit is contained in:
@@ -181,7 +181,7 @@ public final class FunctionNode extends RegularMemberNode {
|
||||
assert argCount != paramCount;
|
||||
|
||||
return exceptionBuilder()
|
||||
.evalError("wrongFunctionArgumentCount", paramCount, argCount, paramCount == 1 ? "" : "s")
|
||||
.evalError("wrongFunctionArgumentCount", paramCount, argCount)
|
||||
.withSourceSection(member.getHeaderSection())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class IdentityMixinNode extends PklRootNode {
|
||||
if (arguments.length != 3) {
|
||||
CompilerDirectives.transferToInterpreter();
|
||||
throw exceptionBuilder()
|
||||
.evalError("wrongFunctionArgumentCount", 1, arguments.length - 2, "")
|
||||
.evalError("wrongFunctionArgumentCount", 1, arguments.length - 2)
|
||||
.withSourceSection(sourceSection)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ expectedModuleAsArgument=\
|
||||
Expected a module as argument, but got an object that amends a module.
|
||||
|
||||
wrongTypeArgumentCount=\
|
||||
Expected {0} type argument(s) but got {1}.
|
||||
Expected {0} type argument{0,choice,0#s|1#|1<s} but got {1}.
|
||||
|
||||
duplicateDefinition=\
|
||||
Duplicate definition of member `{0}`.
|
||||
@@ -310,7 +310,7 @@ cannotDefineExternalMember=\
|
||||
External members can only be defined by standard library modules.
|
||||
|
||||
wrongFunctionArgumentCount=\
|
||||
Expected {0} function argument{2} but got {1}.
|
||||
Expected {0} function argument{0,choice,0#s|1#|1<s} but got {1}.
|
||||
|
||||
noOuterScope=\
|
||||
Top-level scope does not have an outer scope.
|
||||
@@ -810,7 +810,7 @@ Error parsing YAML document: The number of aliases for collection nodes exceeds
|
||||
To increase the allowed maximum, set `YamlRenderer.maxCollectionAliases`.
|
||||
|
||||
evaluationTimedOut=\
|
||||
Evaluation timed out after {0,number,#.##} second(s).
|
||||
Evaluation timed out after {0,number,#.##} second{0,choice,0<s|1#|1.0<s}.
|
||||
|
||||
cannotFindStdLibModule=\
|
||||
Cannot find standard library module `pkl:{0}`.\n\
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
f = (a1, a2, a3) -> a1
|
||||
f = (a1, a2) -> a1
|
||||
res = f.applyToList(List(1, 2, 3, 4, 5, 6))
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
–– Pkl Error ––
|
||||
Expected 3 function arguments but got 6.
|
||||
Expected 2 function arguments but got 6.
|
||||
|
||||
x | f = (a1, a2, a3) -> a1
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
x | f = (a1, a2) -> a1
|
||||
^^^^^^^^^^^^^^
|
||||
at wrongArgumentListLength#f.<function#1> (file:///$snippetsDir/input/lambdas/wrongArgumentListLength.pkl)
|
||||
|
||||
x | res = f.applyToList(List(1, 2, 3, 4, 5, 6))
|
||||
|
||||
@@ -530,8 +530,27 @@ class EmbeddedExecutorTest {
|
||||
timeout(Duration.ofSeconds(1))
|
||||
}
|
||||
}
|
||||
assertThat(e.message)
|
||||
.containsAnyOf(
|
||||
"Evaluation timed out after 1 second.",
|
||||
"Evaluation timed out after 1 second(s).",
|
||||
)
|
||||
|
||||
assertThat(e.message).contains("Evaluation timed out after 1 second(s).")
|
||||
val e2 =
|
||||
assertThrows<ExecutorException> {
|
||||
executor.evaluatePath(pklFile) {
|
||||
allowedModules("file:")
|
||||
allowedResources("prop:")
|
||||
rootDir(tempDir)
|
||||
timeout(Duration.ofMillis(1500))
|
||||
}
|
||||
}
|
||||
|
||||
assertThat(e2.message)
|
||||
.containsAnyOf(
|
||||
"Evaluation timed out after 1.5 seconds.",
|
||||
"Evaluation timed out after 1.5 second(s).",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user