/**
File Name: 15.5.4.12-3.js
ECMA Section: 15.5.4.12 String.prototype.toUpperCase()
Description:
Returns a string equal in length to the length of the result of converting
this object to a string. The result is a string value, not a String object.
Every character of the result is equal to the corresponding character of the
string, unless that character has a Unicode 2.0 uppercase equivalent, in which
case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case
mapping shall be used, which does not depend on implementation or locale.)
Note that the toUpperCase function is intentionally generic; it does not require
that its this value be a String object. Therefore it can be transferred to other
kinds of objects for use as a method.
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "15.5.4.12-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "String.prototype.toUpperCase()";
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
function getTestCases() {
var array = new Array();
var item = 0;
// Georgian
// Range: U+10A0 to U+10FF
for ( var i = 0x10A0; i <= 0x10FF; i++ ) {
var U = new Unicode( i );
/*
array[item++] = new TestCase( SECTION,
"var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()",
String.fromCharCode(U.upper),
eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") );
*/
array[item++] = new TestCase( SECTION,
"var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)",
U.upper,
eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") );
}
// Halfwidth and Fullwidth Forms
// Range: U+FF00 to U+FFEF
for ( var i = 0xFF00; i <= 0xFFEF; i++ ) {
array[item++] = new TestCase( SECTION,
"var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()",
eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ),
eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") );
array[item++] = new TestCase( SECTION,
"var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)",
eval( "var u = new Unicode( i ); u.upper" ),
eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") );
}
// Hiragana (no upper / lower case)
// Range: U+3040 to U+309F
for ( var i = 0x3040; i <= 0x309F; i++ ) {
array[item++] = new TestCase( SECTION,
"var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()",
eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ),
eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") );
array[item++] = new TestCase( SECTION,
"var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)",
eval( "var u = new Unicode( i ); u.upper" ),
eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") );
}
/*
var TEST_STRING = "";
var EXPECT_STRING = "";
// basic latin test
for ( var i = 0; i < 0x007A; i++ ) {
var u = new Unicode(i);
TEST_STRING += String.fromCharCode(i);
EXPECT_STRING += String.fromCharCode( u.upper );
}
*/
return array;
}
function test() {
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
function MyObject( value ) {
this.value = value;
this.substring = String.prototype.substring;
this.toString = new Function ( "return this.value+''" );
}
function Unicode( c ) {
u = GetUnicodeValues( c );
this.upper = u[0];
this.lower = u[1]
return this;
}
function GetUnicodeValues( c ) {
u = new Array();
u[0] = c;
u[1] = c;
// upper case Basic Latin
if ( c >= 0x0041 && c <= 0x005A) {
u[0] = c;
u[1] = c + 32;
return u;
}
// lower case Basic Latin
if ( c >= 0x0061 && c <= 0x007a ) {
u[0] = c - 32;
u[1] = c;
return u;
}
// upper case Latin-1 Supplement
if ( c == 0x00B5 ) {
u[0] = 0x039C;
u[1] = c;
return u;
}
if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) {
u[0] = c;
u[1] = c + 32;
return u;
}
// lower case Latin-1 Supplement
if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) {
u[0] = c - 32;
u[1] = c;
return u;
}
if ( c == 0x00FF ) {
u[0] = 0x0178;
u[1] = c;
return u;
}
// Latin Extended A
if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) {
// special case for capital I
if ( c == 0x0130 ) {
u[0] = c;
u[1] = 0x0069;
return u;
}
if ( c == 0x0131 ) {
u[0] = 0x0049;
u[1] = c;
return u;
}
if ( c % 2 == 0 ) {
// if it's even, it's a capital and the lower case is c +1
u[0] = c;
u[1] = c+1;
} else {
// if it's odd, it's a lower case and upper case is c-1
u[0] = c-1;
u[1] = c;
}
return u;
}
if ( c == 0x0178 ) {
u[0] = c;
u[1] = 0x00FF;
return u;
}
if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) {
if ( c % 2 == 1 ) {
// if it's odd, it's a capital and the lower case is c +1
u[0] = c;
u[1] = c+1;
} else {
// if it's even, it's a lower case and upper case is c-1
u[0] = c-1;
u[1] = c;
}
return u;
}
if ( c == 0x017F ) {
u[0] = 0x0053;
u[1] = c;
}
// Latin Extended B
// need to improve this set
if ( c >= 0x0200 && c <= 0x0217 ) {
if ( c % 2 == 0 ) {
u[0] = c;
u[1] = c+1;
} else {
u[0] = c-1;
u[1] = c;
}
return u;
}
// Latin Extended Additional
// Range: U+1E00 to U+1EFF
// http://www.unicode.org/Unicode.charts/glyphless/U1E00.html
// Spacing Modifier Leters
// Range: U+02B0 to U+02FF
// Combining Diacritical Marks
// Range: U+0300 to U+036F
// skip Greek for now
// Greek
// Range: U+0370 to U+03FF
// Cyrillic
// Range: U+0400 to U+04FF
if ( c >= 0x0400 && c <= 0x040F) {
u[0] = c;
u[1] = c + 80;
return u;
}
if ( c >= 0x0410 && c <= 0x042F ) {
u[0] = c;
u[1] = c + 32;
return u;
}
if ( c >= 0x0430 && c<= 0x044F ) {
u[0] = c - 32;
u[1] = c;
return u;
}
if ( c >= 0x0450 && c<= 0x045F ) {
u[0] = c -80;
u[1
dowhile-001.rar_statement
版权申诉
48 浏览量
2022-09-22
23:54:40
上传
评论
收藏 3KB RAR 举报
我虽横行却不霸道
- 粉丝: 77
- 资源: 1万+
最新资源
- AutoHotKey 2.0中文帮助文件
- 基于Docker-compose的Elasticsearch集群每个节点均是独立docker-compose配置而成源码.zip
- 目标检测-零售食品LOGO检测数据集-40000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 目标检测-零售食品LOGO检测数据集-30000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 目标检测-零售食品LOGO检测数据集-20000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 目标检测-零售食品LOGO检测数据集-10000张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本
- 基于GUI+MYSQL+JAVA图书管理系统文档说明+源码(高分大作业项目).zip
- 基于Qt使用C++实现图书管理系统源码+数据库(95分以上).zip
- 基于GUI+MYSQL+JAVA票务管理系统文档介绍+源码+数据库(高分大作业).zip
- Java项目-购物网站系统(java+Servlet+JSP+Mysql)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈