Hi Alexandr,

Alexandr Ciornii schrieb:
I want to writes tests for 'use base' for Module::ScanDeps.
t/Utils.pm has two subs: generic_scandeps_rv_test &
compare_scandeps_rvs. Does anybody know what they do?

That's great news!

Adrian Issott wrote it when he added lots of tests to M::SD. I haven't followed closely, so I'd hope he is around to correct me.

generic_scandeps_rv_test: rv stands for return value here (not related to references as might be guessed in case of XS).

This is code using it from the 1-static_functional....t:

---
my @deps = qw(
    Carp.pm   Config.pm   Exporter.pm
    Test/More.pm  strict.pm   vars.pm
);

# Functional i/f
$rv = scan_deps($root);
generic_scandeps_rv_test($rv, [$0], [EMAIL PROTECTED]);
---

So the usage is generic_scandeps_rv_test($scandeps_return_value_to_test, [EMAIL PROTECTED], [EMAIL PROTECTED]).

The routine first checks that all known @deps and all input files have been found by scandeps in $rv. Then, it continues checking various attributes expected of the $rv struct such as:
- Do all the entries have the necessary keys such as 'key', 'file', 'type'?
- Does the key of the outer hash match that in of the inner hash/struct?
- Is the file name absolute?
- Is it a valid type?
- No duplicates in the used_by list?
- Everything that depends on an entry (i.e. all in it's used_by list) is part of $rv itself?
- Similar checks for the reverse mapping: 'uses'.

Now, compare_scandeps_rvs($test_rv, $reference_rv, [EMAIL PROTECTED]) runs generic_scandeps_rv_test() on the $test_rv and then compares the $test_rv to the $reference_rv expecting equality.

I really just read the code. It may be a little hard to follow depending on how much you know about the data structures used by M::SD.

Cheers,
Steffen

Reply via email to