S13.2.1_A5_T1.js (796B)
1 // Copyright 2009 the Sputnik authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 info: Closures are admitted 6 es5id: 13.2.1_A5_T1 7 description: Sorting with closure 8 ---*/ 9 10 var __arr = [4,3,2,1,4,3,2,1,4,3,2,1]; 11 //Sort uses closure 12 // 13 __arr.sort( 14 function(x,y) { 15 if (x>y){return -1;} 16 if (x<y){return 1;} 17 if (x==y){return 0;} 18 } 19 ); 20 21 ////////////////////////////////////////////////////////////////////////////// 22 //CHECK#1 23 if (__arr.toString() !== [4,4,4,3,3,3,2,2,2,1,1,1].toString()) { 24 throw new Test262Error('#1: __arr.toString() === [4,4,4,3,3,3,2,2,2,1,1,1].toString(). Actual: __arr.toString() ==='+__arr.toString()); 25 } 26 27 // 28 ////////////////////////////////////////////////////////////////////////////// 29 30 reportCompare(0, 0);