⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oneshot.pl

📁 source of perl for linux application,
💻 PL
📖 第 1 页 / 共 4 页
字号:
                    ok ! -e $out_file, "  Output file does not exist";                    writeFile($out_file, $already);                    my $out = new IO::File ">>$out_file" ;                    ok &$Func($in_file, $out, AutoClose => 1, Append => $append), '  Compressed ok' ;                    ok -e $out_file, "  Created output file";                    my $got = anyUncompress($out_file, $already);                    $got = undef if ! defined $buffer && $got eq '' ;                    is $got, $buffer, "  Uncompressed matches original";                }                {                    title "$TopType - From Filename to Buffer content '$disp_content' Append $append" ;                    my $lex = new LexFile(my $in_file, my $out_file) ;                    writeFile($in_file, $buffer);                    my $out = $already;                    ok &$Func($in_file => \$out, Append => $append), '  Compressed ok' ;                    my $got = anyUncompress(\$out, $already);                    $got = undef if ! defined $buffer && $got eq '' ;                    is $got, $buffer, "  Uncompressed matches original";                }                                {                    title "$TopType - From Handle to Filename content '$disp_content' Append $append" ;                    my $lex = new LexFile(my $in_file, my $out_file) ;                    writeFile($in_file, $buffer);                    my $in = new IO::File "<$in_file" ;                    ok ! -e $out_file, "  Output file does not exist";                    writeFile($out_file, $already);                    ok &$Func($in, $out_file, Append => $append), '  Compressed ok'                         or diag "error is $$Error" ;                    ok -e $out_file, "  Created output file";                    my $got = anyUncompress($out_file, $already);                    $got = undef if ! defined $buffer && $got eq '' ;                    is $buffer, $got, "  Uncompressed matches original";                }                {                    title "$TopType - From Handle to Handle content '$disp_content' Append $append" ;                    my $lex = new LexFile(my $in_file, my $out_file) ;                    writeFile($in_file, $buffer);                    my $in = new IO::File "<$in_file" ;                    ok ! -e $out_file, "  Output file does not exist";                    writeFile($out_file, $already);                    my $out = new IO::File ">>$out_file" ;                    ok &$Func($in, $out, AutoClose => 1, Append => $append), '  Compressed ok' ;                    ok -e $out_file, "  Created output file";                    my $got = anyUncompress($out_file, $already);                    $got = undef if ! defined $buffer && $got eq '' ;                    is $buffer, $got, "  Uncompressed matches original";                }                {                    title "$TopType - From Handle to Buffer content '$disp_content' Append $append" ;                    my $lex = new LexFile(my $in_file, my $out_file) ;                    writeFile($in_file, $buffer);                    my $in = new IO::File "<$in_file" ;                    my $out = $already ;                    ok &$Func($in, \$out, Append => $append), '  Compressed ok' ;                    my $got = anyUncompress(\$out, $already);                    $got = undef if ! defined $buffer && $got eq '' ;                    is $buffer, $got, "  Uncompressed matches original";                }                {                    title "$TopType - From stdin (via '-') to Buffer content '$disp_content' Append $append" ;                    my $lex = new LexFile(my $in_file, my $out_file) ;                    writeFile($in_file, $buffer);                       open(SAVEIN, "<&STDIN");                    my $dummy = fileno SAVEIN ;                    ok open(STDIN, "<$in_file"), "  redirect STDIN";                    my $out = $already;                    ok &$Func('-', \$out, Append => $append), '  Compressed ok'                         or diag $$Error ;                       open(STDIN, "<&SAVEIN");                    my $got = anyUncompress(\$out, $already);                    $got = undef if ! defined $buffer && $got eq '' ;                    is $buffer, $got, "  Uncompressed matches original";                }            }        }    }    foreach my $bit ($CompressClass)    {        my $Error = getErrorRef($bit);        my $Func = getTopFuncRef($bit);        my $TopType = getTopFuncName($bit);        my $TopTypeInverse = getInverse($bit);        my $FuncInverse = getTopFuncRef($TopTypeInverse);        my $lex = new LexFile(my $file1, my $file2) ;        writeFile($file1, "data1");        writeFile($file2, "data2");        my $of = new IO::File "<$file1" ;        ok $of, "  Created output filehandle" ;        #my @input = (   undef, "", $file2, \undef, \'', \"abcde", $of) ;        #my @expected = ("", "", $file2, "", "", "abcde", "data1");        #my @uexpected = ("", "", "data2", "", "", "abcde", "data1");        #my @input = (   $file2, \"abcde", $of) ;        #my @expected = ( $file2, "abcde", "data1");        #my @uexpected = ("data2", "abcde", "data1");        my @input = (   $file1, $file2) ;        #my @expected = ( $file1, $file2);        my @expected = ("data1", "data2");        my @uexpected = ("data1", "data2");        my @keep = @input ;        {            title "$TopType - From Array Ref to Array Ref" ;            my @output = ('first') ;            ok &$Func(\@input, \@output, AutoClose => 0), '  Compressed ok' ;            is $output[0], 'first', "  Array[0] unchanged";            is_deeply \@input, \@keep, "  Input array not changed" ;            my @got = shift @output;            foreach (@output) { push @got, anyUncompress($_) }            is_deeply \@got, ['first', @expected], "  Got Expected uncompressed data";        }        foreach my $ms (@MultiValues)        {            {                title "$TopType - From Array Ref to Buffer, MultiStream $ms" ;                # rewind the filehandle                $of->open("<$file1") ;                my $output  ;                ok &$Func(\@input, \$output, MultiStream => $ms, AutoClose => 0), '  Compressed ok'                     or diag $$Error;                my $got = anyUncompress([ \$output, MultiStream => $ms ]);                is $got, join('', @uexpected), "  Got Expected uncompressed data";                my @headers = getHeaders(\$output);                is @headers, $ms ? @input : 1, "  Header count ok";            }            {                title "$TopType - From Array Ref to Filename, MultiStream $ms" ;                my $lex = new LexFile( my $file3) ;                # rewind the filehandle                $of->open("<$file1") ;                my $output  ;                ok &$Func(\@input, $file3, MultiStream => $ms, AutoClose => 0), '  Compressed ok' ;                my $got = anyUncompress([ $file3, MultiStream => $ms ]);                is $got, join('', @uexpected), "  Got Expected uncompressed data";                my @headers = getHeaders($file3);                is @headers, $ms ? @input : 1, "  Header count ok";            }            {                title "$TopType - From Array Ref to Filehandle, MultiStream $ms" ;                my $lex = new LexFile(my $file3) ;                my $fh3 = new IO::File ">$file3";                # rewind the filehandle                $of->open("<$file1") ;                my $output  ;                ok &$Func(\@input, $fh3, MultiStream => $ms, AutoClose => 0), '  Compressed ok' ;                $fh3->close();                my $got = anyUncompress([ $file3, MultiStream => $ms ]);                is $got, join('', @uexpected), "  Got Expected uncompressed data";                my @headers = getHeaders($file3);                is @headers, $ms ? @input : 1, "  Header count ok";            }        }    }    foreach my $bit ($UncompressClass,                    #'IO::Uncompress::AnyUncompress',                    )    {        my $Error = getErrorRef($bit);        my $Func = getTopFuncRef($bit);        my $TopType = getTopFuncName($bit);        my $CompressClass = getInverse($bit);        my $C_Func = getTopFuncRef($CompressClass);                my $data = "mary had a little lamb" ;        my $keep = $data ;        my $extra = "after the main event";        foreach my $fb ( qw( filehandle buffer ) )        {            title "Trailingdata with $TopType, from $fb";            my $lex = new LexFile my $name ;            my $input ;            my $compressed ;            ok &$C_Func(\$data, \$compressed), '  Compressed ok' ;            $compressed .= $extra;            if ($fb eq 'buffer')            {                $input = \$compressed;            }            else            {                writeFile($name, $compressed);                $input = new IO::File "<$name" ;            }            my $trailing;            my $out;            ok $Func->($input, \$out, TrailingData => $trailing), "  Uncompressed OK" ;            is $out, $keep, "  Got uncompressed data";            my $rest = '';            if ($fb eq 'filehandle')            {                read($input, $rest, 10000) ;            }            is $trailing . $rest, $extra, "  Got trailing data";                    }    }#    foreach my $bit ($CompressClass)#    {#        my $Error = getErrorRef($bit);#        my $Func = getTopFuncRef($bit);#        my $TopType = getTopFuncName($bit);##        my $TopTypeInverse = getInverse($bit);#        my $FuncInverse = getTopFuncRef($TopTypeInverse);##        my @inFiles  = map { "in$_.tmp"  } 1..4;#        my @outFiles = map { "out$_.tmp" } 1..4;#        my $lex = new LexFile(@inFiles, @outFiles);##        writeFile($_, "data $_") foreach @inFiles ;#        #        {#            title "$TopType - Hash Ref: to filename" ;##            my $output ;#            ok &$Func( { $inFiles[0] => $outFiles[0],#                         $inFiles[1] => $outFiles[1],#                         $inFiles[2] => $outFiles[2] } ), '  Compressed ok' ;##            foreach (0 .. 2)#            {#                my $got = anyUncompress($outFiles[$_]);#                is $got, "data $inFiles[$_]", "  Uncompressed $_ matches original";#            }#        }##        {#            title "$TopType - Hash Ref: to buffer" ;##            my @buffer ;#            ok &$Func( { $inFiles[0] => \$buffer[0],#                         $inFiles[1] => \$buffer[1],#                         $inFiles[2] => \$buffer[2] } ), '  Compressed ok' ;##            foreach (0 .. 2)#            {#                my $got = anyUncompress(\$buffer[$_]);#                is $got, "data $inFiles[$_]", "  Uncompressed $_ matches original";#            }#        }##        {#            title "$TopType - Hash Ref: to undef" ;##            my @buffer ;#            my %hash = ( $inFiles[0] => undef,#                         $inFiles[1] => undef,#                         $inFiles[2] => undef, #                     );  ##            ok &$Func( \%hash ), '  Compressed ok' ;##            foreach (keys %hash)#            {#                my $got = anyUncompress(\$hash{$_});#                is $got, "data $_", "  Uncompressed $_ matches original";#            }#        }##        {#            title "$TopType - Filename to Hash Ref" ;##            my %output ;#            ok &$Func( $inFiles[0] => \%output), '  Compressed ok' ;##            is keys %output, 1, "  one pair in hash" ;#            my ($k, $v) = each %output;#            is $k, $inFiles[0], "  key is '$inFiles[0]'";#            my $got = anyUncompress($v);#            is $got, "data $inFiles[0]", "  Uncompressed matches original";#        }##        {#            title "$TopType - File Glob to Hash Ref" ;##            my %output ;#            ok &$Func( '<in*.tmp>' => \%output), '  Compressed ok' ;##            is keys %output, 4, "  four pairs in hash" ;#            foreach my $fil (@inFiles)#            {#                ok exists $output{$fil}, "  key '$fil' exists" ;#                my $got = anyUncompress($output{$fil});#                is $got, "data $fil", "  Uncompressed matches original";#            }#        }###    }#    foreach my $bit ($CompressClass)#    {#        my $Error = getErrorRef($bit);#        my $Func = getTopFuncRef($bit);#        my $TopType = getTopFuncName($bit);##        my $TopTypeInverse = getInverse($bit);#        my $FuncInverse = getTopFuncRef($TopTypeInverse);##        my @inFiles  = map { "in$_.tmp"  } 1..4;#        my @outFiles = map { "out$_.tmp" } 1..4;#        my $lex = new LexFile(@inFiles, @outFiles);##        writeFile($_, "data $_") foreach @inFiles ;#        ###    #    if (0)#    #    {#    #        title "$TopType - Hash Ref to Array Ref" ;#    ##    #        my @output = ('first') ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -