Search the web
Sign In
New User? Sign Up
jsunit
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Testing for Object equality   Message List  
Reply | Forward Message #1194 of 1231 |
Hi all,

I'm just getting started with JSUnit and with xUnit in general, and was wanted to make sure I'm on the right track.

In one test I am writing I want to compare two (arrays of) object literals:

var defaults = [{ color: "blue", size: 'small'},...];

Simply using assertEquals will fail since they are not the same Object:

assertEquals(defaults, getDefaults()); // Fails

I have found that by using checking myObj.toSource() instead of myObj the test seems to work okay.

assertEquals(defaults.toSource(), getDefaults().toSource()); // Works!

So, my question is: Is this an appropriate method of testing what I want to test? Is there a better method?

Any advice or feedback would be greatly appreciated :)

Thanks!
Keith

Fri Feb 27, 2009 4:10 pm

pwnedd
Offline Offline
Send Email Send Email

Forward
Message #1194 of 1231 |
Expand Messages Author Sort by Date

Hi all, I'm just getting started with JSUnit and with xUnit in general, and was wanted to make sure I'm on the right track. In one test I am writing I want to...
Keith Hughitt
pwnedd
Offline Send Email
Mar 3, 2009
12:53 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help