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

<mx:Script>
<![CDATA[
	import Tests;
	private function appComplete():void
	{
		var dict:Dictionary = new Dictionary();
		var o:Object = new Object();
		
		dict["foo"] = 5;
		dict[o] = "muffins";

		Tests.assertTrue(dict.hasOwnProperty("foo"),"hasOwnProperty with string");
		
		Tests.assertEquals(dict["foo"], 5, "dict[\"foo\"] = 5", true);
		Tests.assertEquals(dict[o], "muffins", "dict[Object]", true);

		var count:int = 0;
		for each (var tmp:* in dict)
			count++;

		Tests.assertEquals(2, count, "iterator: primitive and object keys");
		
		delete dict["foo"];
		
		dict[2] = "number two";
		Tests.assertTrue(dict.hasOwnProperty(2), "hasOwnProperty with number");
		Tests.assertEquals(dict["2"], "number two", "primitive keys behaviour", true);
		Tests.assertFalse(dict["foo"] == 5, "delete dict[\"key\"]");
		
		var dict2:Dictionary = new Dictionary();
		dict2.weakKeys = true;
		{
			var a:Object = new Object();
			dict[a] = "test";
		}
		
		var n:int = 0;
		for (var key:* in dict2)
			n++;
		
		Tests.assertEquals(n, 1, "Dictionary.weakKeys");
		
		Tests.report(visual, name);
	}
]]>
</mx:Script>

<mx:UIComponent id="visual" />

</mx:Application>
