1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00

Add String.toLocaleUpperCase

This commit is contained in:
Robert Krimen 2013-07-14 14:38:59 -07:00
parent 3d883a981e
commit 33672f5c98
4 changed files with 33 additions and 0 deletions

View File

@ -496,3 +496,7 @@ func builtinString_trim(call FunctionCall) Value {
func builtinString_toLocaleLowerCase(call FunctionCall) Value {
return builtinString_toLowerCase(call)
}
func builtinString_toLocaleUpperCase(call FunctionCall) Value {
return builtinString_toUpperCase(call)
}

1
inline
View File

@ -290,6 +290,7 @@ sub newContext {
"trimRight", 0,
"localeCompare", 1,
"toLocaleLowerCase", 0,
"toLocaleUpperCase", 0,
);
return
".${class}Prototype =",

View File

@ -1750,6 +1750,25 @@ func _newContext(runtime *_runtime) {
call: _nativeCallFunction(builtinString_toLocaleLowerCase),
},
}
toLocaleUpperCase_function := &_object{
runtime: runtime,
class: "Function",
objectClass: _classObject,
prototype: runtime.Global.FunctionPrototype,
extensible: true,
property: map[string]_property{
"length": _property{
mode: 0,
value: Value{
_valueType: valueNumber,
value: 0,
},
},
},
value: _functionObject{
call: _nativeCallFunction(builtinString_toLocaleUpperCase),
},
}
fromCharCode_function := &_object{
runtime: runtime,
class: "Function",
@ -1931,6 +1950,13 @@ func _newContext(runtime *_runtime) {
value: toLocaleLowerCase_function,
},
},
"toLocaleUpperCase": _property{
mode: 0101,
value: Value{
_valueType: valueObject,
value: toLocaleUpperCase_function,
},
},
},
}
runtime.Global.String = &_object{

View File

@ -222,6 +222,8 @@ func TestString_toCase(t *testing.T) {
test(`"ABC".toLocaleLowerCase()`, "abc")
test(`"abc".toUpperCase()`, "ABC")
test(`"ABC".toUpperCase()`, "ABC")
test(`"abc".toLocaleUpperCase()`, "ABC")
test(`"ABC".toLocaleUpperCase()`, "ABC")
}
func Test_floatToString(t *testing.T) {