[Bps-public-commit] Date-Extract branch, master, updated. 049281057785cdf511b7e456069cd3f0fb2a8d13

Thomas Sibley trs at bestpractical.com
Thu Aug 19 02:14:23 EDT 2010


The branch, master has been updated
       via  049281057785cdf511b7e456069cd3f0fb2a8d13 (commit)
      from  a037722ad52dd96c7600ec25704b10c75fecf270 (commit)

Summary of changes:
 t/04-formats.t |   51 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 32 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit 049281057785cdf511b7e456069cd3f0fb2a8d13
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Aug 19 01:58:58 2010 -0400

    Fix up the format tests so we can run the ones that work
    
    This TODOs the ones that we don't handle yet, which is how it should be
    instead of skipping the entire file.

diff --git a/t/04-formats.t b/t/04-formats.t
index 849721f..d49237a 100644
--- a/t/04-formats.t
+++ b/t/04-formats.t
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More skip_all => "not finished yet";
+use Test::More;
 use Date::Extract;
 
 my %formats = (
@@ -21,15 +21,17 @@ my %formats = (
             is($_->day_name, 'Monday', "next Monday");
             cmp_ok($_->epoch, '>', DateTime->today->epoch, "next Monday");
         },
-    'previous Sat' =>
-        sub {
+    'previous Sat' => {
+        TODO => 'Not handled by us or DTFN yet',
+        test => sub {
             is($_->day_name, 'Saturday', "previous Sat");
             cmp_ok($_->epoch, '<', DateTime->today->epoch, "previous Sat");
         },
+    },
     'Monday' =>
-        sub { is($_->day_name, 'Monday', "previous Sat") },
+        sub { is($_->day_name, 'Monday', "Monday") },
     'Mon' =>
-        sub { is($_->day_name, 'Mon', "previous Sat") },
+        sub { is($_->day_name, 'Monday', "Mon") },
     'November 13th, 1986' =>
         sub { is($_->ymd, '1986-11-13', "November 13th, 1986") },
     'Nov 13, 1986' =>
@@ -46,25 +48,36 @@ my %formats = (
         sub { is($_->ymd, '1986-11-13', "1986/11/13") },
     '1986-11-13' =>
         sub { is($_->ymd, '1986-11-13', "1986-11-13") },
-    '11-13-86' =>
-        sub { is($_->ymd, '1986-11-13', "11-13-86") },
-    '11/13/1986' =>
-        sub { is($_->ymd, '1986-11-13', "11/13/1986") },
+    '11-13-86' => {
+        TODO => 'Not handled by us or DTFN yet',
+        test => sub { is($_->ymd, '1986-11-13', "11-13-86") },
+    },
+    '11/13/1986' => {
+        TODO => 'Not handled by us or DTFN yet',
+        test => sub { is($_->ymd, '1986-11-13', "11/13/1986") },
+    },
 );
 
-plan tests => 3 + 2 * keys(%formats);
+plan tests => 2 + 2 * keys(%formats);
 
 while (my ($input, $checker) = each %formats) {
-    my $got = Date::Extract->extract($input);
-    ok($got, "got a date out of $input");
+    $checker = { test => $checker }
+        if ref $checker eq 'CODE';
 
-    unless ($got) {
-        fail("No date parsed, so no use running the checker");
-        next;
-    }
+    TODO: {
+        local $TODO = $checker->{'TODO'} if $checker->{'TODO'};
+
+        my $got = Date::Extract->extract($input);
+        ok($got, "got a date out of $input");
 
-    local $_ = $got;
-    local $Test::Builder::Level = $Test::Builder::Level + 1;
-    $checker->();
+        unless ($got) {
+            fail("No date parsed, so no use running the checker");
+            next;
+        }
+
+        local $_ = $got;
+        local $Test::Builder::Level = $Test::Builder::Level + 1;
+        $checker->{'test'}->();
+    }
 }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list