From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: 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 --- includes/js/dojox/collections/tests/ArrayList.js | 83 ++++++++++ includes/js/dojox/collections/tests/BinaryTree.js | 83 ++++++++++ includes/js/dojox/collections/tests/Dictionary.js | 82 ++++++++++ includes/js/dojox/collections/tests/Queue.js | 49 ++++++ includes/js/dojox/collections/tests/Set.js | 35 +++++ includes/js/dojox/collections/tests/SortedList.js | 168 +++++++++++++++++++++ includes/js/dojox/collections/tests/Stack.js | 49 ++++++ includes/js/dojox/collections/tests/_base.js | 84 +++++++++++ includes/js/dojox/collections/tests/collections.js | 19 +++ includes/js/dojox/collections/tests/runTests.html | 9 ++ 10 files changed, 661 insertions(+) create mode 100644 includes/js/dojox/collections/tests/ArrayList.js create mode 100644 includes/js/dojox/collections/tests/BinaryTree.js create mode 100644 includes/js/dojox/collections/tests/Dictionary.js create mode 100644 includes/js/dojox/collections/tests/Queue.js create mode 100644 includes/js/dojox/collections/tests/Set.js create mode 100644 includes/js/dojox/collections/tests/SortedList.js create mode 100644 includes/js/dojox/collections/tests/Stack.js create mode 100644 includes/js/dojox/collections/tests/_base.js create mode 100644 includes/js/dojox/collections/tests/collections.js create mode 100644 includes/js/dojox/collections/tests/runTests.html (limited to 'includes/js/dojox/collections/tests') diff --git a/includes/js/dojox/collections/tests/ArrayList.js b/includes/js/dojox/collections/tests/ArrayList.js new file mode 100644 index 0000000..2645238 --- /dev/null +++ b/includes/js/dojox/collections/tests/ArrayList.js @@ -0,0 +1,83 @@ +if(!dojo._hasResource["dojox.collections.tests.ArrayList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.ArrayList"] = true; +dojo.provide("dojox.collections.tests.ArrayList"); +dojo.require("dojox.collections.ArrayList"); + +tests.register("dojox.collections.tests.ArrayList", [ + function testCtor(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + t.assertEqual(4, al.count); + }, + function testAdd(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.add("carp"); + t.assertEqual("foo,bar,test,bull,carp", al.toString()); + al.addRange(["oof","rab"]); + t.assertEqual("foo,bar,test,bull,carp,oof,rab", al.toString()); + }, + function testClear(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.clear(); + t.assertEqual(0, al.count); + }, + function testClone(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + var cloned=al.clone(); + t.assertEqual(al.toString(), cloned.toString()); + }, + function testContains(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + t.assertTrue(al.contains("bar")); + t.assertFalse(al.contains("faz")); + }, + function testGetIterator(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + var itr=al.getIterator(); + while(!itr.atEnd()){ + itr.get(); + } + t.assertEqual("bull", itr.element); + }, + function testIndexOf(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + t.assertEqual(1, al.indexOf("bar")); + }, + function testInsert(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.insert(2, "baz"); + t.assertEqual(2, al.indexOf("baz")); + }, + function testItem(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + t.assertEqual("test", al.item(2)); + }, + function testRemove(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.remove("bar"); + t.assertEqual("foo,test,bull", al.toString()); + t.assertEqual(3, al.count); + }, + function testRemoveAt(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.removeAt(3); + t.assertEqual("foo,bar,test", al.toString()); + t.assertEqual(3, al.count); + }, + function testReverse(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.reverse(); + t.assertEqual("bull,test,bar,foo", al.toString()); + }, + function testSort(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + al.sort(); + t.assertEqual("bar,bull,foo,test", al.toString()); + }, + function testToArray(t){ + var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); + var a=al.toArray(); + t.assertEqual(a.join(","), al.toString()); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/BinaryTree.js b/includes/js/dojox/collections/tests/BinaryTree.js new file mode 100644 index 0000000..48acaa4 --- /dev/null +++ b/includes/js/dojox/collections/tests/BinaryTree.js @@ -0,0 +1,83 @@ +if(!dojo._hasResource["dojox.collections.tests.BinaryTree"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.BinaryTree"] = true; +dojo.provide("dojox.collections.tests.BinaryTree"); +dojo.require("dojox.collections.BinaryTree"); + +tests.register("dojox.collections.tests.BinaryTree", [ + function testCtor(t){ + var bt=new dojox.collections.BinaryTree("foo"); + t.assertTrue(bt instanceof dojox.collections.BinaryTree); + }, + function testAdd(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + t.assertEqual("apple,bar,baz,buck,foo,shot",bt.toString()); + }, + function testClear(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + bt.clear(); + t.assertEqual(bt.count, 0); + }, + function testClone(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + var bt2=bt.clone(); + t.assertEqual(bt2.count, 6); + t.assertEqual(bt.toString(), bt2.toString()); + }, + function testContains(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + t.assertTrue(bt.contains("buck")); + t.assertFalse(bt.contains("duck")); + }, + function testDeleteData(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + bt.deleteData("buck"); + t.assertEqual("apple,bar,baz,foo,shot",bt.toString()); + }, + function testGetIterator(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + var itr=bt.getIterator(); + while(!itr.atEnd()){ itr.get(); } + t.assertEqual("shot", itr.element); + }, + function testSearch(t){ + var bt=new dojox.collections.BinaryTree("foo"); + bt.add("bar"); + bt.add("baz"); + bt.add("buck"); + bt.add("shot"); + bt.add("apple"); + t.assertEqual("buck", bt.search("buck").value); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/Dictionary.js b/includes/js/dojox/collections/tests/Dictionary.js new file mode 100644 index 0000000..7bde6ee --- /dev/null +++ b/includes/js/dojox/collections/tests/Dictionary.js @@ -0,0 +1,82 @@ +if(!dojo._hasResource["dojox.collections.tests.Dictionary"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.Dictionary"] = true; +dojo.provide("dojox.collections.tests.Dictionary"); +dojo.require("dojox.collections.Dictionary"); + +tests.register("dojox.collections.tests.Dictionary", [ + function testCtor(t){ + var d=new dojox.collections.Dictionary(); + t.assertTrue(d instanceof dojox.collections.Dictionary); + }, + function testAdd(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + t.assertEqual("bar", d.item("foo").valueOf()); + }, + function testClear(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.clear() + t.assertEqual(0, d.count); + }, + function testClone(t){ + var d=new dojox.collections.Dictionary(); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + var d2 = d.clone(); + t.assertTrue(d2.contains("baz")); + }, + function testContains(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + t.assertTrue(d.contains("baz")); + }, + function testContainsKey(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + t.assertTrue(d.containsKey("buck")); + }, + function testContainsValue(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + t.assertTrue(d.containsValue("shot")); + }, + function testGetKeyList(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + t.assertEqual("foo,baz,buck,apple", d.getKeyList().join(",")); + }, + function testGetValueList(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + t.assertEqual("bar,fab,shot,orange", d.getValueList().join(",")); + }, + function testRemove(t){ + var d=new dojox.collections.Dictionary(); + d.add("foo","bar"); + d.add("baz","fab"); + d.add("buck","shot"); + d.add("apple","orange"); + d.remove("baz"); + t.assertEqual(3, d.count); + t.assertEqual(undefined, d.item("baz")); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/Queue.js b/includes/js/dojox/collections/tests/Queue.js new file mode 100644 index 0000000..5ac61bc --- /dev/null +++ b/includes/js/dojox/collections/tests/Queue.js @@ -0,0 +1,49 @@ +if(!dojo._hasResource["dojox.collections.tests.Queue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.Queue"] = true; +dojo.provide("dojox.collections.tests.Queue"); +dojo.require("dojox.collections.Queue"); + +tests.register("dojox.collections.tests.Queue", [ + function testCtor(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + t.assertEqual(4, q.count); + }, + function testClear(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + q.clear(); + t.assertEqual(0, q.count); + }, + function testClone(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + var cloned=q.clone(); + t.assertEqual(q.count, cloned.count); + t.assertEqual(q.toArray().join(), cloned.toArray().join()); + }, + function testContains(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + t.assertTrue(q.contains("bar")); + t.assertFalse(q.contains("faz")); + }, + function testGetIterator(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + var itr=q.getIterator(); + while(!itr.atEnd()){ itr.get(); } + t.assertEqual("bull", itr.element); + }, + function testPeek(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + t.assertEqual("foo", q.peek()); + }, + function testDequeue(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + t.assertEqual("foo", q.dequeue()); + t.assertEqual("bar,test,bull", q.toArray().join(",")); + }, + function testEnqueue(t){ + var q=new dojox.collections.Queue(["foo","bar","test","bull"]); + q.enqueue("bull"); + t.assertEqual("bull", q.toArray().pop()); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/Set.js b/includes/js/dojox/collections/tests/Set.js new file mode 100644 index 0000000..d548223 --- /dev/null +++ b/includes/js/dojox/collections/tests/Set.js @@ -0,0 +1,35 @@ +if(!dojo._hasResource["dojox.collections.tests.Set"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.Set"] = true; +dojo.provide("dojox.collections.tests.Set"); +dojo.require("dojox.collections.Set"); + +(function(){ + var dxcs=dojox.collections.Set; + var a = ["apple","bear","candy","donut","epiphite","frank"]; + var b = ["bear","epiphite","google","happy","joy"]; + tests.register("dojox.collections.tests.Set", [ + function testUnion(t){ + var union=dxcs.union(a,b); + t.assertEqual("apple,bear,candy,donut,epiphite,frank,google,happy,joy", union.toArray().join(',')); + }, + function testIntersection(t){ + var itsn=dxcs.intersection(a,b); + t.assertEqual("bear,epiphite", itsn.toArray().join(",")); + t.assertEqual("bear", dxcs.intersection(["bear","apple"], ["bear"])); + }, + function testDifference(t){ + var d=dxcs.difference(a,b); + t.assertEqual("apple,candy,donut,frank",d.toArray().join(',')); + }, + function testIsSubSet(t){ + t.assertFalse(dxcs.isSubSet(a,["bear","candy"])); + t.assertTrue(dxcs.isSubSet(["bear","candy"],a)); + }, + function testIsSuperSet(t){ + t.assertTrue(dxcs.isSuperSet(a,["bear","candy"])); + t.assertFalse(dxcs.isSuperSet(["bear","candy"],a)); + } + ]); +})(); + +} diff --git a/includes/js/dojox/collections/tests/SortedList.js b/includes/js/dojox/collections/tests/SortedList.js new file mode 100644 index 0000000..dfb4ffa --- /dev/null +++ b/includes/js/dojox/collections/tests/SortedList.js @@ -0,0 +1,168 @@ +if(!dojo._hasResource["dojox.collections.tests.SortedList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.SortedList"] = true; +dojo.provide("dojox.collections.tests.SortedList"); +dojo.require("dojox.collections.SortedList"); + +tests.register("dojox.collections.tests.SortedList", [ + function testCtor(t){ + var sl=new dojox.collections.SortedList(); + t.assertTrue(sl instanceof dojox.collections.SortedList); + }, + function testAdd(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + t.assertEqual("bar", sl.item("foo").valueOf()); + }, + function testClear(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.clear(); + t.assertEqual(0, sl.count); + }, + function testClone(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + var sl2=sl.clone(); + t.assertTrue(sl2.contains("baz")); + }, + function testContains(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertTrue(sl.contains("baz")); + t.assertFalse(sl.contains("faz")); + }, + function testContainsKey(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertTrue(sl.containsKey("buck")); + t.assertFalse(sl.containsKey("faz")); + }, + function testContainsValue(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertTrue(sl.containsValue("shot")); + t.assertFalse(sl.containsValue("faz")); + }, + function testGetKeyList(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertEqual("foo,baz,buck,apple",sl.getKeyList().join(',')); + }, + function testGetValueList(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertEqual("bar,fab,shot,orange",sl.getValueList().join(',')); + }, + function testCopyTo(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + var arr=["bek"]; + sl.copyTo(arr,0); + t.assertEqual("bar,fab,shot,orange,bek", arr.join(',')); + }, + function testGetByIndex(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertEqual("shot", sl.getByIndex(2)); + }, + function testGetKey(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertEqual("apple", sl.getKey(0)); + }, + function testIndexOfKey(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertEqual(0, sl.indexOfKey("apple")); + }, + function testIndexOfValue(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + t.assertEqual(3, sl.indexOfValue("bar")); + }, + function testRemove(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + sl.remove("baz"); + t.assertEqual(3, sl.count); + t.assertEqual(undefined, sl.item("baz")); + }, + function testRemoveAt(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + sl.removeAt(2); + t.assertEqual(undefined, sl.item("buck")); + }, + function testReplace(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + sl.replace("buck","dollar"); + t.assertEqual(sl.item("buck").valueOf(), "dollar"); + }, + function testSetByIndex(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + sl.setByIndex(0, "bar"); + t.assertEqual("bar", sl.getByIndex(0)); + }, + function testSorting(t){ + var sl=new dojox.collections.SortedList(); + sl.add("foo","bar"); + sl.add("baz","fab"); + sl.add("buck","shot"); + sl.add("apple","orange"); + + var a=[]; + sl.forEach(function(item){ + a.push(item); + }); + t.assertEqual("orange,fab,shot,bar", a.join()); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/Stack.js b/includes/js/dojox/collections/tests/Stack.js new file mode 100644 index 0000000..7bf4e79 --- /dev/null +++ b/includes/js/dojox/collections/tests/Stack.js @@ -0,0 +1,49 @@ +if(!dojo._hasResource["dojox.collections.tests.Stack"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.Stack"] = true; +dojo.provide("dojox.collections.tests.Stack"); +dojo.require("dojox.collections.Stack"); + +tests.register("dojox.collections.tests.Stack", [ + function testCtor(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + t.assertEqual(4, s.count); + }, + function testClear(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + s.clear(); + t.assertEqual(0, s.count); + }, + function testClone(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + var cloned=s.clone(); + t.assertEqual(s.count, cloned.count); + t.assertEqual(s.toArray().join(), cloned.toArray().join()); + }, + function testContains(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + t.assertTrue(s.contains("bar")); + t.assertFalse(s.contains("faz")); + }, + function testGetIterator(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + var itr=s.getIterator(); + while(!itr.atEnd()){ itr.get(); } + t.assertEqual("bull", itr.element); + }, + function testPeek(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + t.assertEqual("bull", s.peek()); + }, + function testPop(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + t.assertEqual("bull", s.pop()); + t.assertEqual("test", s.pop()); + }, + function testPush(t){ + var s=new dojox.collections.Stack(["foo","bar","test","bull"]); + s.push("bug"); + t.assertEqual("bug", s.peek()); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/_base.js b/includes/js/dojox/collections/tests/_base.js new file mode 100644 index 0000000..f58a82c --- /dev/null +++ b/includes/js/dojox/collections/tests/_base.js @@ -0,0 +1,84 @@ +if(!dojo._hasResource["dojox.collections.tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests._base"] = true; +dojo.provide("dojox.collections.tests._base"); +dojo.require("dojox.collections"); + +tests.register("dojox.collections.tests._base", [ + function testDictionaryEntry(t){ + var d=new dojox.collections.DictionaryEntry("foo","bar"); + t.assertEqual("bar", d.valueOf()); + t.assertEqual("bar", d.toString()); + }, + + function testIterator(t){ + var itr=new dojox.collections.Iterator(["foo","bar","baz","zoo"]); + t.assertEqual("foo", itr.element); // test initialization + t.assertTrue(!itr.atEnd()); + t.assertEqual("foo", itr.get()); // make sure the first get doesn't advance. + t.assertEqual("bar", itr.get()); + t.assertEqual("baz", itr.get()); + t.assertEqual("zoo", itr.get()); + t.assertTrue(itr.atEnd()); + t.assertEqual(null, itr.get()); + + itr.reset(); + t.assertTrue(!itr.atEnd()); + t.assertEqual("foo", itr.element); + + // test map + var a=itr.map(function(elm){ + return elm+"-mapped"; + }); + itr=new dojox.collections.Iterator(a); + t.assertEqual("foo-mapped", itr.element); // test initialization + t.assertTrue(!itr.atEnd()); + t.assertEqual("foo-mapped", itr.get()); // make sure the first get doesn't advance. + t.assertEqual("bar-mapped", itr.get()); + t.assertEqual("baz-mapped", itr.get()); + t.assertEqual("zoo-mapped", itr.get()); + t.assertTrue(itr.atEnd()); + t.assertEqual(null, itr.get()); + }, + + function testDictionaryIterator(t){ + /* + in the context of any of the Dictionary-based collections, the + element would normally return a DictionaryEntry. However, since + the DictionaryIterator is really an iterator of pure objects, + we will just test with an object here. This means all property + names are lost in the translation, but...that's why there's a + DictionaryEntry object :) + */ + var itr=new dojox.collections.DictionaryIterator({ + first:"foo", second:"bar", third:"baz", fourth:"zoo" + }); + t.assertEqual("foo", itr.element); // test initialization + t.assertTrue(!itr.atEnd()); + t.assertEqual("foo", itr.get()); // make sure the first get doesn't advance. + t.assertEqual("bar", itr.get()); + t.assertEqual("baz", itr.get()); + t.assertEqual("zoo", itr.get()); + t.assertTrue(itr.atEnd()); + t.assertEqual(null, itr.get()); + + itr.reset(); + t.assertTrue(!itr.atEnd()); + t.assertEqual("foo", itr.element); + + // test map + var a=itr.map(function(elm){ + return elm+"-mapped"; + }); + itr=new dojox.collections.Iterator(a); + t.assertEqual("foo-mapped", itr.element); // test initialization + t.assertTrue(!itr.atEnd()); + t.assertEqual("foo-mapped", itr.get()); // make sure the first get doesn't advance. + t.assertEqual("bar-mapped", itr.get()); + t.assertEqual("baz-mapped", itr.get()); + t.assertEqual("zoo-mapped", itr.get()); + t.assertTrue(itr.atEnd()); + t.assertEqual(null, itr.get()); + } +]); + +} diff --git a/includes/js/dojox/collections/tests/collections.js b/includes/js/dojox/collections/tests/collections.js new file mode 100644 index 0000000..4fb2634 --- /dev/null +++ b/includes/js/dojox/collections/tests/collections.js @@ -0,0 +1,19 @@ +if(!dojo._hasResource["dojox.collections.tests.collections"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.collections.tests.collections"] = true; +dojo.provide("dojox.collections.tests.collections"); +dojo.require("dojox.collections"); + +try{ + dojo.require("dojox.collections.tests._base"); + dojo.require("dojox.collections.tests.ArrayList"); + dojo.require("dojox.collections.tests.BinaryTree"); + dojo.require("dojox.collections.tests.Dictionary"); + dojo.require("dojox.collections.tests.Queue"); + dojo.require("dojox.collections.tests.Set"); + dojo.require("dojox.collections.tests.SortedList"); + dojo.require("dojox.collections.tests.Stack"); +}catch(e){ + doh.debug(e); +} + +} diff --git a/includes/js/dojox/collections/tests/runTests.html b/includes/js/dojox/collections/tests/runTests.html new file mode 100644 index 0000000..37f26a6 --- /dev/null +++ b/includes/js/dojox/collections/tests/runTests.html @@ -0,0 +1,9 @@ + + + + Dojox.wire Unit Test Runner + + + Redirecting to D.O.H runner. + + -- cgit v1.2.3