summaryrefslogtreecommitdiff
path: root/includes/js/dojox/collections/tests/Stack.js
blob: 7bf4e79dbb183580a9ad9c58661b974ccdb20d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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());
	}
]);

}