📄 gen-start-end-tags.pl
字号:
#!/usr/bin/perl -wuse strict;my @tags = ( "h1","h2","h3","h4","h5","h6", "table","ul","li","ol","td", "b","i","u","div", );my $the_tag;my $tests_body = "";my $num_tests = 0;foreach $the_tag (@tags){ my $start_or_end; foreach $start_or_end (qw(start end)) { my $slash = ($start_or_end eq "start") ? "" : "/"; $tests_body .= "is(${start_or_end}_${the_tag}(), \"<${slash}${the_tag}>\", \"${start_or_end}_${the_tag}\"); # TEST\n"; $num_tests++; if ($start_or_end eq "start") { $tests_body .= "is(${start_or_end}_${the_tag}({class => 'hello'}), \"<${slash}${the_tag} class=\\\"hello\\\">\", \"${start_or_end}_${the_tag} with param\"); # TEST\n"; $num_tests++; } } $tests_body .= "\n";}my $header1 = <<"EOF";#!/usr/local/bin/perl -wuse lib qw(t/lib);use strict;# Due to a bug in older versions of MakeMaker & Test::Harness, we must# ensure the blib's are in \@INC, else we might use the core CGI.pmuse lib qw(blib/lib blib/arch);EOF;my $header2 = "use Test::More tests => $num_tests;\n\n";my $header3;sub write_file{ my %args = (@_); local(*O); open O, ">t/start_end_" . $args{'filename'} . ".t\n"; my $content = $header1 . $header2 . "use CGI qw(:standard " . join(" ", @{$args{'use_params'}}) . ");\n\n" . $tests_body; print O $content; close(O);}write_file( "filename" => "asterisk", "use_params" => [ map {"\*$_" } @tags ],);write_file( "filename" => "start", "use_params" => [ map {"start_$_"} @tags],);write_file( "filename" => "end", "use_params" => [ map {"end_$_"} @tags],);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -