Created
March 17, 2010 12:03
-
-
Save clairvy/335158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| str.pl | |
| undef.pl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| default : test | |
| expand : undef.pl str.pl | |
| undef.pl : no.pl | |
| perl -pe 's/my \$$res;/my \$$res = undef;/' no.pl > undef.pl | |
| chmod +x undef.pl | |
| str.pl : no.pl | |
| perl -pe 's/my \$$res;/my \$$res = '"''"';/' no.pl > str.pl | |
| chmod +x str.pl | |
| test : expand | |
| prove ./test.pl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| sub test { | |
| local $SIG{ALRM} = sub { | |
| die; | |
| }; | |
| alarm 2; | |
| my $res; | |
| eval { | |
| chomp($res = <STDIN>); | |
| }; | |
| alarm 0; | |
| return $res; | |
| } | |
| print "1st : ", test(), "\n"; | |
| print "2nd : ", test(), "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| sub test { | |
| local $SIG{ALRM} = sub { | |
| die; | |
| }; | |
| alarm 2; | |
| my $res = ''; | |
| eval { | |
| chomp($res = <STDIN>); | |
| }; | |
| alarm 0; | |
| return $res; | |
| } | |
| print "1st : ", test(), "\n"; | |
| print "2nd : ", test(), "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Test::More 'no_plan'; | |
| my $expect = <<EOL; | |
| 1st : aa | |
| 2nd : | |
| EOL | |
| foreach my $base (qw(no undef str)) { | |
| is(`( echo aa; sleep 3; echo bb ) | ./$base.pl`, $expect, "test for $base"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| sub test { | |
| local $SIG{ALRM} = sub { | |
| die; | |
| }; | |
| alarm 2; | |
| my $res = undef; | |
| eval { | |
| chomp($res = <STDIN>); | |
| }; | |
| alarm 0; | |
| return $res; | |
| } | |
| print "1st : ", test(), "\n"; | |
| print "2nd : ", test(), "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment