📄 output.t
字号:
#!perl -wBEGIN { if( $ENV{PERL_CORE} ) { chdir 't'; @INC = ('../lib', 'lib'); } else { unshift @INC, 't/lib'; }}chdir 't';# Can't use Test.pm, that's a 5.005 thing.print "1..4\n";my $test_num = 1;# Utility testing functions.sub ok ($;$) { my($test, $name) = @_; my $ok = ''; $ok .= "not " unless $test; $ok .= "ok $test_num"; $ok .= " - $name" if defined $name; $ok .= "\n"; print $ok; $test_num++; return $test;}use TieOut;use Test::Builder;my $Test = Test::Builder->new();my $result;my $tmpfile = 'foo.tmp';my $out = $Test->output($tmpfile);END { 1 while unlink($tmpfile) }ok( defined $out );print $out "hi!\n";close *$out;undef $out;open(IN, $tmpfile) or die $!;chomp(my $line = <IN>);close IN;ok($line eq 'hi!');open(FOO, ">>$tmpfile") or die $!;$out = $Test->output(\*FOO);$old = select *$out;print "Hello!\n";close *$out;undef $out;select $old;open(IN, $tmpfile) or die $!;my @lines = <IN>;close IN;ok($lines[1] =~ /Hello!/);# Ensure stray newline in name escaping works.$out = tie *FAKEOUT, 'TieOut';$Test->output(\*FAKEOUT);$Test->exported_to(__PACKAGE__);$Test->no_ending(1);$Test->plan(tests => 5);$Test->ok(1, "ok");$Test->ok(1, "ok\n");$Test->ok(1, "ok, like\nok");$Test->skip("wibble\nmoof");$Test->todo_skip("todo\nskip\n");my $output = $out->read;ok( $output eq <<OUTPUT ) || print STDERR $output;1..5ok 1 - okok 2 - ok# ok 3 - ok, like# okok 4 # skip wibble# moofnot ok 5 # TODO & SKIP todo# skip# OUTPUT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -