Debug-Statements

 view release on metacpan or  search on metacpan

t/DebugStatementsTest.t  view on Meta::CPAN

    my $r_spell = qr(Check if you misspelled your variable name when you called);
    my $d_spell = 'scalar misspelled variable or wrong sigil';
    td '$misspelledvar', $r_spell, $d_spell;
    td '$list',       $r_spell, $d_spell;
    td '$nestedlist',    $r_spell, $d_spell;
    td '$hash',       $r_spell, $d_spell;
    td '$nestedhash',    $r_spell, $d_spell;
    td '$list[10]',   $r_spell, $d_spell;
    td '$hash{ten}',  $r_spell, $d_spell;
    my $warning = qr(WARNING:.*was given a reference to a variable instead of a single-quoted string);
    if ( $] lt '5.018' ) {
        #tsub 'd', '$scalar', $warning, 'scalar warning';
        tdd { d( \$scalar ) } $warning, 'scalar warning'; # 5.18
    }
    #td '\$scalar', $warning, 'warning';
    my $undefinedvar;
    my $expundef = "$header  \$undefinedvar = undef\n";
    tdd { d('$undefinedvar') } $expundef, 'scalar undef';
    #td '$undefinedvar', $expundef, 'undef';
    CLOSURE: {
        # Needed because $d is undef'd

t/DebugStatementsTest.t  view on Meta::CPAN

    say "\n### testOptions_multiple";
    tdd { d('$scalar') }       qr($header${vr}'myvalue'), '$scalar normal';
    tdd { d('@list') }    $rl, '@list  normal';
    tdd { d('%hash') }    $rh, '%hash  normal';
    my $i = 1;
    tdd { d('$listref->[$i]') }  qr($header${vr}'?$listref->[$i]'?), '$listref->[$i]';
    my $ref = 'flintstones';
    tdd { d('$nestedhashref->{$ref}') } $rnf, '$nestedhashref->{flintstones}';
    tdd { d('$Data::Dumper::Terse') } "$header  \$Data::Dumper::Terse = 1\n", 'package variable';
    my $allopt = 'bcenstz';
    if ( $] lt '5.018' ) {
        tdd { d('$scalar', $allopt) }       qr($header  At line undef:\s+[\$\@\%]\S+\s+=\s+'myvalue'\s+at\s+\S+), '$scalar with all options';
        my $rlest = qr($header\s+At line undef:.*\d+.*\s+${lsort}\s+at\s+\S+);
        my $rhest = qr($header\s+At line undef:.*\d+.*\s+${h}\s+at\s+\S+);
        tdd { d('@list', $allopt) }     $rlest, '@list with all options';
        tdd { d('%hash', $allopt) }     $rhest, '%hash with all options';
        tdd { d('$scalar', 'a') }       qr(does not understand your option), 'invalid option a';
    }
    # tests not implemented
    #d( '$listref->[$i]',         $allopt );
    #d( '$nestedhashref->{$ref}', $allopt );

t/DebugStatementsTest.t  view on Meta::CPAN

            $rd = '\S+\s+\d+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+';
        }
        my $header = 'DEBUG:  ls -l = ';
        $d = 0;
        tdd { ls($0) }                         qr(), "File ls($0)";
        tdd { LS($0) }                         qr($header$rd), "File ls($0)";
        $d = 1;
        tdd { ls("filename_does_not_exist") }  qr(does not exist), 'ls(filename_does_not_exist)';
        tdd { ls('$filename') }                qr(did not understand file name), "ls('\$filename') error";
        tdd { ls($0) }                         qr($header$rd), "File ls($0)";
        if ( $] lt '5.018' ) {
            tdd { ls('.') }                    qr($header$rd), "Directory ls(.)";
            tdd { ls("$0 $0") }                qr($header$rd.*\n$header$rd), "ls($0 $0)";
            tdd { ls("$0 .") }                 qr($header$rd.*\n$header$rd), "ls($0 .)";
            ##tdd { ls($filename), 2 }  '', 'ls() with too high a debug level';
        }
        ######### Need to create test for directory
        ######### Need to create test for ls('$dir', '-lR')
    }
}



( run in 0.732 second using v1.01-cache-2.11-cpan-cc502c75498 )