issue301.t 612 B

1234567891011121314151617181920212223242526272829303132
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=301
  3. # detect (maybe|next)::(method|can) mro method calls
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require "test.pl";
  8. }
  9. use Test::More tests => 1;
  10. my $script = <<EOF;
  11. use mro;
  12. {
  13. package A;
  14. sub foo { 'A::foo' }
  15. }
  16. {
  17. package C;
  18. use base 'A';
  19. sub foo { (shift)->next::method() }
  20. }
  21. print qq{ok} if C->foo eq 'A::foo'
  22. EOF
  23. if ($] < 5.010) {
  24. $script =~ s/mro/NEXT/m;
  25. $script =~ s/next::/NEXT::/m;
  26. $script =~ s/method/foo/m;
  27. }
  28. # mro since 5.10 only
  29. ctestok(1, 'C,-O3', 'ccode301i', $script, '#301 next::method detection');