2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.lang.tests.std"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.lang.tests.std"] = true;
|
|
|
3 |
dojo.provide("dojox.lang.tests.std");
|
|
|
4 |
dojo.require("dojox.lang.functional");
|
|
|
5 |
|
|
|
6 |
(function(){
|
|
|
7 |
var df = dojox.lang.functional, v, isOdd = "%2";
|
|
|
8 |
tests.register("dojox.lang.tests.std", [
|
|
|
9 |
function testFilter1(t){ t.assertEqual(df.filter([1, 2, 3], isOdd), [1, 3]); },
|
|
|
10 |
function testFilter2(t){ t.assertEqual(df.filter([1, 2, 3], "%2==0"), [2]); },
|
|
|
11 |
|
|
|
12 |
function testForEach(t){ t.assertEqual(
|
|
|
13 |
(v = [], df.forEach([1, 2, 3], function(x){ v.push(x); }), v), [1, 2, 3]); },
|
|
|
14 |
|
|
|
15 |
function testMap(t){ t.assertEqual(df.map([1, 2, 3], "+3"), [4, 5, 6]); },
|
|
|
16 |
|
|
|
17 |
function testEvery1(t){ t.assertFalse(df.every([1, 2, 3], isOdd)); },
|
|
|
18 |
function testEvery2(t){ t.assertTrue(df.every([1, 3, 5], isOdd)); },
|
|
|
19 |
|
|
|
20 |
function testSome1(t){ t.assertFalse(df.some([2, 4, 6], isOdd)); },
|
|
|
21 |
function testSome2(t){ t.assertTrue(df.some([1, 2, 3], isOdd)); },
|
|
|
22 |
|
|
|
23 |
function testReduce1(t){ t.assertEqual(df.reduce([4, 2, 1], "x-y"), 1); },
|
|
|
24 |
function testReduce2(t){ t.assertEqual(df.reduce([4, 2, 1], "x-y", 8), 1); },
|
|
|
25 |
|
|
|
26 |
function testReduceRight1(t){ t.assertEqual(df.reduceRight([4, 2, 1], "x-y"), -5); },
|
|
|
27 |
function testReduceRight2(t){ t.assertEqual(df.reduceRight([4, 2, 1], "x-y", 8), 1); }
|
|
|
28 |
]);
|
|
|
29 |
})();
|
|
|
30 |
|
|
|
31 |
}
|