issue71.t 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=71
  3. # Encode::decode fails in multiple ways. 1 with B::REGEXP refs unattached to PMOPs
  4. use Test::More tests => 3;
  5. use strict;
  6. BEGIN {
  7. unshift @INC, 't';
  8. require "test.pl";
  9. }
  10. use Config ();
  11. my $DEBUGGING = ($Config::Config{ccflags} =~ m/-DDEBUGGING/);
  12. my $ITHREADS = $Config::Config{useithreads};
  13. # Simplification of Encode::Alias to test SvANY(REGEXP)=SvANY(CALLREGCOMP)
  14. # e.g. Encode::Alias define_alias( qr/^(.*)$/ => '"\L$1"' ) creates REGEXP refs without PMOP's.
  15. my $script = <<'EOF';
  16. package my;
  17. our @a;
  18. sub f {
  19. my($alias,$name)=@_;
  20. unshift(@a, $alias => $name);
  21. my $find = "ok";
  22. my $val = $a[1];
  23. if ( ref($alias) eq 'Regexp' && $find =~ $alias ) {
  24. eval $val;
  25. }
  26. $find
  27. }
  28. package main;
  29. *f=*my::f;
  30. print "ok" if f(qr/^(.*)$/ => '"\L$1"');
  31. EOF
  32. use B::C;
  33. ctestok(1, "C", "ccode71i", $script,
  34. ($B::C::VERSION lt '1.35' ? "TODO " : ""). "SvANY(REGEXP)=SvANY(CALLREGCOMP)"
  35. );
  36. $script = <<'EOF';
  37. use Encode;
  38. my $x = 'abc';
  39. print "ok" if 'abc' eq Encode::decode('UTF-8', $x);
  40. EOF
  41. # These 2 tests failed until 1.35 because of stale QR Regexp (see test 1),
  42. # issue71 (const destruction) and issue76 (invalid cop_warnings).
  43. # rx: (?^i:^(?:US-?)ascii$)"
  44. use B::C;
  45. ctestok(2, "C", "ccode71i", $script,
  46. ($B::C::VERSION lt '1.35' or ($] > 5.008005 and $] < 5.011))
  47. ? "TODO C reg_temp_copy from invalid r->offs"
  48. : "C alias reg_temp_copy failed: Unknown encoding 'UTF-8'");
  49. SKIP: {
  50. #skip "hangs", 1 if !$DEBUGGING;
  51. skip "asserts", 1 if $DEBUGGING and $] < 5.011;
  52. #use B::CC;
  53. ctestok(3, "CC", "ccode71i", $script,
  54. (($B::C::VERSION lt '1.42_57') or $] < 5.011 or ($ITHREADS and $] > 5.013))
  55. ? "TODO CC Encode::decode croak: Assertion failed: (SvTYPE(TARG) == SVt_PVHV), function Perl_pp_padhv"
  56. : "CC");
  57. }