Is there an expectation/assertion for deep comparisons?
Can you give an example? Checking for equality on arrays, structs, etc should already compare all the keys/indexes.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Sure. I have this:
beforeEach( function( currentSpec ){
user = new xmdroot.model.beans.user();
});
it( " get/has UserSig should return properly ", function(){
sig1 = new xmdroot.model.beans.usersignature();
sig2 = new xmdroot.model.beans.usersignature();
sig1.setId(1);
sig2.setId(2);
user.addUserSignature( sig1 );
expect( user.hasUserSignature() ).toBe( true );
expect( user.getUserSignature() ).toBe( sig1 );
user.addUserSignature( sig2 );
expect( user.hasUserSignature() ).toBe( true );
expect( user.getUserSignature() ).toBe( sig2 );
});
I’m seeing equality here:
expect( user.getUserSignature() ).toBe( sig2 );
And when I dump user.getUserSignature(), it matches sig1 (the internal ID).
I worked around it by just doing:
expect( user.getUserSignature().getId() ).toBe( sig2.getId() );
but I was curious.
Ahh, so you’re trying to compare two CFC instances? Those would fall under the struct comparison in the assertion library which just does a compare of the public properties (UDFs). Since everyone could define a different method for comparing two CFC instances from a data perspective, I’m not sure how we’d handle that.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Ahh, so you’re trying to compare two CFC instances? Those would fall under the struct comparison in the assertion library which just does a compare of the public properties (UDFs).
Yep, that explains it. I’ll just continue checking appropriate getter return values!
Since everyone could define a different method for comparing two CFC instances from a data perspective, I’m not sure how we’d handle that.
Dunno what you mean about making a different method for comparison?