Davis Ford wrote: > > > Hi Paul, > > I don't believe this is correct for ActionScript3. Strict equality is > the "===" operator which compares object instances. "==" should test > for equality. I tried (in Flash)..
var objA:Object = {a:1}; var objB:Object = {a:1}; trace(objA==objB); // false var xmlA:XML = <x>xxx</x>; var xmlB:XML = <x>xxx</x>; trace(xmlA==xmlB); // true trace(xmlA===xmlB); // false and indeed you are right. I didn't know that XML was treated differently from vanilla object in comparisons. Thanks. Paul > > If you change the test to this... > > [Test] > public function testXmlEquality():void { > var xml1:XML = > <a> > <b></b> > <c></c> > </a>; > var xml2:XML = > <a> > <b></b> > <c></c> > </a>; > xml1.normalize(); > xml2.normalize(); > Assert.assertTrue(xml1 == xml2); > } > > it passes. XML/e4x is supposed to support this out of the box, and it > does -- to a degree. Although, semantically and syntactically, xml1 > and xml2 from the 1st test are equivalent, e4x is not thinking so, and > I think that is broken. Searching for a workaround has popped up very > little, which is why I was hoping someone on the list might have a > good answer for why this is, and how I can test XML equivalence > without caring about element ordering. > > Regards, > Davis > > On Wed, Jan 6, 2010 at 7:03 PM, Paul Andrews <p...@ipauland.com > <mailto:p...@ipauland.com>> wrote: > > > Davis Ford wrote: > > > > > > Why does this test fail? Is there any way to test for equality that > > ignores the ordering of elements -- which shouldn't technically > matter? > > > > [Test] > > public function testXmlEquality():void { > > var xml1:XML = > > <a> > > <b></b> > > <c></c> > > </a>; > > var xml2:XML = > > <a> > > <c></c> > > <b></b> > > </a>; > > Assert.assertTrue(xml1 == xml2); > > } > xml1 and xml2 are references to objects. Because they are different > objects they are not equal - the references are different. > > > > > > > > > > > > > > > -- > Zeno Consulting, Inc. > home: http://www.zenoconsulting.biz > blog: http://zenoconsulting.wikidot.com > p: 248.894.4922 > f: 313.884.2977 > > > ------------------------------------ -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: flexcoders-dig...@yahoogroups.com flexcoders-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: flexcoders-unsubscr...@yahoogroups.com <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/