Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

is_deeply() is painful

3 views
Skip to first unread message

Chromatic

unread,
Apr 26, 2006, 3:05:15 PM4/26/06
to perl6-i...@perl.org
Hi all,

I'm working on is_deeply() for Test::More in PIR. Handling nested data
structures is painful in PIR. I'm not asking for better abstractions to
handle that, just ideas on how to handle the algorithm.

Multidispatch helps, but :multi( Array, Array ) or :multi( Hash, Hash ) don't
work based on the capabilities of the PMC. That's fine.

With Parrot's type system, where the writer of the code (me) doesn't know at
code writing time what the type of the incoming data structures or individual
data members might be, what's a concise and maintainable way to port
is_deeply() to PIR?

(I keep asking myself "How would I do this in C?" and the answer keeps being
"Ugh, I wouldn't.")

-- c

Audrey Tang

unread,
Apr 26, 2006, 3:17:27 PM4/26/06
to chromatic, perl6-i...@perl.org
chromatic wrote:
> With Parrot's type system, where the writer of the code (me) doesn't know at
> code writing time what the type of the incoming data structures or individual
> data members might be, what's a concise and maintainable way to port
> is_deeply() to PIR?

Try a :multi first; if unsuccessful, compare type, and if match,
serialize both sides using freeze_pmc (or some kind of Dumper), and
compare the strings?

Thanks,
Audrey

signature.asc

Chromatic

unread,
Apr 26, 2006, 5:19:01 PM4/26/06
to perl6-i...@perl.org, Audrey Tang
On Wednesday 26 April 2006 12:17, Audrey Tang wrote:

> Try a :multi first; if unsuccessful, compare type, and if match,
> serialize both sides using freeze_pmc (or some kind of Dumper), and
> compare the strings?

I do have multis for primitive types (I,N,S,P), but when I have an array of
arrays to compare with an array of hashes or an array of ints things get more
complex, especially when I want to emit diagnostics about where the two data
structures did not match on failure.

I should have been more specific.

-- c

Leopold Toetsch

unread,
Apr 27, 2006, 5:29:21 AM4/27/06
to chromatic, perl6-i...@perl.org

On Apr 26, 2006, at 21:05, chromatic wrote:

> Multidispatch helps, but :multi( Array, Array ) or :multi( Hash, Hash
> ) don't
> work based on the capabilities of the PMC. That's fine.

does_foo = does $Px, 'array' # 'hash'

might help.

There should be no problem with .Hash, but there are a lot of array
types around.

leo

0 new messages