/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var SECTION = "15.4.4.5-1"; var TITLE = "Array.prototype.sort(comparefn)";
writeHeaderToLog( SECTION + " "+ TITLE); var S = new Array(); var item = 0;
// array is empty.
S[item++] = "var A = new Array()";
// array contains one item
S[item++] = "var A = new Array( true )";
// length of array is 2
S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )";
S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0";
S[item] = "var A = new Array( ";
var limit = 0x0061; for ( var i = 0x007A; i >= limit; i-- ) {
S[item] += "\'"+ String.fromCharCode(i) +"\'" ; if ( i > limit ) {
S[item] += ",";
}
}
S[item] += ")";
item++;
for ( var i = 0; i < S.length; i++ ) {
CheckItems( S[i] );
}
test();
function CheckItems( S ) {
eval( S ); var E = Sort( A );
new TestCase(
S +"; A.sort(); A.length",
E.length,
eval( S + "; A.sort(); A.length") );
for ( var i = 0; i < E.length; i++ ) { new TestCase( "A["+i+ "].toString()",
E[i] +"",
A[i] +"");
if ( A[i] == void0 && typeof A[i] == "undefined" ) { new TestCase( "typeof A["+i+ "]", typeof E[i], typeof A[i] );
}
}
} function Object_1( value ) { this.array = value.split(","); this.length = this.array.length; for ( var i = 0; i < this.length; i++ ) { this[i] = eval(this.array[i]);
} this.sort = Array.prototype.sort; this.getClass = Object.prototype.toString;
} function Sort( a ) { for ( i = 0; i < a.length; i++ ) { for ( j = i+1; j < a.length; j++ ) { var lo = a[i]; var hi = a[j]; var c = Compare( lo, hi ); if ( c == 1 ) {
a[i] = hi;
a[j] = lo;
}
}
} return a;
} function Compare( x, y ) { if ( x == void0 && y == void0 && typeof x == "undefined" && typeof y == "undefined" ) { return +0;
} if ( x == void0 && typeof x == "undefined" ) { return1;
} if ( y == void0 && typeof y == "undefined" ) { return -1;
}
x = String(x);
y = String(y); if ( x < y ) { return -1;
} if ( x > y ) { return1;
} return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.