issue90.t 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=90
  3. # Magic Tie::Named::Capture <=> *main::+ main::*- and Errno vs !
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require "test.pl";
  8. }
  9. use Test::More tests => 9;
  10. my $i=0;
  11. sub test3 {
  12. my $name = shift;
  13. my $script = shift;
  14. my $cmt = join('',@_);
  15. my $todo;
  16. $todo = 'TODO %+ setting regdata magic crashes' if $name eq 'ccode90i_c';
  17. plctestok($i*3+1, $name, $script, $todo);
  18. ctestok($i*3+2, "C", $name, $script, "C $cmt");
  19. ctestok($i*3+3, "CC", $name, $script, "CC $cmt");
  20. $i++;
  21. }
  22. SKIP: {
  23. skip "Tie::Named::Capture requires Perl v5.10", 3 if $] < 5.010;
  24. test3('ccode90i_c', <<'EOF', '%+ includes Tie::Hash::NamedCapture');
  25. my $s = 'test string';
  26. $s =~ s/(?<first>test) (?<second>string)/\2 \1/g;
  27. print q(o) if $s eq 'string test';
  28. 'test string' =~ /(?<first>\w+) (?<second>\w+)/;
  29. print q(k) if $+{first} eq 'test';
  30. EOF
  31. }
  32. test3('ccode90i_es', <<'EOF', '%! magic');
  33. my %errs = %!; # t/op/magic.t Errno compiled in
  34. print q(ok) if defined ${"!"}{ENOENT};
  35. EOF
  36. # this fails so far, %{"!"} is not detected at compile-time. requires -uErrno
  37. test3('ccode90i_er', <<'EOF', 'TODO may require -uErrno');
  38. my %errs = %{"!"}; # t/op/magic.t Errno to be loaded at run-time
  39. print q(ok) if defined ${"!"}{ENOENT};
  40. EOF