2 <!-- MOZ_INSERT_CONTENT_HOOK -->
3 <script src = runner.js
></script>
5 var onlyName
= 'String Split on Char', onlyNum
= 131072;
8 startTest("object-string");
10 // Try to force real results
13 // TESTS: String concatenation
15 for ( var num
= 500; num
<= 4000; num
*= 2 ) (function(num
){
17 test( "Concat String", num
, function(){
19 for ( var i
= 0; i
< num
; i
++ )
24 test( "Concat String Object", num
, function(){
25 var str
= new String();
26 for ( var i
= 0; i
< num
; i
++ )
31 test( "Concat String from charCode", num
, function(){
33 for ( var i
= 0; i
< num
; i
++ )
34 str
+= String
.fromCharCode(97);
38 test( "Array String Join", num
, function(){
40 for ( var i
= 0; i
< num
; i
++ )
47 var str
= "", tmp
, num
= 50;
49 for ( var i
= 0; i
< 16384; i
++ )
50 str
+= String
.fromCharCode( (25 * Math
.random()) + 97 );
52 for ( var i
= 16384; i
<= 131072; i
*= 2 ) (function(i
){
56 test( "String Split", i
, function(){
60 test( "String Split on Char", i
, function(){
66 test( "charAt", i
, function(){
67 for ( var j
= 0; j
< num
; j
++ ) {
69 ret
= str
.charAt(str
.length
- 1);
70 ret
= str
.charAt( 15000 );
71 ret
= str
.charAt( 12000 );
75 test( "[Number]", i
, function(){
76 for ( var j
= 0; j
< num
; j
++ ) {
78 ret
= str
[str
.length
- 1];
84 test( "charCodeAt", i
, function(){
85 for ( var j
= 0; j
< num
; j
++ ) {
86 ret
= str
.charCodeAt(0);
87 ret
= str
.charCodeAt(str
.length
- 1);
88 ret
= str
.charCodeAt( 15000 );
89 ret
= str
.charCodeAt( 12000 );
95 test( "indexOf", i
, function(){
96 for ( var j
= 0; j
< num
; j
++ ) {
97 ret
= str
.indexOf("a");
98 ret
= str
.indexOf("b");
99 ret
= str
.indexOf("c");
100 ret
= str
.indexOf("d");
104 test( "lastIndexOf", i
, function(){
105 for ( var j
= 0; j
< num
; j
++ ) {
106 ret
= str
.lastIndexOf("a");
107 ret
= str
.lastIndexOf("b");
108 ret
= str
.lastIndexOf("c");
109 ret
= str
.lastIndexOf("d");
115 test( "length", i
, function(){
116 for ( var j
= 0; j
< num
; j
++ ) {
128 test( "slice", i
, function(){
129 for ( var j
= 0; j
< num
; j
++ ) {
131 ret
= str
.slice(0,5);
133 ret
= str
.slice(-6,-1);
134 ret
= str
.slice( 15000, 15005 );
135 ret
= str
.slice( 12000, -1 );
141 test( "substr", i
, function(){
142 for ( var j
= 0; j
< num
; j
++ ) {
144 ret
= str
.substr(0,5);
145 ret
= str
.substr(-1);
146 ret
= str
.substr(-6,1);
147 ret
= str
.substr( 15000, 5 );
148 ret
= str
.substr( 12000, 5 );
154 test( "substring", i
, function(){
155 for ( var j
= 0; j
< num
; j
++ ) {
156 ret
= str
.substring(0);
157 ret
= str
.substring(0,5);
158 ret
= str
.substring(-1);
159 ret
= str
.substring(-6,-1);
160 ret
= str
.substring( 15000, 15005 );
161 ret
= str
.substring( 12000, -1 );
165 // TESTS: toLower/UpperCase
167 test( "toLowerCase", i
, function(){
168 for ( var j
= 0; j
< num
; j
++ ) {
169 ret
= str
.toLowerCase();
173 test( "toUpperCase", i
, function(){
174 for ( var j
= 0; j
< num
; j
++ ) {
175 ret
= str
.toUpperCase();
181 test( "toSource", i
, function(){
182 for ( var j
= 0; j
< num
; j
++ ) {
183 ret
= str
.toSource();
189 test( "toString", i
, function(){
190 for ( var j
= 0; j
< num
; j
++ ) {
191 ret
= str
.toString();
197 test( "valueOf", i
, function(){
198 for ( var j
= 0; j
< num
; j
++ ) {
207 test( "comparing", i
, function(){
208 for ( var j
= 0; j
< num
; j
++ ) {
215 // Double the length of the string
222 <body onload=
"thisTest()"></body></html>