From 33672f5c98086c8406a144efe142eae7642065eb Mon Sep 17 00:00:00 2001 From: Robert Krimen Date: Sun, 14 Jul 2013 14:38:59 -0700 Subject: [PATCH] Add String.toLocaleUpperCase --- builtin_string.go | 4 ++++ inline | 1 + inline.go | 26 ++++++++++++++++++++++++++ string_test.go | 2 ++ 4 files changed, 33 insertions(+) diff --git a/builtin_string.go b/builtin_string.go index 12650e2..95ceabf 100644 --- a/builtin_string.go +++ b/builtin_string.go @@ -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) +} diff --git a/inline b/inline index 6541018..7a15191 100755 --- a/inline +++ b/inline @@ -290,6 +290,7 @@ sub newContext { "trimRight", 0, "localeCompare", 1, "toLocaleLowerCase", 0, + "toLocaleUpperCase", 0, ); return ".${class}Prototype =", diff --git a/inline.go b/inline.go index 01e5b6d..d167543 100644 --- a/inline.go +++ b/inline.go @@ -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{ diff --git a/string_test.go b/string_test.go index 13752da..0e3e9c7 100644 --- a/string_test.go +++ b/string_test.go @@ -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) {