mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-26 10:10:19 +00:00
8015352: "i".toUpperCase() => currently returns "İ", but should be "I" (with Turkish locale)
Reviewed-by: jlaskey, lagergren
This commit is contained in:
parent
1dfb4bf18e
commit
bca9af88da
@ -38,6 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import jdk.internal.dynalink.CallSiteDescriptor;
|
||||
import jdk.internal.dynalink.linker.GuardedInvocation;
|
||||
import jdk.internal.dynalink.linker.LinkRequest;
|
||||
@ -997,7 +998,7 @@ public final class NativeString extends ScriptObject {
|
||||
*/
|
||||
@Function(attributes = Attribute.NOT_ENUMERABLE)
|
||||
public static Object toLowerCase(final Object self) {
|
||||
return checkObjectToString(self).toLowerCase();
|
||||
return checkObjectToString(self).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1017,7 +1018,7 @@ public final class NativeString extends ScriptObject {
|
||||
*/
|
||||
@Function(attributes = Attribute.NOT_ENUMERABLE)
|
||||
public static Object toUpperCase(final Object self) {
|
||||
return checkObjectToString(self).toUpperCase();
|
||||
return checkObjectToString(self).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -262,14 +262,19 @@ public final class ScriptEnvironment {
|
||||
}
|
||||
this._callsite_flags = callSiteFlags;
|
||||
|
||||
final Option<?> option = options.get("timezone");
|
||||
if (option != null) {
|
||||
this._timezone = (TimeZone)option.getValue();
|
||||
final Option<?> timezoneOption = options.get("timezone");
|
||||
if (timezoneOption != null) {
|
||||
this._timezone = (TimeZone)timezoneOption.getValue();
|
||||
} else {
|
||||
this._timezone = TimeZone.getDefault();
|
||||
}
|
||||
|
||||
this._locale = Locale.getDefault();
|
||||
final Option<?> localeOption = options.get("locale");
|
||||
if (localeOption != null) {
|
||||
this._locale = (Locale)localeOption.getValue();
|
||||
} else {
|
||||
this._locale = Locale.getDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -152,6 +152,9 @@ public class OptionTemplate implements Comparable<OptionTemplate> {
|
||||
case "timezone":
|
||||
this.defaultValue = TimeZone.getDefault().getID();
|
||||
break;
|
||||
case "locale":
|
||||
this.defaultValue = Locale.getDefault().toLanguageTag();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -499,6 +499,8 @@ public final class Options {
|
||||
case "timezone":
|
||||
// default value "TimeZone.getDefault()"
|
||||
return new Option<>(TimeZone.getTimeZone(value));
|
||||
case "locale":
|
||||
return new Option<>(Locale.forLanguageTag(value));
|
||||
case "keyvalues":
|
||||
return new KeyValueOption(value);
|
||||
case "log":
|
||||
|
||||
@ -332,6 +332,15 @@ nashorn.option.timezone = { \
|
||||
type=TimeZone \
|
||||
}
|
||||
|
||||
nashorn.option.locale = { \
|
||||
name="--locale", \
|
||||
short_name="-l", \
|
||||
is_undocumented=true, \
|
||||
params="<locale>", \
|
||||
desc="Set Locale for script execution.", \
|
||||
type=Locale \
|
||||
}
|
||||
|
||||
nashorn.option.trace.callsites = { \
|
||||
name="--trace-callsites", \
|
||||
short_name="-tcs", \
|
||||
|
||||
46
nashorn/test/script/basic/JDK-8015352.js
Normal file
46
nashorn/test/script/basic/JDK-8015352.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8015352: "i".toUpperCase() => currently returns "İ", but should be "I" (with Turkish locale)
|
||||
*
|
||||
* @test
|
||||
* @option --locale=tr-TR
|
||||
* @run
|
||||
*/
|
||||
|
||||
if ("i".toUpperCase() != "I") {
|
||||
fail("'i'.toUpperCase() is not 'I'");
|
||||
}
|
||||
|
||||
if ("i".toUpperCase() == "i".toLocaleUpperCase()) {
|
||||
fail("'i'.toUpperCase() == 'i'.toLocaleUpperCase()");
|
||||
}
|
||||
|
||||
if ("I".toLowerCase() != "i") {
|
||||
fail("'I'.toLowerCase() is not 'i'");
|
||||
}
|
||||
|
||||
if ("I".toLowerCase() == "I".toLocaleLowerCase()) {
|
||||
fail("'i'.toLowerCase() == 'i'.toLocaleLowerCase()");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user