1 if(!dojo._hasResource["dojox.collections.tests.SortedList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.collections.tests.SortedList"] = true;
3 dojo.provide("dojox.collections.tests.SortedList");
4 dojo.require("dojox.collections.SortedList");
6 tests.register("dojox.collections.tests.SortedList", [
8 var sl=new dojox.collections.SortedList();
9 t.assertTrue(sl instanceof dojox.collections.SortedList);
12 var sl=new dojox.collections.SortedList();
14 t.assertEqual("bar", sl.item("foo").valueOf());
16 function testClear(t){
17 var sl=new dojox.collections.SortedList();
20 t.assertEqual(0, sl.count);
22 function testClone(t){
23 var sl=new dojox.collections.SortedList();
26 sl.add("buck","shot");
27 sl.add("apple","orange");
29 t.assertTrue(sl2.contains("baz"));
31 function testContains(t){
32 var sl=new dojox.collections.SortedList();
35 sl.add("buck","shot");
36 sl.add("apple","orange");
37 t.assertTrue(sl.contains("baz"));
38 t.assertFalse(sl.contains("faz"));
40 function testContainsKey(t){
41 var sl=new dojox.collections.SortedList();
44 sl.add("buck","shot");
45 sl.add("apple","orange");
46 t.assertTrue(sl.containsKey("buck"));
47 t.assertFalse(sl.containsKey("faz"));
49 function testContainsValue(t){
50 var sl=new dojox.collections.SortedList();
53 sl.add("buck","shot");
54 sl.add("apple","orange");
55 t.assertTrue(sl.containsValue("shot"));
56 t.assertFalse(sl.containsValue("faz"));
58 function testGetKeyList(t){
59 var sl=new dojox.collections.SortedList();
62 sl.add("buck","shot");
63 sl.add("apple","orange");
64 t.assertEqual("foo,baz,buck,apple",sl.getKeyList().join(','));
66 function testGetValueList(t){
67 var sl=new dojox.collections.SortedList();
70 sl.add("buck","shot");
71 sl.add("apple","orange");
72 t.assertEqual("bar,fab,shot,orange",sl.getValueList().join(','));
74 function testCopyTo(t){
75 var sl=new dojox.collections.SortedList();
78 sl.add("buck","shot");
79 sl.add("apple","orange");
82 t.assertEqual("bar,fab,shot,orange,bek", arr.join(','));
84 function testGetByIndex(t){
85 var sl=new dojox.collections.SortedList();
88 sl.add("buck","shot");
89 sl.add("apple","orange");
90 t.assertEqual("shot", sl.getByIndex(2));
92 function testGetKey(t){
93 var sl=new dojox.collections.SortedList();
96 sl.add("buck","shot");
97 sl.add("apple","orange");
98 t.assertEqual("apple", sl.getKey(0));
100 function testIndexOfKey(t){
101 var sl=new dojox.collections.SortedList();
104 sl.add("buck","shot");
105 sl.add("apple","orange");
106 t.assertEqual(0, sl.indexOfKey("apple"));
108 function testIndexOfValue(t){
109 var sl=new dojox.collections.SortedList();
112 sl.add("buck","shot");
113 sl.add("apple","orange");
114 t.assertEqual(3, sl.indexOfValue("bar"));
116 function testRemove(t){
117 var sl=new dojox.collections.SortedList();
120 sl.add("buck","shot");
121 sl.add("apple","orange");
123 t.assertEqual(3, sl.count);
124 t.assertEqual(undefined, sl.item("baz"));
126 function testRemoveAt(t){
127 var sl=new dojox.collections.SortedList();
130 sl.add("buck","shot");
131 sl.add("apple","orange");
133 t.assertEqual(undefined, sl.item("buck"));
135 function testReplace(t){
136 var sl=new dojox.collections.SortedList();
139 sl.add("buck","shot");
140 sl.add("apple","orange");
141 sl.replace("buck","dollar");
142 t.assertEqual(sl.item("buck").valueOf(), "dollar");
144 function testSetByIndex(t){
145 var sl=new dojox.collections.SortedList();
148 sl.add("buck","shot");
149 sl.add("apple","orange");
150 sl.setByIndex(0, "bar");
151 t.assertEqual("bar", sl.getByIndex(0));
153 function testSorting(t){
154 var sl=new dojox.collections.SortedList();
157 sl.add("buck","shot");
158 sl.add("apple","orange");
161 sl.forEach(function(item){
164 t.assertEqual("orange,fab,shot,bar", a.join());