[PATCH] LambdaTranslationTest[1|2] may fail when executed with other locale than US (original) (raw)
Andrej Golovnin andrej.golovnin at gmail.com
Sat Jun 21 22:17:27 UTC 2014
- Previous message: RFR: 8047724: @since tag cleanup in jaxws
- Next message: RFR : 8047777: Build broken: ProcessEnvironment_md.c not compiling
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Joel,
as I already wrote [1] the tests
jdk/lambda/LambdaTranslationTest1.java jdk/lambda/LambdaTranslationTest2.java
fails when they are executed with other locale than US. The tests make use of Locale sensitive APIs and assume that the current Locale has the same formatting rules as Locale.US.
The test LambdaTranslationTest1 fails with the message:
test LambdaTranslationTest1.testMethodRefs(): failure java.lang.AssertionError: expected [d:1234.000000] but found [d:1234,000000]
The test LambdaTranslationTest2 fails with the message:
test LambdaTranslationTest2.testBoxing(): failure java.lang.AssertionError: expected [b1 s2 cA i4 j5 ztrue f6,000000 d7,000000] but found [b1 s2 cA i4 j5 ztrue f6.000000 d7.000000]
To reproduce the failure you should execute following commands in the shell (tested only on Linux):
export LANG=de_DE.utf8 export LC_PAPER=de_DE.utf8 export LC_MONETARY=de_DE.utf8 export LC_NUMERIC=de_DE.utf8 export LC_MEASUREMENT=de_DE.utf8 export LC_TIME=de_DE.utf8 make test TEST=jdk_lang
I have created patch to fix this problem. The patch is attached to this mail.
Best regards, Andrej Golovnin
[1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-June/027194.html -------------- next part -------------- diff --git a/test/jdk/lambda/LambdaTranslationTest1.java b/test/jdk/lambda/LambdaTranslationTest1.java --- a/test/jdk/lambda/LambdaTranslationTest1.java +++ b/test/jdk/lambda/LambdaTranslationTest1.java @@ -21,6 +21,7 @@
- questions. */
+import java.util.Locale; import java.util.function.Consumer;
import org.testng.annotations.Test; @@ -54,15 +55,15 @@ }
static void eye(Integer i) {
setResult(String.format("I:%d", i));
setResult(String.format(Locale.US, "I:%d", i));
}
static void ieye(int i) {
setResult(String.format("i:%d", i));
setResult(String.format(Locale.US, "i:%d", i));
}
static void deye(double d) {
setResult(String.format("d:%f", d));
setResult(String.format(Locale.US, "d:%f", d));
}
public void testLambdas() {
@@ -87,37 +88,37 @@ }
cntxt = "blah";
Consumer<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));};
Consumer<String> b4 = t -> {setResult(String.format(Locale.US, "b4: %s .. %s", cntxt, t));}; b4.accept("Yor"); assertResult("b4: blah .. Yor"); String flaw = "flaw";
Consumer<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));};
Consumer<String> b5 = t -> {setResult(String.format(Locale.US, "b5: %s .. %s", flaw, t));}; b5.accept("BB"); assertResult("b5: flaw .. BB"); cntxt = "flew";
Consumer<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));};
Consumer<String> b6 = t -> {setResult(String.format(Locale.US, "b6: %s .. %s .. %s", t, cntxt, flaw));}; b6.accept("flee"); assertResult("b6: flee .. flew .. flaw");
Consumer<String> b7 = t -> {setResult(String.format("b7: %s %s", t, this.protectedSuperclassMethod()));};
Consumer<String> b7 = t -> {setResult(String.format(Locale.US, "b7: %s %s", t, this.protectedSuperclassMethod()));}; b7.accept("this:"); assertResult("b7: this: instance:flew");
Consumer<String> b8 = t -> {setResult(String.format("b8: %s %s", t, super.protectedSuperclassMethod()));};
Consumer<String> b8 = t -> {setResult(String.format(Locale.US, "b8: %s %s", t, super.protectedSuperclassMethod()));}; b8.accept("super:"); assertResult("b8: super: I'm the sub");
Consumer<String> b7b = t -> {setResult(String.format("b9: %s %s", t, protectedSuperclassMethod()));};
Consumer<String> b7b = t -> {setResult(String.format(Locale.US, "b9: %s %s", t, protectedSuperclassMethod()));}; b7b.accept("implicit this:"); assertResult("b9: implicit this: instance:flew");
Consumer<Object> b10 = t -> {setResult(String.format("b10: new LT1Thing: %s", (new LT1Thing(t)).str));};
Consumer<Object> b10 = t -> {setResult(String.format(Locale.US, "b10: new LT1Thing: %s", (new LT1Thing(t)).str));}; b10.accept("thing"); assertResult("b10: new LT1Thing: thing");
Consumer<Object> b11 = t -> {setResult(String.format("b11: %s", (new LT1Thing(t) {
Consumer<Object> b11 = t -> {setResult(String.format(Locale.US, "b11: %s", (new LT1Thing(t) { String get() { return "*" + str.toString() + "*"; }
@@ -159,7 +160,7 @@ private int that = 1234;
void doInner() {
Consumer<String> i4 = t -> {setResult(String.format("i4: %d .. %s", that, t));};
Consumer<String> i4 = t -> {setResult(String.format(Locale.US, "i4: %d .. %s", that, t));}; i4.accept("=1234"); assertResult("i4: 1234 .. =1234");
@@ -168,7 +169,7 @@ assertResult("fruitfruit");
cntxt = "human";
Consumer<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));};
Consumer<String> b4 = t -> {setResult(String.format(Locale.US, "b4: %s .. %s", cntxt, t));}; b4.accept("bin"); assertResult("b4: human .. bin");
@@ -179,16 +180,16 @@ System.out.printf("c5: %s\n", c5.call() ); **/
Consumer<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));};
Consumer<String> b5 = t -> {setResult(String.format(Locale.US, "b5: %s .. %s", flaw, t));}; b5.accept("BB"); assertResult("b5: flaw .. BB"); cntxt = "borg";
Consumer<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));};
Consumer<String> b6 = t -> {setResult(String.format(Locale.US, "b6: %s .. %s .. %s", t, cntxt, flaw));}; b6.accept("flee"); assertResult("b6: flee .. borg .. flaw");
Consumer<String> b7b = t -> {setResult(String.format("b7b: %s %s", t, protectedSuperclassMethod()));};
Consumer<String> b7b = t -> {setResult(String.format(Locale.US, "b7b: %s %s", t, protectedSuperclassMethod()));}; b7b.accept("implicit outer this"); assertResult("b7b: implicit outer this instance:borg");
diff --git a/test/jdk/lambda/LambdaTranslationTest2.java b/test/jdk/lambda/LambdaTranslationTest2.java --- a/test/jdk/lambda/LambdaTranslationTest2.java +++ b/test/jdk/lambda/LambdaTranslationTest2.java @@ -25,6 +25,7 @@
import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.function.Function; import java.util.function.Predicate;
@@ -160,39 +161,39 @@ }
static String pb(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7) {
return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
return String.format(Locale.US, "b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
}
static String pwI1(int a0, int a1, int a2, int a3) {
return String.format("b%d s%d c%d i%d", a0, a1, a2, a3);
return String.format(Locale.US, "b%d s%d c%d i%d", a0, a1, a2, a3);
}
static String pwI2(Integer a0, Integer a1, Integer a2, Integer a3) {
return String.format("b%d s%d c%d i%d", a0, a1, a2, a3);
return String.format(Locale.US, "b%d s%d c%d i%d", a0, a1, a2, a3);
}
static String pwL1(long a0, long a1, long a2, long a3, long a4) {
return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
return String.format(Locale.US, "b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
}
static String pwL2(Long a0, Long a1, Long a2, Long a3, Long a4) {
return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
return String.format(Locale.US, "b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
}
static String pwS1(short a0, short a1) {
return String.format("b%d s%d", a0, a1);
return String.format(Locale.US, "b%d s%d", a0, a1);
}
static String pwS2(Short a0, Short a1) {
return String.format("b%d s%d", a0, a1);
return String.format(Locale.US, "b%d s%d", a0, a1);
}
static String pwD1(double a0, double a1) {
return String.format("f%f d%f", a0, a1);
return String.format(Locale.US, "f%f d%f", a0, a1);
}
static String pwD2(Double a0, Double a1) {
return String.format("f%f d%f", a0, a1);
return String.format(Locale.US, "f%f d%f", a0, a1);
}
public void testPrimitiveWidening() {
@@ -216,7 +217,7 @@ }
static String pu(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7) {
return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
return String.format(Locale.US, "b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
}
public void testUnboxing() {
- Previous message: RFR: 8047724: @since tag cleanup in jaxws
- Next message: RFR : 8047777: Build broken: ProcessEnvironment_md.c not compiling
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]