summaryrefslogtreecommitdiff
path: root/includes/js/dojo/tests/_base/Deferred.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojo/tests/_base/Deferred.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojo/tests/_base/Deferred.js')
-rw-r--r--includes/js/dojo/tests/_base/Deferred.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/includes/js/dojo/tests/_base/Deferred.js b/includes/js/dojo/tests/_base/Deferred.js
new file mode 100644
index 0000000..5dcf003
--- /dev/null
+++ b/includes/js/dojo/tests/_base/Deferred.js
@@ -0,0 +1,76 @@
+if(!dojo._hasResource["tests._base.Deferred"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["tests._base.Deferred"] = true;
+dojo.provide("tests._base.Deferred");
+
+doh.register("tests._base.Deferred",
+ [
+
+ function callback(t){
+ var nd = new dojo.Deferred();
+ var cnt = 0;
+ nd.addCallback(function(res){
+ doh.debug("debug from dojo.Deferred callback");
+ return res;
+ });
+ nd.addCallback(function(res){
+ // t.debug("val:", res);
+ cnt+=res;
+ return cnt;
+ });
+ nd.callback(5);
+ // t.debug("cnt:", cnt);
+ t.assertEqual(cnt, 5);
+ },
+
+ function callback_extra_args(t){
+ var nd = new dojo.Deferred();
+ var cnt = 0;
+ nd.addCallback(dojo.global, function(base, res){ cnt+=base; cnt+=res; return cnt; }, 30);
+ nd.callback(5);
+ t.assertEqual(cnt, 35);
+ },
+
+ function errback(t){
+ var nd = new dojo.Deferred();
+ var cnt = 0;
+ nd.addErrback(function(val){
+ return ++cnt;
+ });
+ nd.errback();
+ t.assertEqual(cnt, 1);
+ },
+
+ function callbackTwice(t){
+ var nd = new dojo.Deferred();
+ var cnt = 0;
+ nd.addCallback(function(res){
+ return ++cnt;
+ });
+ nd.callback();
+ t.assertEqual(cnt, 1);
+ var thrown = false;
+ try{
+ nd.callback();
+ }catch(e){
+ thrown = true;
+ }
+ t.assertTrue(thrown);
+ },
+
+ function addBoth(t){
+ var nd = new dojo.Deferred();
+ var cnt = 0;
+ nd.addBoth(function(res){
+ return ++cnt;
+ });
+ nd.callback();
+ t.assertEqual(cnt, 1);
+
+ // nd.callback();
+ // t.debug(cnt);
+ // t.assertEqual(cnt, 1);
+ }
+ ]
+);
+
+}