issue27.t 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=27
  3. # run-time require fails at *DynaLoader::Config = *Config::Config
  4. use strict;
  5. BEGIN {
  6. unless (eval "require LWP::UserAgent;") {
  7. print "1..0 #skip LWP::UserAgent not installed\n";
  8. exit;
  9. }
  10. }
  11. use Test::More tests => 3;
  12. my $X = $^X =~ m/\s/ ? qq{"$^X" -Iblib/arch -Iblib/lib} : "$^X -Iblib/arch -Iblib/lib";
  13. my $perlcc = $^O eq 'MSWin32' ? "blib\\script\\perlcc" : 'blib/script/perlcc';
  14. my $opt = '';
  15. $opt .= ",-fno-warnings" if $] >= 5.013005;
  16. $opt .= ",-fno-fold" if $] >= 5.013009;
  17. $opt = "-Wb=".substr($opt,1) if $opt;
  18. # -fno-warnings order: Carp requires DynaLoader
  19. #TODO: {
  20. # fixed with 1.48
  21. # local $TODO = 'use -fno-warnings, always and save 550KB for small scripts' if $] >= 5.013005;
  22. # Attempt to reload Config.pm aborted.
  23. # Global symbol "%Config" requires explicit package name at 5.8.9/Time/Local.pm line 36
  24. # 5.15: Undefined subroutine &utf8::SWASHNEW called at /usr/local/lib/perl5/5.15.3/constant.pm line 36
  25. # old: &Config::AUTOLOAD failed on Config::launcher at Config.pm line 72.
  26. is(`$X $perlcc -O2 -occodei27_o2 -r -e"require LWP::UserAgent;print q(ok);"`, 'ok',
  27. "-O2 require LWP::UserAgent without -fno-warnings");
  28. #}
  29. # fine with -fno-warnings
  30. is(`$X $perlcc $opt -occodei27 -r -e"require LWP::UserAgent;print q(ok);"`, 'ok',
  31. "require LWP::UserAgent $opt");
  32. # With -O3 ditto (includes -fno-warnings)
  33. is(`$X $perlcc -O3 -occodei27_o3 -r -e"require LWP::UserAgent;print q(ok);"`, 'ok',
  34. "-O3 require LWP::UserAgent");
  35. END {
  36. unlink qw(ccodei27 ccodei27.c);
  37. unlink qw(ccodei27_o2 ccodei27_o2.c);
  38. unlink qw(ccodei27_o3 ccodei27_o3.c);
  39. }