home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / t / op / exists_sub.t < prev    next >
Text File  |  2000-01-20  |  929b  |  47 lines

  1. #!./perl
  2.  
  3. BEGIN {
  4.     chdir 't' if -d 't';
  5.     unshift @INC, '../lib';
  6. }
  7.  
  8. print "1..9\n";
  9.  
  10. sub t1;
  11. sub t2 : locked;
  12. sub t3 ();
  13. sub t4 ($);
  14. sub t5 {1;}
  15. {
  16.     package P1;
  17.     sub tmc {1;}
  18.     package P2;
  19.     @ISA = 'P1';
  20. }
  21.  
  22. print "not " unless exists &t1 && not defined &t1;
  23. print "ok 1\n";
  24. print "not " unless exists &t2 && not defined &t2;
  25. print "ok 2\n";
  26. print "not " unless exists &t3 && not defined &t3;
  27. print "ok 3\n";
  28. print "not " unless exists &t4 && not defined &t4;
  29. print "ok 4\n";
  30. print "not " unless exists &t5 && defined &t5;
  31. print "ok 5\n";
  32. P2::->tmc;
  33. print "not " unless not exists &P2::tmc && not defined &P2::tmc;
  34. print "ok 6\n";
  35. my $ref;
  36. $ref->{A}[0] = \&t4;
  37. print "not " unless exists &{$ref->{A}[0]} && not defined &{$ref->{A}[0]};
  38. print "ok 7\n";
  39. undef &P1::tmc;
  40. print "not " unless exists &P1::tmc && not defined &P1::tmc;
  41. print "ok 8\n";
  42. eval 'exists &t5()';
  43. print "not " unless $@;
  44. print "ok 9\n";
  45.  
  46. exit 0;
  47.