<?xml version="1.0"?>
<mx:Application name="lightspark_utils_Dicionary_test"
	xmlns:mx="http://www.adobe.com/2006/mxml"
	layout="absolute"
	applicationComplete="appComplete();"
	backgroundColor="white">

<mx:Script>
	<![CDATA[
	import flash.utils.Dictionary;
	private function appComplete():void
	{
		var dict:flash.utils.Dictionary=new flash.utils.Dictionary;
		Tests.assertEquals(false, dict.hasOwnProperty(this), "hasOwnProperty on non existant Dictionary item");
		dict[this]="Test";
		Tests.assertEquals(false, dict.hasOwnProperty(this), "hasOwnProperty on existant Dictionary item");

		var str1:String = "test123";
		var str2:String = new String(str1);
		var key:String = "123";
		var dict1:flash.utils.Dictionary=new flash.utils.Dictionary;
		var dict2:flash.utils.Dictionary=new flash.utils.Dictionary;
		var dict3:flash.utils.Dictionary=new flash.utils.Dictionary;
		var dict4:flash.utils.Dictionary;

		dict1[key] = str1;
		dict2[key] = str1;
		dict3[key] = str2;
		dict4 = dict1;

		Tests.assertTrue(dict1["123"] == dict2["123"], "Values equal");
		Tests.assertFalse(dict1 == dict2, "Dictionaries equal with same value object");
		Tests.assertFalse(dict1 == dict3, "Dictionaries equal with different value object");
		Tests.assertTrue(dict1 == dict4, "Dictionaries equal with itsself");

		var obj:Object = new Object();
		var obj2:Object = new Object();
		var dict5:Dictionary = new Dictionary();
		dict5[obj] = obj2;
		for(var o:Object in dict5)
		{
			Tests.assertEquals(o, obj, "Iterating over keys");
		}
		for each(var o2:Object in dict5)
		{
			Tests.assertEquals(o2, obj2, "Iterating over values");
		}
		Tests.assertTrue(obj in dict5, "Key in Dictionary");
		Tests.assertFalse(obj2 in dict5, "Value in Dictionary");

		Tests.report(visual, this.name);
	}
 ]]>
</mx:Script>

<mx:UIComponent id="visual" />

</mx:Application>
