Title: [108252] trunk
Revision
108252
Author
msab...@apple.com
Date
2012-02-20 10:49:22 -0800 (Mon, 20 Feb 2012)

Log Message

Update toLower and toUpper tests for Unicode 6.1 changes
https://bugs.webkit.org/show_bug.cgi?id=78923

Reviewed by Oliver Hunt.

Source/_javascript_Core: 

* tests/mozilla/ecma/String/15.5.4.11-2.js: Updated the test
to handle a third set of results for updated Unicode 6.1
changes.
(getTestCases):
(TestCaseMultiExpected):
(writeTestCaseResultMultiExpected):
(getTestCaseResultMultiExpected):
(test):
(GetUnicodeValues):
(DecimalToHexString):

LayoutTests: 


* fast/js/script-tests/string-capitalization.js: Updated the test
to handle a new set of characters that have different results depending
on what version of Unicode the platform supports.  The tests work 
for Unicode 5.0 through 6.1.
(createExpected):
* fast/js/string-capitalization-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (108251 => 108252)


--- trunk/LayoutTests/ChangeLog	2012-02-20 18:46:41 UTC (rev 108251)
+++ trunk/LayoutTests/ChangeLog	2012-02-20 18:49:22 UTC (rev 108252)
@@ -1,3 +1,18 @@
+2012-02-20  Michael Saboff  <msab...@apple.com>
+
+        Update toLower and toUpper tests for Unicode 6.1 changes
+        https://bugs.webkit.org/show_bug.cgi?id=78923
+
+        Reviewed by Oliver Hunt.
+
+
+        * fast/js/script-tests/string-capitalization.js: Updated the test
+        to handle a new set of characters that have different results depending
+        on what version of Unicode the platform supports.  The tests work 
+        for Unicode 5.0 through 6.1.
+        (createExpected):
+        * fast/js/string-capitalization-expected.txt:
+
 2012-02-20  David Barton  <dbar...@mathscribe.com>
 
         MathML internals - remove nonOperatorHeight(), hasBase()

Modified: trunk/LayoutTests/fast/js/script-tests/string-capitalization.js (108251 => 108252)


--- trunk/LayoutTests/fast/js/script-tests/string-capitalization.js	2012-02-20 18:46:41 UTC (rev 108251)
+++ trunk/LayoutTests/fast/js/script-tests/string-capitalization.js	2012-02-20 18:49:22 UTC (rev 108252)
@@ -13,3 +13,60 @@
 shouldBe('String("ffi").toUpperCase()', '"FFI"');
 shouldBe('String("FFI").toLowerCase()', '"ffi"');
 shouldBe('String("IJ").toLowerCase()', '"ij"');
+
+// Test the toUpper and toLower changes made in Unicode versions 5.2 and 6.1
+// Construct the tests so that it passes if the toLowerCase()/toUpperCase()
+// either return the updated results for compliant platforms or the
+// passed in arguments if not.  This should be changed when all platforms
+// support Unicode 5.2 and Unicode 6.1.
+function createExpected(/* ... */)
+{
+    expected = {};
+
+    for (var i = 0; i < arguments.length; i++) {
+        var s = String.fromCharCode(arguments[i]);
+        expected[s] = true;
+    }
+
+    return expected;
+}
+
+// Check Unicode additions in version 5.2.  From UnicodeData.txt:
+// 0265;LATIN SMALL LETTER TURNED H;Ll;0;L;;;;;N;;;A78D;;A78D
+// A78D;LATIN CAPITAL LETTER TURNED H;Lu;0;L;;;;;N;;;;0265;
+
+var expected = createExpected(0xA78D, 0x0265);
+shouldBeTrue('expected[String.fromCharCode(0xA78D).toLowerCase()]');
+shouldBeTrue('expected[String.fromCharCode(0x0265).toUpperCase()]');
+
+// Check Unicode additions in version 6.1 From UnicodeData.txt:
+// 0266;LATIN SMALL LETTER H WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER H HOOK;;A7AA;;A7AA
+// 10C7;GEORGIAN CAPITAL LETTER YN;Lu;0;L;;;;;N;;;;2D27;
+// 10CD;GEORGIAN CAPITAL LETTER AEN;Lu;0;L;;;;;N;;;;2D2D;
+// 2CF2;COPTIC CAPITAL LETTER BOHAIRIC KHEI;Lu;0;L;;;;;N;;;;2CF3;
+// 2CF3;COPTIC SMALL LETTER BOHAIRIC KHEI;Ll;0;L;;;;;N;;;2CF2;;2CF2
+// 2D27;GEORGIAN SMALL LETTER YN;Ll;0;L;;;;;N;;;10C7;;10C7
+// 2D2D;GEORGIAN SMALL LETTER AEN;Ll;0;L;;;;;N;;;10CD;;10CD
+// A792;LATIN CAPITAL LETTER C WITH BAR;Lu;0;L;;;;;N;;;;A793;
+// A793;LATIN SMALL LETTER C WITH BAR;Ll;0;L;;;;;N;;;A792;;A792
+// A7AA;LATIN CAPITAL LETTER H WITH HOOK;Lu;0;L;;;;;N;;;;0266;
+
+var expected = createExpected(0x10C7, 0x2D27);
+shouldBeTrue('expected[String.fromCharCode(0x10C7).toLowerCase()]');
+shouldBeTrue('expected[String.fromCharCode(0x2D27).toUpperCase()]');
+
+var expected = createExpected(0x10CD, 0x2D2D);
+shouldBeTrue('expected[String.fromCharCode(0x2D2D).toLowerCase()]');
+shouldBeTrue('expected[String.fromCharCode(0x10CD).toUpperCase()]');
+
+var expected = createExpected(0x2CF2, 0x2CF3);
+shouldBeTrue('expected[String.fromCharCode(0x2CF2).toLowerCase()]');
+shouldBeTrue('expected[String.fromCharCode(0x2CF3).toUpperCase()]');
+
+var expected = createExpected(0xA792, 0xA793);
+shouldBeTrue('expected[String.fromCharCode(0xA792).toLowerCase()]');
+shouldBeTrue('expected[String.fromCharCode(0xA793).toUpperCase()]');
+
+var expected = createExpected(0xA7AA, 0x0266);
+shouldBeTrue('expected[String.fromCharCode(0xA7AA).toLowerCase()]');
+shouldBeTrue('expected[String.fromCharCode(0x0266).toUpperCase()]');

Modified: trunk/LayoutTests/fast/js/string-capitalization-expected.txt (108251 => 108252)


--- trunk/LayoutTests/fast/js/string-capitalization-expected.txt	2012-02-20 18:46:41 UTC (rev 108251)
+++ trunk/LayoutTests/fast/js/string-capitalization-expected.txt	2012-02-20 18:49:22 UTC (rev 108252)
@@ -12,6 +12,18 @@
 PASS String("ffi").toUpperCase() is "FFI"
 PASS String("FFI").toLowerCase() is "ffi"
 PASS String("IJ").toLowerCase() is "ij"
+PASS expected[String.fromCharCode(0xA78D).toLowerCase()] is true
+PASS expected[String.fromCharCode(0x0265).toUpperCase()] is true
+PASS expected[String.fromCharCode(0x10C7).toLowerCase()] is true
+PASS expected[String.fromCharCode(0x2D27).toUpperCase()] is true
+PASS expected[String.fromCharCode(0x2D2D).toLowerCase()] is true
+PASS expected[String.fromCharCode(0x10CD).toUpperCase()] is true
+PASS expected[String.fromCharCode(0x2CF2).toLowerCase()] is true
+PASS expected[String.fromCharCode(0x2CF3).toUpperCase()] is true
+PASS expected[String.fromCharCode(0xA792).toLowerCase()] is true
+PASS expected[String.fromCharCode(0xA793).toUpperCase()] is true
+PASS expected[String.fromCharCode(0xA7AA).toLowerCase()] is true
+PASS expected[String.fromCharCode(0x0266).toUpperCase()] is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/_javascript_Core/ChangeLog (108251 => 108252)


--- trunk/Source/_javascript_Core/ChangeLog	2012-02-20 18:46:41 UTC (rev 108251)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-02-20 18:49:22 UTC (rev 108252)
@@ -1,3 +1,21 @@
+2012-02-20  Michael Saboff  <msab...@apple.com>
+
+        Update toLower and toUpper tests for Unicode 6.1 changes
+        https://bugs.webkit.org/show_bug.cgi?id=78923
+
+        Reviewed by Oliver Hunt.
+
+        * tests/mozilla/ecma/String/15.5.4.11-2.js: Updated the test
+        to handle a third set of results for updated Unicode 6.1
+        changes.
+        (getTestCases):
+        (TestCaseMultiExpected):
+        (writeTestCaseResultMultiExpected):
+        (getTestCaseResultMultiExpected):
+        (test):
+        (GetUnicodeValues):
+        (DecimalToHexString):
+
 2012-02-20  Andy Wingo  <wi...@igalia.com>
 
         Remove unused features from CodeFeatures

Modified: trunk/Source/_javascript_Core/tests/mozilla/ecma/String/15.5.4.11-2.js (108251 => 108252)


--- trunk/Source/_javascript_Core/tests/mozilla/ecma/String/15.5.4.11-2.js	2012-02-20 18:46:41 UTC (rev 108251)
+++ trunk/Source/_javascript_Core/tests/mozilla/ecma/String/15.5.4.11-2.js	2012-02-20 18:49:22 UTC (rev 108252)
@@ -84,7 +84,7 @@
     // Georgian
     // Range: U+10A0 to U+10FF
     for ( var i = 0x10A0; i <= 0x10FF; i++ ) {
-        var U = new Array(new Unicode( i, 4 ), new Unicode( i, 5 ));
+        var U = new Array(new Unicode( i, 4 ), new Unicode( i, 5 ), new Unicode( i, 6.1));
 
 /*
         array[item++] = new TestCase(   SECTION,
@@ -92,7 +92,7 @@
                                         String.fromCharCode(U.lower),
                                         eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") );
 */
-        array[item++] = new TestCaseDualExpected(   SECTION,
+        array[item++] = new TestCaseMultiExpected(   SECTION,
                                         "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)",
                                         U,
                                         eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") );
@@ -106,7 +106,7 @@
  *
  */
 
-function TestCaseDualExpected( n, d, e, a ) {
+function TestCaseMultiExpected( n, d, e, a ) {
     this.name        = n;
     this.description = d;
     this.expect      = e;
@@ -115,26 +115,27 @@
     this.reason      = "";
     this.bugnumber   = BUGNUMBER;
 
-    this.passed = getTestCaseResultDualExpected( this.expect, this.actual );
+    this.passed = getTestCaseResultMultiExpected( this.expect, this.actual );
     if ( DEBUG ) {
         writeLineToLog( "added " + this.description );
     }
 }
 
 // Added so that either Unicode 4.0 or 5.0 results will be considered correct.
-function writeTestCaseResultDualExpected( expect, actual, string ) {
-        var passed = getTestCaseResultDualExpected( expect, actual );
+function writeTestCaseResultMultiExpected( expect, actual, string ) {
+        var passed = getTestCaseResultMultiExpected( expect, actual );
         writeFormattedResult( expect[1].lower, actual, string, passed );
         return passed;
 }
 /*
- * Added so that either Unicode 4.0 or 5.0 results will be considered correct.
+ * Added so that either Unicode 4.0, 5.0 or 6.1 results will be considered correct.
  * Compare expected result to the actual result and figure out whether
  * the test case passed.
  */
-function getTestCaseResultDualExpected( expect, actual ) {
+function getTestCaseResultMultiExpected( expect, actual ) {
     expectedU4 = expect[0].lower;
     expectedU5 = expect[1].lower;
+    expectedU6_1 = expect[2].lower;
     //  because ( NaN == NaN ) always returns false, need to do
     //  a special compare to see if we got the right result.
         if ( actual != actual ) {
@@ -159,22 +160,30 @@
                 expectedU5 = "NaN number";
             }
         }
+        if ( expectedU6_1 != expectedU6_1 )   {
+            if ( typeof expectedU6_1 == "object" ) {
+                expectedU6_1 = "NaN object";
+            } else {
+                expectedU6_1 = "NaN number";
+            }
+        }
 
-        var passed = ( expectedU4 == actual || expectedU5 == actual ) ? true : false;
+        var passed = ( expectedU4 == actual || expectedU5 == actual || expectedU6_1 == actual ) ? true : false;
         
         //  if both objects are numbers
         // need to replace w/ IEEE standard for rounding
         if ( !passed &&
              typeof(actual) == "number" &&
             (typeof(expectedU4) == "number" ||
-             typeof(expectedU5) == "number")) {
-            if (( Math.abs(actual-expectedU4) < 0.0000001 ) || ( Math.abs(actual-expectedU5) < 0.0000001 )) {
+             typeof(expectedU5) == "number" ||
+             typeof(expectedU6_1) == "number")) {
+            if (( Math.abs(actual-expectedU4) < 0.0000001 ) || ( Math.abs(actual-expectedU5) < 0.0000001 ) || ( Math.abs(actual-expectedU6_1) < 0.0000001 )) {
                 passed = true;
             }
         }
 
         //  verify type is the same
-        if ( typeof(expectedU4) != typeof(actual) && typeof(expectedU5) != typeof(actual) )   {
+        if ( typeof(expectedU4) != typeof(actual) && typeof(expectedU5) != typeof(actual) && typeof(expectedU6_1) != typeof(actual) )   {
             passed = false;
         }
 
@@ -183,7 +192,7 @@
 
 function test() {
     for ( tc=0; tc < testcases.length; tc++ ) {
-        testcases[tc].passed = writeTestCaseResultDualExpected(
+        testcases[tc].passed = writeTestCaseResultMultiExpected(
                             testcases[tc].expect,
                             testcases[tc].actual,
                             testcases[tc].description +" = "+ testcases[tc].actual );
@@ -438,7 +447,12 @@
 
     // Georgian
     // Range: U+10A0 to U+10F0
-    if ( version == 5 ) {
+    if ( version >= 5 ) {
+        if ( version >= 6.1 && ( c == 0x10c7 || c == 0x10cd ) ) {
+            u[0] = c;
+            u[1] = c + 7264; //48;
+            return u;
+        }
         if ( c >= 0x10A0 && c <= 0x10C5 ) {
             u[0] = c;
             u[1] = c + 7264; //48;
@@ -630,4 +644,4 @@
     }
 
     return h;
-}
\ No newline at end of file
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to