[483] | 1 | dojo.provide("dojox.collections.tests.Set"); |
---|
| 2 | dojo.require("dojox.collections.Set"); |
---|
| 3 | |
---|
| 4 | (function(){ |
---|
| 5 | var dxcs=dojox.collections.Set; |
---|
| 6 | var a = ["apple","bear","candy","donut","epiphite","frank"]; |
---|
| 7 | var b = ["bear","epiphite","google","happy","joy"]; |
---|
| 8 | tests.register("dojox.collections.tests.Set", [ |
---|
| 9 | function testUnion(t){ |
---|
| 10 | var union=dxcs.union(a,b); |
---|
| 11 | t.assertEqual("apple,bear,candy,donut,epiphite,frank,google,happy,joy", union.toArray().join(',')); |
---|
| 12 | }, |
---|
| 13 | function testIntersection(t){ |
---|
| 14 | var itsn=dxcs.intersection(a,b); |
---|
| 15 | t.assertEqual("bear,epiphite", itsn.toArray().join(",")); |
---|
| 16 | t.assertEqual("bear", dxcs.intersection(["bear","apple"], ["bear"])); |
---|
| 17 | }, |
---|
| 18 | function testDifference(t){ |
---|
| 19 | var d=dxcs.difference(a,b); |
---|
| 20 | t.assertEqual("apple,candy,donut,frank",d.toArray().join(',')); |
---|
| 21 | }, |
---|
| 22 | function testIsSubSet(t){ |
---|
| 23 | t.assertFalse(dxcs.isSubSet(a,["bear","candy"])); |
---|
| 24 | t.assertTrue(dxcs.isSubSet(["bear","candy"],a)); |
---|
| 25 | }, |
---|
| 26 | function testIsSuperSet(t){ |
---|
| 27 | t.assertTrue(dxcs.isSuperSet(a,["bear","candy"])); |
---|
| 28 | t.assertFalse(dxcs.isSuperSet(["bear","candy"],a)); |
---|
| 29 | } |
---|
| 30 | ]); |
---|
| 31 | })(); |
---|