Changeset 194328 in webkit
- Timestamp:
- Dec 21, 2015 2:03:36 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r194326 r194328 1 2015-12-21 Andy VanWagoner <thetalecrafter@gmail.com> 2 3 [INTL] Implement String.prototype.localeCompare in ECMA-402 4 https://bugs.webkit.org/show_bug.cgi?id=147607 5 6 Reviewed by Darin Adler. 7 8 * js/script-tests/string-localeCompare.js: 9 * js/script-tests/string-prototype-properties.js: Update error message. 10 * js/string-localeCompare-expected.txt: 11 * js/string-prototype-properties-expected.txt: Update error message. 12 * js/string-localeCompare.html: 13 1 14 2015-12-20 Jeremy Zerfas <WebKit@JeremyZerfas.com> 2 15 -
trunk/LayoutTests/js/dom/script-tests/string-prototype-properties.js
r156066 r194328 21 21 shouldThrow("String.prototype.toLowerCase.call(undefined)"); 22 22 shouldThrow("String.prototype.toUpperCase.call(undefined)"); 23 shouldThrow("String.prototype.localeCompare.call(undefined, '1224')" );23 shouldThrow("String.prototype.localeCompare.call(undefined, '1224')", "'TypeError: String.prototype.localeCompare requires that |this| not be undefined'"); 24 24 shouldThrow("String.prototype.toLocaleLowerCase.call(undefined)"); 25 25 shouldThrow("String.prototype.toLocaleUpperCase.call(undefined)"); -
trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt
r156066 r194328 21 21 PASS String.prototype.toLowerCase.call(undefined) threw exception TypeError: Type error. 22 22 PASS String.prototype.toUpperCase.call(undefined) threw exception TypeError: Type error. 23 PASS String.prototype.localeCompare.call(undefined, '1224') threw exception TypeError: Type error.23 PASS String.prototype.localeCompare.call(undefined, '1224') threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined. 24 24 PASS String.prototype.toLocaleLowerCase.call(undefined) threw exception TypeError: Type error. 25 25 PASS String.prototype.toLocaleUpperCase.call(undefined) threw exception TypeError: Type error. -
trunk/LayoutTests/js/script-tests/string-localeCompare.js
r129601 r194328 1 description("This test checks String.localeCompare().");1 description("This test checks the behavior of String.prototype.localeCompare as described in the ECMAScript Internationalization API Specification (ECMA-402 2.0)."); 2 2 3 shouldBe("String.prototype.localeCompare.length", "1"); 4 shouldBeFalse("Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').enumerable"); 5 shouldBeTrue("Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').configurable"); 6 shouldBeTrue("Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').writable"); 7 8 // Test RequireObjectCoercible. 9 shouldThrow("String.prototype.localeCompare.call()", "'TypeError: String.prototype.localeCompare requires that |this| not be undefined'"); 10 shouldThrow("String.prototype.localeCompare.call(undefined)", "'TypeError: String.prototype.localeCompare requires that |this| not be undefined'"); 11 shouldThrow("String.prototype.localeCompare.call(null)", "'TypeError: String.prototype.localeCompare requires that |this| not be null'"); 12 shouldNotThrow("String.prototype.localeCompare.call({}, '')"); 13 shouldNotThrow("String.prototype.localeCompare.call([], '')"); 14 shouldNotThrow("String.prototype.localeCompare.call(NaN, '')"); 15 shouldNotThrow("String.prototype.localeCompare.call(5, '')"); 16 shouldNotThrow("String.prototype.localeCompare.call('', '')"); 17 shouldNotThrow("String.prototype.localeCompare.call(() => {}, '')"); 18 19 // Test toString fails. 20 shouldThrow("''.localeCompare.call({ toString() { throw 'thisFail' } }, '')", "'thisFail'"); 21 shouldThrow("''.localeCompare({ toString() { throw 'thatFail' } })", "'thatFail'"); 22 shouldNotThrow("''.localeCompare()"); 23 shouldNotThrow("''.localeCompare(null)"); 24 25 // Basic support. 3 26 shouldBeTrue('"a".localeCompare("aa") < 0'); 4 27 shouldBeTrue('"a".localeCompare("b") < 0'); … … 9 32 shouldBeTrue('"aa".localeCompare("a") > 0'); 10 33 shouldBeTrue('"b".localeCompare("a") > 0'); 34 35 // Uses Intl.Collator. 36 shouldThrow("'a'.localeCompare('b', '$')", "'RangeError: invalid language tag: $'"); 37 shouldThrow("'a'.localeCompare('b', 'en', {usage: 'Sort'})", '\'RangeError: usage must be either "sort" or "search"\''); 38 39 shouldBe("'ä'.localeCompare('z', 'en')", "-1"); 40 shouldBe("'ä'.localeCompare('z', 'sv')", "1"); 41 42 shouldBe("'a'.localeCompare('b', 'en', { sensitivity:'base' })", "-1"); 43 shouldBe("'a'.localeCompare('ä', 'en', { sensitivity:'base' })", "0"); 44 shouldBe("'a'.localeCompare('A', 'en', { sensitivity:'base' })", "0"); 45 shouldBe("'a'.localeCompare('ⓐ', 'en', { sensitivity:'base' })", "0"); 46 47 shouldBe("'a'.localeCompare('b', 'en', { sensitivity:'accent' })", "-1"); 48 shouldBe("'a'.localeCompare('ä', 'en', { sensitivity:'accent' })", "-1"); 49 shouldBe("'a'.localeCompare('A', 'en', { sensitivity:'accent' })", "0"); 50 shouldBe("'a'.localeCompare('ⓐ', 'en', { sensitivity:'accent' })", "0"); 51 52 shouldBe("'a'.localeCompare('b', 'en', { sensitivity:'case' })", "-1"); 53 shouldBe("'a'.localeCompare('ä', 'en', { sensitivity:'case' })", "0"); 54 shouldBe("'a'.localeCompare('A', 'en', { sensitivity:'case' })", "-1"); 55 shouldBe("'a'.localeCompare('ⓐ', 'en', { sensitivity:'case' })", "0"); 56 57 shouldBe("'a'.localeCompare('b', 'en', { sensitivity:'variant' })", "-1"); 58 shouldBe("'a'.localeCompare('ä', 'en', { sensitivity:'variant' })", "-1"); 59 shouldBe("'a'.localeCompare('A', 'en', { sensitivity:'variant' })", "-1"); 60 shouldBe("'a'.localeCompare('ⓐ', 'en', { sensitivity:'variant' })", "-1"); 61 62 shouldBe("'1'.localeCompare('2', 'en', { numeric:false })", "-1"); 63 shouldBe("'2'.localeCompare('10', 'en', { numeric:false })", "1"); 64 shouldBe("'01'.localeCompare('1', 'en', { numeric:false })", "-1"); 65 shouldBe("'๑'.localeCompare('๒', 'en', { numeric:false })", "-1"); 66 shouldBe("'๒'.localeCompare('๑๐', 'en', { numeric:false })", "1"); 67 shouldBe("'๐๑'.localeCompare('๑', 'en', { numeric:false })", "-1"); 68 69 shouldBe("'1'.localeCompare('2', 'en', { numeric:true })", "-1"); 70 shouldBe("'2'.localeCompare('10', 'en', { numeric:true })", "-1"); 71 shouldBe("'01'.localeCompare('1', 'en', { numeric:true })", "0"); 72 shouldBe("'๑'.localeCompare('๒', 'en', { numeric:true })", "-1"); 73 shouldBe("'๒'.localeCompare('๑๐', 'en', { numeric:true })", "-1"); 74 shouldBe("'๐๑'.localeCompare('๑', 'en', { numeric:true })", "0"); 75 -
trunk/LayoutTests/js/string-localeCompare-expected.txt
r129601 r194328 1 This test checks String.localeCompare().1 This test checks the behavior of String.prototype.localeCompare as described in the ECMAScript Internationalization API Specification (ECMA-402 2.0). 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 5 6 PASS String.prototype.localeCompare.length is 1 7 PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').enumerable is false 8 PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').configurable is true 9 PASS Object.getOwnPropertyDescriptor(String.prototype, 'localeCompare').writable is true 10 PASS String.prototype.localeCompare.call() threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined. 11 PASS String.prototype.localeCompare.call(undefined) threw exception TypeError: String.prototype.localeCompare requires that |this| not be undefined. 12 PASS String.prototype.localeCompare.call(null) threw exception TypeError: String.prototype.localeCompare requires that |this| not be null. 13 PASS String.prototype.localeCompare.call({}, '') did not throw exception. 14 PASS String.prototype.localeCompare.call([], '') did not throw exception. 15 PASS String.prototype.localeCompare.call(NaN, '') did not throw exception. 16 PASS String.prototype.localeCompare.call(5, '') did not throw exception. 17 PASS String.prototype.localeCompare.call('', '') did not throw exception. 18 PASS String.prototype.localeCompare.call(() => {}, '') did not throw exception. 19 PASS ''.localeCompare.call({ toString() { throw 'thisFail' } }, '') threw exception thisFail. 20 PASS ''.localeCompare({ toString() { throw 'thatFail' } }) threw exception thatFail. 21 PASS ''.localeCompare() did not throw exception. 22 PASS ''.localeCompare(null) did not throw exception. 6 23 PASS "a".localeCompare("aa") < 0 is true 7 24 PASS "a".localeCompare("b") < 0 is true … … 10 27 PASS "aa".localeCompare("a") > 0 is true 11 28 PASS "b".localeCompare("a") > 0 is true 29 PASS 'a'.localeCompare('b', '$') threw exception RangeError: invalid language tag: $. 30 PASS 'a'.localeCompare('b', 'en', {usage: 'Sort'}) threw exception RangeError: usage must be either "sort" or "search". 31 PASS 'ä'.localeCompare('z', 'en') is -1 32 PASS 'ä'.localeCompare('z', 'sv') is 1 33 PASS 'a'.localeCompare('b', 'en', { sensitivity:'base' }) is -1 34 PASS 'a'.localeCompare('ä', 'en', { sensitivity:'base' }) is 0 35 PASS 'a'.localeCompare('A', 'en', { sensitivity:'base' }) is 0 36 PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'base' }) is 0 37 PASS 'a'.localeCompare('b', 'en', { sensitivity:'accent' }) is -1 38 PASS 'a'.localeCompare('ä', 'en', { sensitivity:'accent' }) is -1 39 PASS 'a'.localeCompare('A', 'en', { sensitivity:'accent' }) is 0 40 PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'accent' }) is 0 41 PASS 'a'.localeCompare('b', 'en', { sensitivity:'case' }) is -1 42 PASS 'a'.localeCompare('ä', 'en', { sensitivity:'case' }) is 0 43 PASS 'a'.localeCompare('A', 'en', { sensitivity:'case' }) is -1 44 PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'case' }) is 0 45 PASS 'a'.localeCompare('b', 'en', { sensitivity:'variant' }) is -1 46 PASS 'a'.localeCompare('ä', 'en', { sensitivity:'variant' }) is -1 47 PASS 'a'.localeCompare('A', 'en', { sensitivity:'variant' }) is -1 48 PASS 'a'.localeCompare('ⓐ', 'en', { sensitivity:'variant' }) is -1 49 PASS '1'.localeCompare('2', 'en', { numeric:false }) is -1 50 PASS '2'.localeCompare('10', 'en', { numeric:false }) is 1 51 PASS '01'.localeCompare('1', 'en', { numeric:false }) is -1 52 PASS '๑'.localeCompare('๒', 'en', { numeric:false }) is -1 53 PASS '๒'.localeCompare('๑๐', 'en', { numeric:false }) is 1 54 PASS '๐๑'.localeCompare('๑', 'en', { numeric:false }) is -1 55 PASS '1'.localeCompare('2', 'en', { numeric:true }) is -1 56 PASS '2'.localeCompare('10', 'en', { numeric:true }) is -1 57 PASS '01'.localeCompare('1', 'en', { numeric:true }) is 0 58 PASS '๑'.localeCompare('๒', 'en', { numeric:true }) is -1 59 PASS '๒'.localeCompare('๑๐', 'en', { numeric:true }) is -1 60 PASS '๐๑'.localeCompare('๑', 'en', { numeric:true }) is 0 12 61 PASS successfullyParsed is true 13 62 -
trunk/LayoutTests/js/string-localeCompare.html
r155452 r194328 2 2 <html> 3 3 <head> 4 <meta charset="utf-8"> 4 5 <script src="../resources/js-test-pre.js"></script> 5 6 </head> -
trunk/Source/JavaScriptCore/CMakeLists.txt
r194294 r194328 1250 1250 ${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js 1251 1251 ${JAVASCRIPTCORE_DIR}/builtins/StringIteratorPrototype.js 1252 ${JAVASCRIPTCORE_DIR}/builtins/StringPrototype.js 1252 1253 ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayConstructor.js 1253 1254 ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayPrototype.js -
trunk/Source/JavaScriptCore/ChangeLog
r194320 r194328 1 2015-12-21 Andy VanWagoner <thetalecrafter@gmail.com> 2 3 [INTL] Implement String.prototype.localeCompare in ECMA-402 4 https://bugs.webkit.org/show_bug.cgi?id=147607 5 6 Reviewed by Darin Adler. 7 8 Add localeCompare in builtin JavaScript that delegates comparing to Intl.Collator. 9 Keep existing native implementation for use if INTL flag is disabled. 10 11 * CMakeLists.txt: 12 * DerivedSources.make: 13 * JavaScriptCore.xcodeproj/project.pbxproj: 14 * builtins/StringPrototype.js: Added. 15 (localeCompare): 16 * runtime/StringPrototype.cpp: 17 (JSC::StringPrototype::finishCreation): 18 1 19 2015-12-18 Filip Pizlo <fpizlo@apple.com> 2 20 -
trunk/Source/JavaScriptCore/DerivedSources.make
r194242 r194328 99 99 $(JavaScriptCore)/builtins/StringConstructor.js \ 100 100 $(JavaScriptCore)/builtins/StringIteratorPrototype.js \ 101 $(JavaScriptCore)/builtins/StringPrototype.js \ 101 102 $(JavaScriptCore)/builtins/TypedArrayConstructor.js \ 102 103 $(JavaScriptCore)/builtins/TypedArrayPrototype.js \ -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r194317 r194328 2055 2055 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2056 2056 FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2057 FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA1E4381C213A2600277A16 /* ValueProfile.cpp */; settings = {ASSET_TAGS = (); };};2057 FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA1E4381C213A2600277A16 /* ValueProfile.cpp */; }; 2058 2058 FEB137571BB11EF900CD5100 /* MacroAssemblerARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */; }; 2059 2059 FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; }; … … 3674 3674 A1D792FA1B43864B004516F5 /* IntlNumberFormatPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntlNumberFormatPrototype.cpp; sourceTree = "<group>"; }; 3675 3675 A1D792FB1B43864B004516F5 /* IntlNumberFormatPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlNumberFormatPrototype.h; sourceTree = "<group>"; }; 3676 A1E0451B1C25B4B100BB663C /* StringPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = StringPrototype.js; sourceTree = "<group>"; }; 3676 3677 A503FA13188E0FAF00110F14 /* JavaScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JavaScriptCallFrame.cpp; sourceTree = "<group>"; }; 3677 3678 A503FA14188E0FAF00110F14 /* JavaScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptCallFrame.h; sourceTree = "<group>"; }; … … 6767 6768 7CF9BC601B65D9B1009DB1EF /* StringConstructor.js */, 6768 6769 7CF9BC611B65D9B1009DB1EF /* StringIteratorPrototype.js */, 6770 A1E0451B1C25B4B100BB663C /* StringPrototype.js */, 6769 6771 53917E831B791CB8000EBD33 /* TypedArrayPrototype.js */, 6770 6772 534C457A1BC703DC007476A7 /* TypedArrayConstructor.js */, -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r194310 r194328 30 30 #include "Executable.h" 31 31 #include "IntlObject.h" 32 #include "JSCBuiltins.h" 32 33 #include "JSCInlines.h" 33 34 #include "JSGlobalObjectFunctions.h" … … 131 132 JSC_NATIVE_FUNCTION("toLowerCase", stringProtoFuncToLowerCase, DontEnum, 0); 132 133 JSC_NATIVE_FUNCTION("toUpperCase", stringProtoFuncToUpperCase, DontEnum, 0); 133 JSC_NATIVE_FUNCTION("localeCompare", stringProtoFuncLocaleCompare, DontEnum, 1);134 134 #if ENABLE(INTL) 135 JSC_BUILTIN_FUNCTION("localeCompare", stringPrototypeLocaleCompareCodeGenerator, DontEnum); 135 136 JSC_NATIVE_FUNCTION("toLocaleLowerCase", stringProtoFuncToLocaleLowerCase, DontEnum, 0); 136 137 JSC_NATIVE_FUNCTION("toLocaleUpperCase", stringProtoFuncToLocaleUpperCase, DontEnum, 0); 137 138 #else 139 JSC_NATIVE_FUNCTION("localeCompare", stringProtoFuncLocaleCompare, DontEnum, 1); 138 140 JSC_NATIVE_FUNCTION("toLocaleLowerCase", stringProtoFuncToLowerCase, DontEnum, 0); 139 141 JSC_NATIVE_FUNCTION("toLocaleUpperCase", stringProtoFuncToUpperCase, DontEnum, 0);
Note: See TracChangeset
for help on using the changeset viewer.