Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.lang.tests.curry"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.lang.tests.curry"] = true;
3
dojo.provide("dojox.lang.tests.curry");
4
dojo.require("dojox.lang.functional");
5
 
6
(function(){
7
	var df = dojox.lang.functional, add5 = df.curry("+")(5), sub3 = df.curry("_-3"), fun = df.lambda("100*a + 10*b + c");
8
	tests.register("dojox.lang.tests.curry", [
9
		function testCurry1(t){ t.assertEqual(df.curry("+")(1, 2), 3); },
10
		function testCurry2(t){ t.assertEqual(df.curry("+")(1)(2), 3); },
11
		function testCurry3(t){ t.assertEqual(df.curry("+")(1, 2, 3), 3); },
12
		function testCurry4(t){ t.assertEqual(add5(1), 6); },
13
		function testCurry5(t){ t.assertEqual(add5(3), 8); },
14
		function testCurry6(t){ t.assertEqual(add5(5), 10); },
15
		function testCurry7(t){ t.assertEqual(sub3(1), -2); },
16
		function testCurry8(t){ t.assertEqual(sub3(3), 0); },
17
		function testCurry9(t){ t.assertEqual(sub3(5), 2); },
18
 
19
		function testPartial1(t){ t.assertEqual(df.partial(fun, 1, 2, 3)(), 123); },
20
		function testPartial2(t){ t.assertEqual(df.partial(fun, 1, 2, df.arg)(3), 123); },
21
		function testPartial3(t){ t.assertEqual(df.partial(fun, 1, df.arg, 3)(2), 123); },
22
		function testPartial4(t){ t.assertEqual(df.partial(fun, 1, df.arg, df.arg)(2, 3), 123); },
23
		function testPartial5(t){ t.assertEqual(df.partial(fun, df.arg, 2, 3)(1), 123); },
24
		function testPartial6(t){ t.assertEqual(df.partial(fun, df.arg, 2, df.arg)(1, 3), 123); },
25
		function testPartial7(t){ t.assertEqual(df.partial(fun, df.arg, df.arg, 3)(1, 2), 123); },
26
		function testPartial8(t){ t.assertEqual(df.partial(fun, df.arg, df.arg, df.arg)(1, 2, 3), 123); }
27
	]);
28
})();
29
 
30
}