4f56245046073639bb9d491ef367d95927931a27.svn-base 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. if (!dojo._hasResource["tests._base"]) { // _hasResource checks added by
  2. // build. Do not use _hasResource
  3. // directly in your code.
  4. dojo._hasResource["tests._base"] = true;
  5. var testGlobal = this;
  6. try {
  7. dojo.provide("tests._base");
  8. testGlobal = dojo.global;
  9. } catch (e) {
  10. }
  11. // the test suite for the bootstrap. Requires hostenv and other base tests
  12. // at
  13. // the end
  14. if (doh.selfTest) {
  15. doh.register("doh.smokeTest", [function sanityCheckHarness(t) {
  16. // sanity checks
  17. t.assertTrue(true);
  18. t.assertFalse(false);
  19. t.assertFalse(0);
  20. t.assertFalse(null);
  21. var tObj = {
  22. w00t : false,
  23. blarg : true
  24. };
  25. t.assertEqual(["thinger", "blah", tObj], ["thinger", "blah", tObj]);
  26. t.assertEqual(tObj, tObj);
  27. },
  28. /*
  29. * // uncomment to tests exception handling function
  30. * sanityCheckassertTrue(t){ // should throw an error
  31. * t.assertTrue(false); }, function sanityCheckassertFalse(t){ //
  32. * should throw an error t.assertFalse(true); }, function
  33. * sanityCheckassertEqual(t){ // should throw an error
  34. * t.assertEqual("foo", "bar"); },
  35. */
  36. {
  37. name : "eqTest",
  38. // smoke test the fixture system
  39. setUp : function(t) {
  40. this.foo = "blah";
  41. },
  42. runTest : function(t) {
  43. t.assertEqual("blah", this.foo);
  44. },
  45. tearDown : function(t) {
  46. }
  47. }]);
  48. if (testGlobal["dojo"]) {
  49. doh.register("tests._base", [function dojoIsAvailable(t) {
  50. t.assertTrue(testGlobal["dojo"]);
  51. }]);
  52. }
  53. if (testGlobal["setTimeout"]) {
  54. // a stone-stupid async test
  55. doh.register("tests.async", [{
  56. name : "deferredSuccess",
  57. runTest : function(t) {
  58. var d = new doh.Deferred();
  59. setTimeout(d.getTestCallback(function() {
  60. t.assertTrue(true);
  61. t.assertFalse(false);
  62. }), 50);
  63. return d;
  64. }
  65. }, {
  66. name : "deferredFailure",
  67. runTest : function(t) {
  68. var d = new doh.Deferred();
  69. setTimeout(function() {
  70. d.errback(new Error("hrm..."));
  71. }, 50);
  72. return d;
  73. }
  74. }, {
  75. name : "timeoutFailure",
  76. timeout : 50,
  77. runTest : function(t) {
  78. // timeout of 50
  79. var d = new doh.Deferred();
  80. setTimeout(function() {
  81. d.callback(true);
  82. }, 100);
  83. return d;
  84. }
  85. }]);
  86. }
  87. }
  88. try {
  89. // go grab the others
  90. dojo.require("tests._base._loader.bootstrap");
  91. dojo.require("tests._base._loader.loader");
  92. dojo.platformRequire({
  93. browser : ["tests._base._loader.hostenv_browser"],
  94. rhino : ["tests._base._loader.hostenv_rhino"],
  95. spidermonkey : ["tests._base._loader.hostenv_spidermonkey"]
  96. });
  97. dojo.require("tests._base.array");
  98. dojo.require("tests._base.Color");
  99. dojo.require("tests._base.lang");
  100. dojo.require("tests._base.declare");
  101. dojo.require("tests._base.connect");
  102. dojo.require("tests._base.Deferred");
  103. dojo.require("tests._base.json");
  104. // FIXME: add test includes for the rest of the Dojo Base groups here
  105. dojo.requireIf(dojo.isBrowser, "tests._base.html");
  106. dojo.requireIf(dojo.isBrowser, "tests._base.fx");
  107. dojo.requireIf(dojo.isBrowser, "tests._base.query");
  108. dojo.requireIf(dojo.isBrowser, "tests._base.xhr");
  109. } catch (e) {
  110. doh.debug(e);
  111. }
  112. }