| 1 | #!/usr/bin/perl -w | ||
| 2 | |||
| 3 | # This is a judgement call but I have moved the | ||
| 4 | # the eval tests out of the main test suite because, | ||
| 5 | # unless you are connected to the Net and perl.com | ||
| 6 | # is up the tests are likely to fail which might | ||
| 7 | # cause issues. /shrug/ | ||
| 8 | # | ||
| 9 | |||
| 10 | use lib 'lib'; | ||
| 11 | use strict; | ||
| 12 | use WWW::Chat::Processor; | ||
| 13 | |||
| 14 | |||
| 15 | my $script = << 'EOS'; | ||
| 16 | GET http://www.perl.com | ||
| 17 | EXPECT OK | ||
| 18 | EOS | ||
| 19 | |||
| 20 | my $convert = WWW::Chat::Processor::parse ($script, '<inline>'); | ||
| 21 | |||
| 22 | |||
| 23 | eval $convert; | ||
| 24 | |||
| 25 | unless ($@) | ||
| 26 | { | ||
| 27 | print "ok 1\n"; | ||
| 28 | print "- successfully eval-ed converted code in 'main::' name space\n"; | ||
| 29 | } else { | ||
| 30 | print "not ok 1\n"; | ||
| 31 | print "- failed to eval converted code in 'main::' name space : $@\n"; | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | unless (SubPack::do($convert)) | ||
| 36 | { | ||
| 37 | print "ok 2\n"; | ||
| 38 | print "- successfully eval-ed code in none 'main::' name space\n"; | ||
| 39 | } else { | ||
| 40 | print "not ok 2\n"; | ||
| 41 | print "- failed to ev code in none 'main::' name space : $@\n"; | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 45 | undef $/; | ||
| 46 | my $oldscript = <DATA>; | ||
| 47 | eval $oldscript; | ||
| 48 | unless ($@) | ||
| 49 | { | ||
| 50 | print "ok 3\n"; | ||
| 51 | print "- successfully eval-ed old style code\n"; | ||
| 52 | } else { | ||
| 53 | print "not ok 3\n"; | ||
| 54 | print "-failed to eval old style code\n"; | ||
| 55 | } | ||
| 56 | |||
| 57 | exit 0; | ||
| 58 | |||
| 59 | package SubPack; | ||
| 60 | sub do | ||
| 61 | { | ||
| 62 | my $script = shift; | ||
| 63 | eval $script; | ||
| 64 | return $@; | ||
| 65 | } | ||
| 66 | |||
| 67 | package main; | ||
| 68 | |||
| 69 | __DATA__ |