3 <script src=
"../htmlrunner.js"></script>
5 window
.onload = function(){ startTest("dromaeo-object-string", 'ef8605c3');
7 // Try to force real results
11 // TESTS: String concatenation
13 test( "Concat String", function(){
15 for ( var i
= 0; i
< num
; i
++ )
20 test( "Concat String Object", function(){
21 var str
= new String();
22 for ( var i
= 0; i
< num
; i
++ )
27 test( "Concat String from charCode", function(){
29 for ( var i
= 0; i
< num
/ 2; i
++ )
30 str
+= String
.fromCharCode(97);
34 test( "Array String Join", function(){
36 for ( var i
= 0; i
< num
/ 2; i
++ )
41 var ostr
= [], tmp
, tmp2
, num
= 5000, tmpstr
;
43 for ( var i
= 0; i
< 16384; i
++ )
44 ostr
.push( String
.fromCharCode( (25 * Math
.random()) + 97 ) );
54 str
= new String(ostr
);
58 test( "String Split", function(){
70 test( "String Split on Char", function(){
71 ret
= tmpstr
.split("a");
80 test( "charAt", function(){
81 for ( var j
= 0; j
< num
; j
++ ) {
83 ret
= str
.charAt(str
.length
- 1);
84 ret
= str
.charAt( 15000 );
85 ret
= str
.charAt( 12000 );
89 test( "[Number]", function(){
90 for ( var j
= 0; j
< num
; j
++ ) {
92 ret
= str
[str
.length
- 1];
99 test( "charCodeAt", function(){
100 for ( var j
= 0; j
< num
; j
++ ) {
101 ret
= str
.charCodeAt(0);
102 ret
= str
.charCodeAt(str
.length
- 1);
103 ret
= str
.charCodeAt( 15000 );
104 ret
= str
.charCodeAt( 10000 );
105 ret
= str
.charCodeAt( 5000 );
111 test( "indexOf", function(){
112 for ( var j
= 0; j
< num
; j
++ ) {
113 ret
= str
.indexOf("a");
114 ret
= str
.indexOf("b");
115 ret
= str
.indexOf("c");
116 ret
= str
.indexOf("d");
120 test( "lastIndexOf", function(){
121 for ( var j
= 0; j
< num
; j
++ ) {
122 ret
= str
.lastIndexOf("a");
123 ret
= str
.lastIndexOf("b");
124 ret
= str
.lastIndexOf("c");
125 ret
= str
.lastIndexOf("d");
131 test( "slice", function(){
132 for ( var j
= 0; j
< num
; j
++ ) {
134 ret
= str
.slice(0,5);
136 ret
= str
.slice(-6,-1);
137 ret
= str
.slice( 15000, 15005 );
138 ret
= str
.slice( 12000, -1 );
144 test( "substr", function(){
145 for ( var j
= 0; j
< num
; j
++ ) {
147 ret
= str
.substr(0,5);
148 ret
= str
.substr(-1);
149 ret
= str
.substr(-6,1);
150 ret
= str
.substr( 15000, 5 );
151 ret
= str
.substr( 12000, 5 );
157 test( "substring", function(){
158 for ( var j
= 0; j
< num
; j
++ ) {
159 ret
= str
.substring(0);
160 ret
= str
.substring(0,5);
161 ret
= str
.substring(-1);
162 ret
= str
.substring(-6,-1);
163 ret
= str
.substring( 15000, 15005 );
164 ret
= str
.substring( 12000, -1 );
168 // TESTS: toLower/UpperCase
170 test( "toLowerCase", function(){
171 for ( var j
= 0; j
< num
/ 1000; j
++ ) {
172 ret
= str
.toLowerCase();
176 test( "toUpperCase", function(){
177 for ( var j
= 0; j
< num
/ 1000; j
++ ) {
178 ret
= str
.toUpperCase();
188 test( "comparing", function(){
189 tmp
= "a" + tmp
+ "a";
190 tmp2
= "a" + tmp2
+ "a";
191 for ( var j
= 0; j
< num
/ 1000; j
++ ) {