http://qs321.pair.com?node_id=11135341


in reply to Inline::C : passing parameters to functions, modifying by reference

Hi bliako,

I sense that there's a bit you could do to simplify the task.
When I run your script I get:
C:\_32\pscrpt\inline>perl bliako.pl Case1: @out ok 1 - Case1: called success. ok 2 - Case1: rows are 5 not ok 3 - Case1 : item 0 is ARRAYref. # Failed test 'Case1 : item 0 is ARRAYref.' # at bliako.pl line 72. Bizarre copy of ARRAY in list assignment at C:/perl-5.34.0/lib/Test/Bu +ilder.pm line 802. # Tests were run but no plan was declared and done_testing() was not s +een. # Looks like your test exited with 255 just after 3.
I therefore wonder "why present us with all of the extra stuff that we don't even get to" ?
Much better, IMO, to consider just the part that's not working. (And then, if needed, proceed to the next part that fails to work when we've fixed the first failure.)

Doing a Devel::Peek::Dump of $out[$i] reveals that it is an array (and not a reference to an array). At least, that's how it looks to me:
ok 1 - Case1: called success. ok 2 - Case1: rows are 5 SV = PVAV(0x7ae098) at 0x33cab0 REFCNT = 1 FLAGS = () ARRAY = 0x2f0d7d8 FILL = 2 MAX = 3 FLAGS = (REAL) Elt No. 0 SV = IV(0x33cad0) at 0x33cae0 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42 Elt No. 1 SV = IV(0x33cab8) at 0x33cac8 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42 Elt No. 2 SV = IV(0x33cb30) at 0x33cb40 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42 not ok 3 - Case1 : item 0 is ARRAYref. # Failed test 'Case1 : item 0 is ARRAYref.'
So the test is reporting correctly.

I'm also a bit puzzled about the involvement of Test/Builder.pm. Do you know what it is it that pulls that module in ?

Cheers,
Rob