James E Keenan wrote:
How do you test that a variable has been tied to a class?

I looked through Test::More; the term 'tie' is conspicuous by its absence. I also searched the archives of this list and couldn't locate anything.

I'm looking for something along the lines of Test::More::isa_ok that we could use like this where the 'tie' call does not (at least in normal practice) explicitly return an object:

    use Tie::File;
    tie @data, 'Tie::File', $file or die;
    is_tied(@data, $file, "[EMAIL PROTECTED] is tied to \$file");

I partially answered my own question by looking at the tests MJD wrote for Tie::File. He has the 'tie' call explicitly return an object:

    # from 01_gen.t
    my $o = tie @a, 'Tie::File', $file, autochomp => 0, autodefer => 0;
    print $o ? "ok $N\n" : "not ok $N\n";
    $N++;

But he's not using *any* Perl test module here; everything is manual. So I'm still wondering if anybody has attempted something that says, in a self-documenting way, "Here I'm testing whether X is tied to Y."

Or perhaps this should be on the TODO list?

Jim Keenan

Reply via email to