Title: [129601] trunk
Revision
129601
Author
barraclo...@apple.com
Date
2012-09-26 00:20:47 -0700 (Wed, 26 Sep 2012)

Log Message

String.localeCompare should normalize input
https://bugs.webkit.org/show_bug.cgi?id=97639

Reviewed by Filip Pizlo.

>From the spec: "It is strongly recommended that this function treat Strings that are
canonically equivalent according to the Unicode standard as identical (in other words,
compare the Strings as if they had both been converted to Normalised Form C or D first).
It is also recommended that this function not honour Unicode compatibility equivalences
or decompositions."

Source/WTF: 

* wtf/unicode/icu/CollatorICU.cpp:
(WTF::Collator::createCollator):
    - Enable normalization.

LayoutTests: 

* fast/js/script-tests/string-localeCompare.js: Added.
* fast/js/string-localeCompare-expected.txt: Added.
* fast/js/string-localeCompare.html: Added.
    - Add lests for localeCompare.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129600 => 129601)


--- trunk/LayoutTests/ChangeLog	2012-09-26 07:18:16 UTC (rev 129600)
+++ trunk/LayoutTests/ChangeLog	2012-09-26 07:20:47 UTC (rev 129601)
@@ -1,3 +1,21 @@
+2012-09-26  Gavin Barraclough  <barraclo...@apple.com>
+
+        String.localeCompare should normalize input
+        https://bugs.webkit.org/show_bug.cgi?id=97639
+
+        Reviewed by Filip Pizlo.
+
+        From the spec: "It is strongly recommended that this function treat Strings that are
+        canonically equivalent according to the Unicode standard as identical (in other words,
+        compare the Strings as if they had both been converted to Normalised Form C or D first).
+        It is also recommended that this function not honour Unicode compatibility equivalences
+        or decompositions."
+
+        * fast/js/script-tests/string-localeCompare.js: Added.
+        * fast/js/string-localeCompare-expected.txt: Added.
+        * fast/js/string-localeCompare.html: Added.
+            - Add lests for localeCompare.
+
 2012-09-26  Raphael Kubo da Costa  <raphael.kubo.da.co...@intel.com>
 
         [EFL] Unskip passing test after r129592.

Added: trunk/LayoutTests/fast/js/script-tests/string-localeCompare.js (0 => 129601)


--- trunk/LayoutTests/fast/js/script-tests/string-localeCompare.js	                        (rev 0)
+++ trunk/LayoutTests/fast/js/script-tests/string-localeCompare.js	2012-09-26 07:20:47 UTC (rev 129601)
@@ -0,0 +1,10 @@
+description("This test checks String.localeCompare().");
+
+shouldBeTrue('"a".localeCompare("aa") < 0');
+shouldBeTrue('"a".localeCompare("b") < 0');
+
+shouldBeTrue('"a".localeCompare("a") === 0');
+shouldBeTrue('"a\u0308\u0323".localeCompare("a\u0323\u0308") === 0');
+
+shouldBeTrue('"aa".localeCompare("a") > 0');
+shouldBeTrue('"b".localeCompare("a") > 0');

Added: trunk/LayoutTests/fast/js/string-localeCompare-expected.txt (0 => 129601)


--- trunk/LayoutTests/fast/js/string-localeCompare-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/js/string-localeCompare-expected.txt	2012-09-26 07:20:47 UTC (rev 129601)
@@ -0,0 +1,15 @@
+This test checks String.localeCompare().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "a".localeCompare("aa") < 0 is true
+PASS "a".localeCompare("b") < 0 is true
+PASS "a".localeCompare("a") === 0 is true
+PASS "ạ̈".localeCompare("ạ̈") === 0 is true
+PASS "aa".localeCompare("a") > 0 is true
+PASS "b".localeCompare("a") > 0 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/js/string-localeCompare.html (0 => 129601)


--- trunk/LayoutTests/fast/js/string-localeCompare.html	                        (rev 0)
+++ trunk/LayoutTests/fast/js/string-localeCompare.html	2012-09-26 07:20:47 UTC (rev 129601)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WTF/ChangeLog (129600 => 129601)


--- trunk/Source/WTF/ChangeLog	2012-09-26 07:18:16 UTC (rev 129600)
+++ trunk/Source/WTF/ChangeLog	2012-09-26 07:20:47 UTC (rev 129601)
@@ -1,3 +1,20 @@
+2012-09-26  Gavin Barraclough  <barraclo...@apple.com>
+
+        String.localeCompare should normalize input
+        https://bugs.webkit.org/show_bug.cgi?id=97639
+
+        Reviewed by Filip Pizlo.
+
+        From the spec: "It is strongly recommended that this function treat Strings that are
+        canonically equivalent according to the Unicode standard as identical (in other words,
+        compare the Strings as if they had both been converted to Normalised Form C or D first).
+        It is also recommended that this function not honour Unicode compatibility equivalences
+        or decompositions."
+
+        * wtf/unicode/icu/CollatorICU.cpp:
+        (WTF::Collator::createCollator):
+            - Enable normalization.
+
 2012-09-25  Cosmin Truta  <ctr...@rim.com>
 
         [BlackBerry] Enable LLInt

Modified: trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp (129600 => 129601)


--- trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp	2012-09-26 07:18:16 UTC (rev 129600)
+++ trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp	2012-09-26 07:20:47 UTC (rev 129601)
@@ -132,6 +132,9 @@
 
     ucol_setAttribute(m_collator, UCOL_CASE_FIRST, m_lowerFirst ? UCOL_LOWER_FIRST : UCOL_UPPER_FIRST, &status);
     ASSERT(U_SUCCESS(status));
+
+    ucol_setAttribute(m_collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
+    ASSERT(U_SUCCESS(status));
 }
 
 void Collator::releaseCollator()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to