mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
Add String.toLocaleLowerCase
This commit is contained in:
parent
e7370c43cc
commit
3d883a981e
|
@ -486,9 +486,13 @@ func builtinString_localeCompare(call FunctionCall) Value {
|
|||
}
|
||||
|
||||
/*
|
||||
An alternate version
|
||||
An alternate version of String.trim
|
||||
func builtinString_trim(call FunctionCall) Value {
|
||||
checkObjectCoercible(call.This)
|
||||
return toValue_string(strings.TrimFunc(toString(call.This), isWhiteSpaceOrLineTerminator))
|
||||
}
|
||||
*/
|
||||
|
||||
func builtinString_toLocaleLowerCase(call FunctionCall) Value {
|
||||
return builtinString_toLowerCase(call)
|
||||
}
|
||||
|
|
1
inline
1
inline
|
@ -289,6 +289,7 @@ sub newContext {
|
|||
"trimLeft", 0,
|
||||
"trimRight", 0,
|
||||
"localeCompare", 1,
|
||||
"toLocaleLowerCase", 0,
|
||||
);
|
||||
return
|
||||
".${class}Prototype =",
|
||||
|
|
26
inline.go
26
inline.go
|
@ -1731,6 +1731,25 @@ func _newContext(runtime *_runtime) {
|
|||
call: _nativeCallFunction(builtinString_localeCompare),
|
||||
},
|
||||
}
|
||||
toLocaleLowerCase_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_toLocaleLowerCase),
|
||||
},
|
||||
}
|
||||
fromCharCode_function := &_object{
|
||||
runtime: runtime,
|
||||
class: "Function",
|
||||
|
@ -1905,6 +1924,13 @@ func _newContext(runtime *_runtime) {
|
|||
value: localeCompare_function,
|
||||
},
|
||||
},
|
||||
"toLocaleLowerCase": _property{
|
||||
mode: 0101,
|
||||
value: Value{
|
||||
_valueType: valueObject,
|
||||
value: toLocaleLowerCase_function,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
runtime.Global.String = &_object{
|
||||
|
|
|
@ -218,6 +218,8 @@ func TestString_toCase(t *testing.T) {
|
|||
test := runTest()
|
||||
test(`"abc".toLowerCase()`, "abc")
|
||||
test(`"ABC".toLowerCase()`, "abc")
|
||||
test(`"abc".toLocaleLowerCase()`, "abc")
|
||||
test(`"ABC".toLocaleLowerCase()`, "abc")
|
||||
test(`"abc".toUpperCase()`, "ABC")
|
||||
test(`"ABC".toUpperCase()`, "ABC")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user