⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 number.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 3 页
字号:
			throw "["+i+"]Failed when formatting 1.2 using legal pattern " + patterns[i];		}else if(!exception && i==0){			throw "["+i+"]Failed when formatting 1.2 using illegal pattern  " + patterns[i];		}	}*/		//print("test_number_format_Patterns() end..............\n");			}		},		{			name: "exponential",			runTest: function(t){/** * TODO: For dojo.number future version  * Refer to ICU4J's NumberFormatTest.TestExponential() */			}		},		{			name: "format_quotes",			runTest: function(t){/** * TODO: Failed case * Refer to ICU4J's NumberFormatTest.TestQuotes() */	//print("test_number_format_Quotes() start..............");	//TODO: add more locales 		//TODO:!!Failed case		//Pattern "s'aa''s'c#" should format 6666 to "saa'sc6666", but got s'aa''s'c6666 instead	// is this case necessary?	/*	var pattern = "s'aa''s'c#";   	var result = dojo.number.format(6666,{pattern:pattern,locale:"en-us"});	var expectResult = "saa'sc6666";	t.is(expectResult,result);	*/	//print("test_number_format_Quotes() end..............");     			}		},		{			name: "format_rounding",			runTest: function(t){/** * Refer to ICU4J's NumberFormatTest.TestRounding487() and NumberFormatTest.TestRounding() */	//print("test_number_format_rounding() start..............");	tests.number.rounding(t,0.000179999, 5, "0.00018");	tests.number.rounding(t,0.00099, 4, "0.001");	tests.number.rounding(t,17.6995, 3, "17.7");	tests.number.rounding(t,15.3999, 0, "15");	tests.number.rounding(t,-29.6, 0, "-30");		//TODO refer to NumberFormatTest.TestRounding()		//print("test_number_format_rounding() end..............");			}		},		{			name: "format_scientific",			runTest: function(t){/** * TODO: For dojo.number future version * Refer to ICU4J's NumberFormatTest.TestScientific()- Exponential testing  * Refer to ICU4J's NumberFormatTest.TestScientific2()  * Refer to ICU4J's NumberFormatTest.TestScientificGrouping() */			}		},		{			name: "format_perMill",			runTest: function(t){/** * TODO: Failed case  * Refer to ICU4J's NumberFormatTest.TestPerMill() */	//print("test_number_format_PerMill() start..............");	var pattern;	var result;	var expectResult;	    //TODO: !!Failed case - ###.###\u2030(\u2030 is ‰)	//Pattern ###.###\u2030 should format 0.4857 as 485.7\u2030,but got 485.700\u2030 instead    	pattern = "###.###\u2030";	expectResult = "485.7\u2030";	result = dojo.number.format(0.4857,{pattern:pattern});	t.is(expectResult,result);    //TODO: !!Failed mile percent case - ###.###m	//Pattern "###.###m" should format 0.4857 to 485.7m, but got 0.485m instead	/*	pattern = "###.###m";	expectResult = "485.7m";	result = dojo.number.format(0.4857,{pattern:pattern,locale:"en"});	t.is(expectResult,result);		*/	//print("test_number_format_PerMill() end..............\n");			}		},		{			name: "format_grouping",			runTest: function(t){/** * Only test en-us and en-in  * Refer to ICU4J's NumberFormatTest.TestSecondaryGrouping() */	//print("test_number_format_Grouping() start..............");	//primary grouping	var sourceInput = 123456789;	var expectResult = "12,34,56,789";	var options = {pattern:"#,##,###",locale:"en-us"};		//step1: 123456789 formated=> 12,34,56,789	//step2:12,34,56,789 parsed=> 123456789 => formated => 12,34,56,789	tests.number.checkFormatParseCycle(t, options,sourceInput,expectResult,true);						  	//TODO: sencondary grouping not implemented yet ?	//Pattern "#,###" and secondaryGroupingSize=4 should format 123456789 to "12,3456,789"					//Special case for "en-in" locale	//1876543210 should be formated as 1,87,65,43,210 in "en-in" (India)/*	sourceInput = 1876543210;	expectResult = "1,87,65,43,210";	var result = dojo.number.format(sourceInput,{locale:"en-in"});	t.is(expectResult,result);   */	//print("test_number_format_Grouping() end..............\n");    			}		},		{			name: "format_pad",			runTest: function(t){/** * TODO:!!Failed cases: * According to ICU4J test criteria: * 1.with pattern "*^##.##": * 	 0 should be formatted to "^^^^0",but got "*^0" instead, *   -1.3 should be formatted to "^-1.3",but got "-*^1.3" instead. *    * 2.with pattern "##0.0####*_ 'g-m/s^2'" : *   0 should be formatted to "0.0______ g-m/s^2",but got ":0.0*_ 'g-m/s^2'" instead *   1.0/3 should be formatted to "0.33333__ g-m/s^2",but got "0.33333*_ 'g-m/s^2'" instead *    * 3.with pattern "*x#,###,###,##0.0#;*x(###,###,##0.0#)": * 	 -10 should be formatted to "xxxxxxxxxx(10.0)",but got "*x(10.0)" instead. *   10 should be formatted to "xxxxxxxxxxxx10.0",but got "*x10.0" instead. *   ...... *   -1120456.37 should be formatted to "xx(1,120,456.37)",but got "*x(1,120,456.37)" instead. *   1120456.37 should be formatted to "xxxx1,120,456.37",but got "*x1,120,456.37" instead. *   -1252045600.37 should be formatted to "(1,252,045,600.37)",but got "*x(1,252,045,600.37)" instead. *   1252045600.37 should be formatted to "10,252,045,600.37",but got "*x10,252,045,600.37" instead. *    * 4.with pattern "#,###,###,##0.0#*x;(###,###,##0.0#*x)" * 	 -10 should be formatted to (10.0xxxxxxxxxx),but got "(10.0*x)" instead. *   10 should be formatted to "10.0xxxxxxxxxxxx",but got "10.0*x" instead. *   ...... *   -1120456.37 should be formatted to "(1,120,456.37xx)",but got "(1,120,456.37*x)" instead. *   1120456.37 should be formatted to "xxxx1,120,456.37",but got "1,120,456.37*x" instead. *   -1252045600.37 should be formatted to "(1,252,045,600.37)",but got "(1,252,045,600.37*x)" instead. *   1252045600.37 should be formatted to ""10,252,045,600.37"",but got "10,252,045,600.37*x" instead.*    *  * Refer to ICU4J's NumberFormatTest.TestPad() *//*function test_number_format_pad(){	var locale = "en-us";	print("test_number_format_Pad() start..............");	var options = {pattern:"*^##.##",locale:locale};	tests.number.check(t, options,0,"^^^^0");	tests.number.check(t, options,-1.3,"^-1.3");				options = {pattern:"##0.0####*_ 'g-m/s^2'",locale:locale};	tests.number.check(t, options,0,"0.0______ g-m/s^2");		tests.number.checkFormatParseCycle(t, options,1.0/3,"0.33333__ g-m/s^2",true);			//exponent not implemented	//options = {pattern:"##0.0####E0*_ 'g-m/s^2'",locale:locale};	//tests.number.check(t, options,0,"0.0E0______ g-m/s^2");	//tests.number.checkFormatParseCycle(t, options,1.0/3,"333.333E-3_ g-m/s^2",true);		// Test padding before a sign	options = {pattern:"*x#,###,###,##0.0#;*x(###,###,##0.0#)",locale:locale};	tests.number.check(t, options,-10,"xxxxxxxxxx(10.0)");	tests.number.check(t, options,-1000, "xxxxxxx(1,000.0)");	tests.number.check(t, options,-1000000, "xxx(1,000,000.0)");	tests.number.check(t, options,-100.37, "xxxxxxxx(100.37)");	tests.number.check(t, options,-10456.37, "xxxxx(10,456.37)");	tests.number.check(t, options,-1120456.37, "xx(1,120,456.37)");	tests.number.check(t, options,-112045600.37, "(112,045,600.37)");    	tests.number.check(t, options,-1252045600.37, "(1,252,045,600.37)");	tests.number.check(t, options,10, "xxxxxxxxxxxx10.0");	tests.number.check(t, options,1000, "xxxxxxxxx1,000.0");	tests.number.check(t, options,1000000, "xxxxx1,000,000.0");	tests.number.check(t, options,100.37, "xxxxxxxxxx100.37");	tests.number.check(t, options,10456.37, "xxxxxxx10,456.37");        	tests.number.check(t, options,1120456.37, "xxxx1,120,456.37");	tests.number.check(t, options,112045600.37, "xx112,045,600.37");	tests.number.check(t, options,10252045600.37, "10,252,045,600.37");	// Test padding between a sign and a number	options = {pattern:"#,###,###,##0.0#*x;(###,###,##0.0#*x)",locale:locale};	tests.number.check(t, options, -10, "(10.0xxxxxxxxxx)");	tests.number.check(t, options, -1000, "(1,000.0xxxxxxx)");	tests.number.check(t, options, -1000000, "(1,000,000.0xxx)");	tests.number.check(t, options, -100.37, "(100.37xxxxxxxx)");	tests.number.check(t, options, -10456.37, "(10,456.37xxxxx)");    	tests.number.check(t, options, -1120456.37, "(1,120,456.37xx)");	tests.number.check(t, options, -112045600.37, "(112,045,600.37)");   	tests.number.check(t, options, -1252045600.37, "(1,252,045,600.37)");  	tests.number.check(t, options, 10, "10.0xxxxxxxxxxxx");	tests.number.check(t, options, 1000, "1,000.0xxxxxxxxx");	tests.number.check(t, options, 1000000, "1,000,000.0xxxxx");	tests.number.check(t, options, 100.37, "100.37xxxxxxxxxx");	tests.number.check(t, options, 10456.37, "10,456.37xxxxxxx");	tests.number.check(t, options, 1120456.37, "1,120,456.37xxxx");	tests.number.check(t, options, 112045600.37, "112,045,600.37xx");	tests.number.check(t, options, 10252045600.37, "10,252,045,600.37");			//Not implemented yet,refer to NumberFormatTest.TestPatterns2()	//For future use - maily test pad patterns	print("test_number_format_Pad() end..............");}*/			}		},		{			name: "parse_icu4j3_6",			runTest: function(t){/** * In ICU4J, testing logic for NumberFormat.parse() is seperated into  * differernt single tese cases. So part of these logic are  * collected together in this test case. *  */	//print("test_number_parse_icu4j3_6() start..............");	//Refer to ICU4J's NumberFormatTest.TestParse() which is only a rudimentary version	var pattern = "00";	var str = "0.0";		var result = dojo.number.parse(str,{pattern:pattern});	//TODO: add more locales//FIXME: is this a valid test?//	t.is(0,result);	/**************************************** tolerant parse *****************************************	 * refers to ICU4J's NumberFormatTest.TestStrictParse()??	 * TODO: Seems dojo.number parses string in a tolerant way.  	 */	 var options = {locale:"en-us"};	/*	 * TODO: !!Failed case,Should all pass,	 * but the following elements failed (all parsed to NaN):	 * [1]-"0 ",[2]-"0.",[3]-"0,",[5]-"0. ",[6]-"0.100,5",	 * [7]-".00",[9]-"12345, ",[10]-"1,234, ",[12]-"0E" 	 */	var passData = ([		"0",           //[0] single zero before end of text is not leading        //"0 ",        //[1] single zero at end of number is not leading        //"0.",        //[2] single zero before period (or decimal, it's ambiguous) is not leading        //"0,",          //[3] single zero before comma (not group separator) is not leading        "0.0",         //[4] single zero before decimal followed by digit is not leading        //"0. ",       //[5] same as above before period (or decimal) is not leading        //"0.100,5",   //[6] comma stops parse of decimal (no grouping)        //".00",       //[7] leading decimal is ok, even with zeros        "1234567",     //[8] group separators are not required        //"12345, ",   //[9] comma not followed by digit is not a group separator, but end of number        //"1,234, ",   //[10] if group separator is present, group sizes must be appropriate        "1,234,567"   //[11] ...secondary too        //,"0E"         //[12]not implemented yet,an exponnent not followed by zero or digits is not an exponent          ]);	runBatchParse(options,passData,true/*tolerant parse*/);			/* 	 * TODO:!!Failed case,should all pass,	 * but the following failed,	 * [10]-"1,45 that" implies that we partially parse input	 */	var failData = ([            		"00",          //[0] leading zero before zero        "012",         //[1] leading zero before digit        "0,456",       //[2] leading zero before group separator        "1,2",         //[3] wrong number of digits after group separator        ",0",          //[4] leading group separator before zero        ",1",          //[5] leading group separator before digit        ",.02",        //[6] leading group separator before decimal        "1,.02",       //[7] group separator before decimal        "1,,200",      //[8] multiple group separators        "1,45",        //[9] wrong number of digits in primary group        //"1,45 that",   //[10] wrong number of digits in primary group        "1,45.34",     //[11] wrong number of digits in primary group        "1234,567",    //[12] wrong number of digits in secondary group        "12,34,567",   //[13] wrong number of digits in secondary group        "1,23,456,7890" //[14] wrong number of digits in primary and secondary groups		]);	runBatchParse(options,failData,false);		 options = {pattern:"#,##,##0.#",locale:"en-us"};	/*	 * TODO:!!Failed case,shoudl all pass.	 	 * but [1] [2] and [3] failed	 * should be parsed to 1234567,but NaN instead 	 */	var mixedPassData = ([            		"12,34,567"    	//[0]        //,"12,34,567,"		//[1]        //"12,34,567, that",//[2]        //"12,34,567 that"	//[3]		]);		runBatchParse(options,mixedPassData,true/*tolerant parse*/);		/*	 * TODO:!!Failed case,should all pass,	 * but actually mixedFailData[2] and mixedFailData[3] passed.	 * "12,34,56, that " and [3]-"12,34,56 that" should be parsed to 123456,but NaN instead	 */	var mixedFailData = ([        "12,34,56",			//[0]        "12,34,56,"		//[1]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -