t / t9000 / test.plon commit Merge branch 'rs/apply-avoid-over-reading' (6fee4ca)
   1#!/usr/bin/perl
   2use lib (split(/:/, $ENV{GITPERLLIB}));
   3
   4use 5.008;
   5use warnings;
   6use strict;
   7
   8use Test::More qw(no_plan);
   9use Mail::Address;
  10
  11BEGIN { use_ok('Git') }
  12
  13my @success_list = (q[Jane],
  14        q[jdoe@example.com],
  15        q[<jdoe@example.com>],
  16        q[Jane <jdoe@example.com>],
  17        q[Jane Doe <jdoe@example.com>],
  18        q["Jane" <jdoe@example.com>],
  19        q["Doe, Jane" <jdoe@example.com>],
  20        q["Jane@:;\>.,()<Doe" <jdoe@example.com>],
  21        q[Jane!#$%&'*+-/=?^_{|}~Doe' <jdoe@example.com>],
  22        q["<jdoe@example.com>"],
  23        q["Jane jdoe@example.com"],
  24        q[Jane Doe <jdoe    @   example.com  >],
  25        q[Jane       Doe <  jdoe@example.com  >],
  26        q[Jane @ Doe @ Jane @ Doe],
  27        q["Jane, 'Doe'" <jdoe@example.com>],
  28        q['Doe, "Jane' <jdoe@example.com>],
  29        q["Jane" "Do"e <jdoe@example.com>],
  30        q["Jane' Doe" <jdoe@example.com>],
  31        q["Jane Doe <jdoe@example.com>" <jdoe@example.com>],
  32        q["Jane\" Doe" <jdoe@example.com>],
  33        q[Doe, jane <jdoe@example.com>],
  34        q["Jane Doe <jdoe@example.com>],
  35        q['Jane 'Doe' <jdoe@example.com>],
  36        q[Jane@:;\.,()<>Doe <jdoe@example.com>],
  37        q[Jane <jdoe@example.com> Doe],
  38        q[<jdoe@example.com> Jane Doe]);
  39
  40my @known_failure_list = (q[Jane\ Doe <jdoe@example.com>],
  41        q["Doe, Ja"ne <jdoe@example.com>],
  42        q["Doe, Katarina" Jane <jdoe@example.com>],
  43        q[Jane jdoe@example.com],
  44        q["Jane "Kat"a" ri"na" ",Doe" <jdoe@example.com>],
  45        q[Jane Doe],
  46        q[Jane "Doe <jdoe@example.com>"],
  47        q[\"Jane Doe <jdoe@example.com>],
  48        q[Jane\"\" Doe <jdoe@example.com>],
  49        q['Jane "Katarina\" \' Doe' <jdoe@example.com>]);
  50
  51foreach my $str (@success_list) {
  52        my @expected = map { $_->format } Mail::Address->parse("$str");
  53        my @actual = Git::parse_mailboxes("$str");
  54        is_deeply(\@expected, \@actual, qq[same output : $str]);
  55}
  56
  57TODO: {
  58        local $TODO = "known breakage";
  59        foreach my $str (@known_failure_list) {
  60                my @expected = map { $_->format } Mail::Address->parse("$str");
  61                my @actual = Git::parse_mailboxes("$str");
  62                is_deeply(\@expected, \@actual, qq[same output : $str]);
  63        }
  64}
  65
  66my $is_passing = eval { Test::More->is_passing };
  67exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/;