1 | dojo.provide("dojox.lang.tests.object"); |
---|
2 | |
---|
3 | dojo.require("dojox.lang.functional.object"); |
---|
4 | |
---|
5 | (function(){ |
---|
6 | var df = dojox.lang.functional, x = {a: 1, b: 2, c: 3}, |
---|
7 | print = function(v, i){ this.push("[" + i + "] = " + v); }, |
---|
8 | show = function(o){ return df.forIn(o, print, []).sort().join(", "); }; |
---|
9 | |
---|
10 | tests.register("dojox.lang.tests.object", [ |
---|
11 | function testKeys(t){ t.assertEqual(df.keys(x).sort(), ["a", "b", "c"]); }, |
---|
12 | function testValues(t){ t.assertEqual(df.values(x).sort(), [1, 2, 3]); }, |
---|
13 | |
---|
14 | function testForIn(t){ t.assertEqual(show(x), "[a] = 1, [b] = 2, [c] = 3"); }, |
---|
15 | function testFilterIn(t){ t.assertEqual(show(df.filterIn(x, "%2")), "[a] = 1, [c] = 3"); }, |
---|
16 | function testMapIn(t){ t.assertEqual(show(df.mapIn(x, "+3")), "[a] = 4, [b] = 5, [c] = 6"); } |
---|
17 | ]); |
---|
18 | })(); |
---|