From 9d19c87e3ede843a95fbe590398aebc525818294 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Thu, 9 Aug 2012 15:02:49 -0700 Subject: Bug 610: Handle supplementary characters. --- website/harness/jquery.base64.js | 24 +++-- website/json/ch06.json | 14 +++ website/json/default.json | 3 +- website/json/suiteDescrip.json | 2 +- website/json/testcases_ch06.json | 6 ++ website/testcases_ch06.html | 183 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 225 insertions(+), 7 deletions(-) create mode 100644 website/json/ch06.json create mode 100644 website/json/testcases_ch06.json create mode 100644 website/testcases_ch06.html (limited to 'website') diff --git a/website/harness/jquery.base64.js b/website/harness/jquery.base64.js index e9168e886..9e3ff5f2e 100644 --- a/website/harness/jquery.base64.js +++ b/website/harness/jquery.base64.js @@ -70,21 +70,35 @@ var uTF8Decode = function(input) { var string = ""; var i = 0; - var c = c1 = c2 = 0; + var c = c2 = c3 = c4 = 0; while ( i < input.length ) { c = input.charCodeAt(i); - if (c < 128) { + if (c < 128) { // 1 byte encoding - ASCII only string += String.fromCharCode(c); i++; - } else if ((c > 191) && (c < 224)) { + } else if ((c >= 192) && (c < 224)) { // 2 byte encoding - max U+07FF c2 = input.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; - } else { + } else if ((c >= 224) && (c < 240)) { // 3 byte encoding - max U+FFFF c2 = input.charCodeAt(i+1); c3 = input.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; + } else if ((c >= 240) && (c < 248)){ // 4 byte encoding - max U+10FFFF. Covers all Unicode CodePoints + c2 = input.charCodeAt(i+1); + c3 = input.charCodeAt(i+2); + c4 = input.charCodeAt(i+3); + var codePoint = (((c & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)); + if (codePoint > 0x10FFFF) { + throw new SyntaxError("invalid UTF-8 code unit sequence"); + } + var highSurrogate = (((codePoint - 0x10000) & 0xFFC00) >>> 10) + 0xD800; // Minus 0x10000, then top 10 bits added to 0xD800 + var lowSurrogate = ((codePoint - 0x10000) & 0x3FF) + 0xDC00; // Minus 0x10000, then low 10 bits added to 0xDC00 + string += String.fromCharCode(highSurrogate); + string += String.fromCharCode(lowSurrogate); + i += 4; + } } return string; @@ -139,4 +153,4 @@ return output; } }); - })(jQuery); \ No newline at end of file + })(jQuery); diff --git a/website/json/ch06.json b/website/json/ch06.json new file mode 100644 index 000000000..ed975ed43 --- /dev/null +++ b/website/json/ch06.json @@ -0,0 +1,14 @@ +{ +"testsCollection":{ +"name":"Chapter - ch06", +"numTests":"1", +"tests":[ +{ +"code":"Ly8gQ29weXJpZ2h0IChjKSAyMDEyIEVjbWEgSW50ZXJuYXRpb25hbC4gIEFsbCByaWdodHMgcmVzZXJ2ZWQuIAovKioKICogQGRlc2NyaXB0aW9uIFRlc3QgZm9yIGhhbmRsaW5nIG9mIHN1cHBsZW1lbnRhcnkgY2hhcmFjdGVycwogKi8KCnZhciBjaGFycyA9ICLwkJKgIjsgIC8vIFNpbmdsZSBVbmljb2RlIGNoYXJhY3RlciBhdCBjb2RlcG9pbnQgXHV7MTA0QTB9CmlmKGNoYXJzLmxlbmd0aCAhPT0gMikgewogICAgJEVSUk9SKCJBIGNoYXJhY3RlciBvdXRzaWRlIHRoZSBCTVAgKFVuaWNvZGUgQ29kZVBvaW50ID4gMHhGRkZGKSBzaG91bGQgY29uc3VtZSB0d28gY29kZSB1bml0cyIpOwp9CmlmKGNoYXJzLmNoYXJDb2RlQXQoMCkgIT09IDB4RDgwMSkgewogICAgJEVSUk9SKCJGaXJzdCBjb2RlIHVuaXQgb2Ygc3Vycm9nYXRlIHBhaXIgZm9yIDB4MTA0QTAgc2hvdWxkIGJlIDB4RDgwMSIpOwp9CgppZihjaGFycy5jaGFyQ29kZUF0KDEpICE9PSAweERDQTApIHsKICAgICRFUlJPUigiU2Vjb25kIGNvZGUgdW5pdCBvZiBzdXJyb2dhdGUgcGFpciBmb3IgMHgxMDRBMCBzaG91bGQgYmUgMHhEQ0EwIik7Cn0K", +"commentary":"", +"description":"Test for handling of supplementary characters", +"path":"TestCases/ch06/6.1.js" +} +] +} +} \ No newline at end of file diff --git a/website/json/default.json b/website/json/default.json index 55becc96e..b4a5cf5eb 100644 --- a/website/json/default.json +++ b/website/json/default.json @@ -1,6 +1,7 @@ { -"numTests":11571, +"numTests":11572, "testSuite":[ +"json/ch06.json", "json/ch07.json", "json/ch08.json", "json/ch09.json", diff --git a/website/json/suiteDescrip.json b/website/json/suiteDescrip.json index 6a1a80bc7..ed86d69a0 100644 --- a/website/json/suiteDescrip.json +++ b/website/json/suiteDescrip.json @@ -1 +1 @@ -{"date":"2012-09-12","version":"ES5.1"} \ No newline at end of file +{"date":"2012-10-04","version":"ES5.1"} \ No newline at end of file diff --git a/website/json/testcases_ch06.json b/website/json/testcases_ch06.json new file mode 100644 index 000000000..50fcca19e --- /dev/null +++ b/website/json/testcases_ch06.json @@ -0,0 +1,6 @@ +{ +"numTests":1, +"testSuite":[ +"json/ch06.json" +] +} \ No newline at end of file diff --git a/website/testcases_ch06.html b/website/testcases_ch06.html new file mode 100644 index 000000000..101a6edb5 --- /dev/null +++ b/website/testcases_ch06.html @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + +ECMAScript Language – test262 + + + +
+ +
+
+
+ Loading... + Loading... +
+
+
+ +
+ +
+

ECMAScript Language test262 + ECMAScript.org

+
+ + +
+ +
+

What is test262?

+

test262 is a test suite intended to check agreement between JavaScript implementations and ECMA-262, the ECMAScript Language Specification (currently 5.1 Edition). + The test suite contains thousands of individual tests, each of which tests some specific requirements of the ECMAScript Language Specification.

+

What is ECMAScript?

+

"ECMAScript" is the name under which the language more commonly known as "JavaScript" is standardized. Development of the ECMAScript standard is the responsibility of Technical Committee 39 (TC39) of Ecma International. + The ECMAScript Language Specification standard is officially known as ECMA-262. + ECMAScript 5.1 (or just ES5.1) is short hand for the "ECMA-262, 5.1 Edition ECMAScript Language Specification" the official name of the current edition of the standard. + ECMAScript 5.1 was approved as an official Ecma standard by the Ecma General Assembly in June 2011. + The ECMAScript 5.1 standard is available in PDF and HTML versions from the Ecma International web site.

+

Who creates and maintains test262?

+

Development of test262 is a project of Ecma TC39. The testing framework and individual tests are created by member organizations of TC39 and contributed to Ecma for use in test262. For more information about how test262 is developed and maintained click the “Development” tab at the top of this page.

+

What is the status of test262?

+

test262 is not yet complete. It is still undergoing active development. Some portions of the ES5 specification have very complete test coverage while other portions of the specification have only partial test coverage. Some tests may be invalid or may yield false positive or false negative results. A perfect passing score on test262 does not guarantee that a JavaScript implementation perfectly supports ES5. Because tests are being actively added and modified, tests results from different days or times may not be directly comparable. Click the “Development” tab at the top of this page for instructions for reporting test262 bugs.

+

Where can I find out more?

+

Please visit our Frequently Asked Questions section on the ECMAScript Wiki.

+ +

Running the Tests

+

Click the “Run” tab at the top of this page for instructions and follow the instructions to run the tests.

+ + + +
+ +
+

Development

+

Test262 is being developed by the members of Ecma TC39. Ecma's intellectual property policies permit only Ecma + members to directly contribute code to the project. However, a public mailing list is used to coordinate development of test262. If you wish to participate in the discussion please subscribe. Bug reports and suggestions should be sent to the mailing list. +

+

+ Ecma members can find detailed instructions on Test262 development procedures at the Test262 Wiki. +

+
+ +
+ +

Please click on the Run All button to run all the tests. Once you start the test you may pause the test anytime by clicking on the Pause button. You can click on the Results tab once the test is completed or after pausing the test. The Reset button is for restarting the test run. You may run individual tests by clicking the Run button next to the tests listed below. If you wish to run several chapters in sequence, but not the entire test suite, click the Select button for the chapters you wish to run and then click the Run Selected button.

+ + +
+
+
+ + + + + Run All + Run Selected Tests + Pause + Resume + Reset +
+
+
+

+ Timer Value(ms) : +

+ + +
+ Tests To run:  | + Total tests ran: | + Pass: | + Fail: | + Failed to load: +

+
+ + +
+
+
+ + +
+
+
+
+ Test suite version:  | Test suite date: +
+
+ +
+
+
+ +
+
+
Total tests:
+ Passed: | Failed: | + Failed to load: +
+ +
+
+
Test results will be displayed after the tests are executed using the Run page.
+
+
+ Test suite version.:  | Test suite date: +
+ +
+  100%  +  75% to 99.9%  +  50% to 75%   +  less than 50% +
+
+
+
+ + + + + -- cgit v1.2.1