- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Mon, 11 Apr 2011 13:15:55 -0700
- To: James Graham <jgraham@opera.com>
- Cc: Aryeh Gregor <Simetrical+w3c@gmail.com>, public-test-infra <public-test-infra@w3.org>
On 4/11/11, James Graham <jgraham@opera.com> wrote: > On 04/11/2011 01:32 AM, Garrett Smith wrote: >> On 4/10/11, James Graham<jgraham@opera.com> wrote: >>>> And again, a test that does that is a mistake. Quite obvious. >>> >>> How would you write a test that a structured clone correctly preserves >>> NaN values? >>> >> If needed, I would be including to write an >> `assert_object_equivalence`. In my style, that'd be more like: > > I don't see that having assert_equals and assert_object_equivalence that > do similar, but slightly different, things is at all clearer than having > a single method that has the useful behaviour from both. Apart from the > NaN case how would you expect these two methods to differ? > Comparing two things for equality means that they're either the same or they'r not. Object equivalence is for comparing if two objects have same properties. 1 === 1; // True. Equal. ({} === {}); // False. Equivalent, but not equal Object assertions are more complicated. FOr object assertions, I have sometimes needed to check things such as: hasProperty(object, propName[, val]); hasAllProperties(object, propertiesObject); doesNotHaveProperty(object, propName); Not always, but often what matters is if the actual object has a specific set of properties; whether or not it has any additional properties doesn't matter. Though sometimes you want to know if an object has exactly a set of properties, and no more. That depends on the usage. -- Garrett
Received on Monday, 11 April 2011 20:16:23 UTC