jsunity patch for array stringification

6 views
Skip to first unread message

Bernhard Wagner

unread,
Feb 14, 2012, 6:47:40 PM2/14/12
to jsuni...@googlegroups.com
http://code.google.com/p/jsunity/issues/detail?id=8

jsunity will rightly complain that [[1],2], [1,2] are unequal:
assertEqual([[1],2], [1,2])

However, the output is confusing:
assertEqual: (1,2) is not equal to (1,2)

The patch I'm proposing changes the output to this:
assertEqual: ([1, 2]) is not equal to ([[1], 2])

It does so by finding the type of the argument and using that as a key
into a map that returns the stringify function for that particular type or
null. When null is returned, the default toString() is used.
With this map it is easy to extend the Stringification for other types.

The patch applies to r152
(http://code.google.com/p/jsunity/source/browse/trunk/jsunity/downloads/jsunity-0.6.js).

Would you accept this patch?

Thank you
Bernhard

Bernhard Wagner

unread,
Feb 14, 2012, 6:54:44 PM2/14/12
to jsuni...@googlegroups.com
Please find the patch and tests in the attachment.
jsunityArray.patch
testarray.js
Reply all
Reply to author
Forward
0 new messages