lambda.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. if (!dojo._hasResource["dojox.lang.tests.lambda"]) { // _hasResource checks
  2. // added by build. Do
  3. // not use _hasResource
  4. // directly in your
  5. // code.
  6. dojo._hasResource["dojox.lang.tests.lambda"] = true;
  7. dojo.provide("dojox.lang.tests.lambda");
  8. dojo.require("dojox.lang.functional");
  9. (function() {
  10. var df = dojox.lang.functional;
  11. tests.register("dojox.lang.tests.lambda", [function testLambda1(t) {
  12. t.assertEqual(df.repeat(3, "3*", 1), [1, 3, 9]);
  13. }, function testLambda2(t) {
  14. t.assertEqual(df.repeat(3, "*3", 1), [1, 3, 9]);
  15. }, function testLambda3(t) {
  16. t.assertEqual(df.repeat(3, "_*3", 1), [1, 3, 9]);
  17. }, function testLambda4(t) {
  18. t.assertEqual(df.repeat(3, "3*_", 1), [1, 3, 9]);
  19. }, function testLambda5(t) {
  20. t.assertEqual(df.repeat(3, "n->n*3", 1), [1, 3, 9]);
  21. }, function testLambda6(t) {
  22. t.assertEqual(df.repeat(3, "n*3", 1), [1, 3, 9]);
  23. }, function testLambda7(t) {
  24. t.assertEqual(df.repeat(3, "3*m", 1), [1, 3, 9]);
  25. }, function testLambda8(t) {
  26. t.assertEqual(df.repeat(3, "->1", 1), [1, 1, 1]);
  27. }, function testLambda9(t) {
  28. t.assertEqual(df.repeat(3, function(n) {
  29. return n * 3;
  30. }, 1), [1, 3, 9]);
  31. }, function testLambda10(t) {
  32. t.assertEqual(df.repeat(3, ["_-1", ["*3"]], 1), [1,
  33. 2, 5]);
  34. }]);
  35. })();
  36. }