Changeset 12819
- Timestamp:
- 03/02/08 20:21:52 (10 months ago)
- Location:
- dojox/trunk/lang
- Files:
-
- 2 modified
-
functional/reversed.js (modified) (1 diff)
-
tests/array.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojox/trunk/lang/functional/reversed.js
r11764 r12819 47 47 for(var i = n - 1, j = 0; i >= 0; t[j++] = f.call(o, a[i], i, a), --i); 48 48 return t; // Array 49 }, 50 everyRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){ 51 // summary: tests whether all elements in the array pass the test 52 // implemented by the provided function. 53 if(typeof a == "string"){ a = a.split(""); } 54 o = o || d.global; f = df.lambda(f); 55 for(var i = a.length - 1; i >= 0; --i){ 56 if(!f.call(o, a[i], i, a)){ 57 return false; // Boolean 58 } 59 } 60 return true; // Boolean 61 }, 62 someRev: function(/*Array|String*/ a, /*Function|String|Array*/ f, /*Object?*/ o){ 63 // summary: tests whether some element in the array passes the test 64 // implemented by the provided function. 65 if(typeof a == "string"){ a = a.split(""); } 66 o = o || d.global; f = df.lambda(f); 67 for(var i = a.length - 1; i >= 0; --i){ 68 if(f.call(o, a[i], i, a)){ 69 return true; // Boolean 70 } 71 } 72 return false; // Boolean 49 73 } 50 74 }); -
dojox/trunk/lang/tests/array.js
r11764 r12819 56 56 t.assertTrue(df.every(iter, isOdd)); 57 57 }, 58 function testEveryRev1(t){ t.assertFalse(df.everyRev([1, 2, 3], isOdd)); }, 59 function testEveryRev2(t){ t.assertTrue(df.everyRev([1, 3, 5], isOdd)); }, 58 60 59 61 function testSome1(t){ t.assertFalse(df.some([2, 4, 6], isOdd)); }, … … 63 65 t.assertTrue(df.some(iter, isOdd)); 64 66 }, 67 function testSomeRev1(t){ t.assertFalse(df.someRev([2, 4, 6], isOdd)); }, 68 function testSomeRev2(t){ t.assertTrue(df.someRev([1, 2, 3], isOdd)); }, 65 69 66 70 function testReduce1(t){ t.assertEqual(df.reduce([4, 2, 1], "x-y"), 1); },