issue143.t 998 B

12345678910111213141516171819202122232425262728293031323334
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=143
  3. # wrong length after double regex compilation
  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 $todo = "TODO #143 " if $]>=5.010 and $]<5.012 and $Config::Config{useithreads};
  12. ctestok(1, "C,-O3", 'ccode143i', <<'EOS', $todo."wrong length after double regex compilation");
  13. BEGIN {
  14. package Net::IDN::Encode;
  15. our $DOT = qr/[\.]/;
  16. my $RE = qr/xx/;
  17. sub domain_to_ascii {
  18. my $x = shift || "";
  19. $x =~ m/$RE/o;
  20. return split( qr/($DOT)/o, $x);
  21. }
  22. }
  23. package main;
  24. Net::IDN::Encode::domain_to_ascii(42);
  25. print q(ok);
  26. EOS
  27. $todo = ($]>=5.010 and $]<5.012) ? "TODO #143 ":"";
  28. ctestok(2, "C,-O3", 'ccode143i', 'BEGIN{package Foo;our $DOT=qr/[.]/;};package main;print "ok\n" if "dot.dot" =~ m/($Foo::DOT)/', $todo."our qr");
  29. ctestok(3, "C,-O3", 'ccode143i', 'BEGIN{$DOT=qr/[.]/}print "ok\n" if "dot.dot" =~ m/($DOT)/',
  30. $todo."global qr");