Author: allison
Date: Wed Apr 11 15:36:14 2007
New Revision: 18153

Modified:
   trunk/runtime/parrot/library/Test/More.pir
   trunk/t/library/test_more.t

Log:
Adding TODO functionality to the PIR Test::More, and tests for the feature.


Modified: trunk/runtime/parrot/library/Test/More.pir
==============================================================================
--- trunk/runtime/parrot/library/Test/More.pir  (original)
+++ trunk/runtime/parrot/library/Test/More.pir  Wed Apr 11 15:36:14 2007
@@ -37,6 +37,8 @@
     is_deeply( some_deep_pmc, another_deep_pmc, 'deep structure comparison' )
 
     like( 'foo', 'f o**{2}', 'passing regex compare with diagnostic' )
+    skip(1, 'reason for skipping')
+    todo(0, 'this is a failed test', 'reason for todo')
 
     $P0 = getclass "Squirrel"
     $P0.new()
@@ -773,6 +775,23 @@
     test.'skip'()
 .end
 
+=item C<todo( passed, description, reason )>
+
+Records a test as pass or fail (like C<ok>, but marks it as TODO so it always
+appears as a success. This also records the optional C<description> of the test
+and the C<reason> you have marked it as TODO.
+
+=cut
+
+.sub todo
+    .param pmc args :slurpy
+
+    .local pmc test
+    find_global test, 'Test::More', '_test'
+
+    test.todo( args :flat )
+.end
+
 =item C<isa_ok( object, class_name, object_name )>
 
 Pass if the object C<isa> class of the given class name.  The object

Modified: trunk/t/library/test_more.t
==============================================================================
--- trunk/t/library/test_more.t (original)
+++ trunk/t/library/test_more.t Wed Apr 11 15:36:14 2007
@@ -16,15 +16,16 @@
        .local pmc exports, curr_namespace, test_namespace
        curr_namespace = get_namespace
        test_namespace = get_namespace [ "Test::More" ]
-       exports = split " ", "ok is diag like skip is_deeply isa_ok"
+       exports = split " ", "ok is diag like skip todo is_deeply isa_ok"
        test_namespace.export_to(curr_namespace, exports)
 
        test_namespace = get_namespace [ "Test::Builder::Tester" ]
        exports = split " ", "plan test_out test_diag test_fail test_pass 
test_test"
        test_namespace.export_to(curr_namespace, exports)
 
-       plan( 53 )
+       plan( 58 )
        test_skip()
+       test_todo()
        test_ok()
        test_is()
        test_like()
@@ -353,6 +354,33 @@
        test_test( 'skip()' )
 .end
 
+.sub test_todo
+
+    .local pmc test
+    test = new 'Test::Builder'
+
+    test_out( 'ok 8 # TODO passing test' )
+    test.'todo'( 1, 'passing test', 'todo reason' )
+    test_test( 'todo test should pass, marked as TODO' )
+
+    test_out( 'not ok 9 # TODO failing test' )
+    test.'todo'( 0, 'failing test', 'todo reason' )
+    test_test( 'todo test should fail, marked as TODO' )
+
+    test_out( 'ok 10 # TODO passing test' )
+    todo( 1, 'passing test', 'todo reason' )
+    test_test( 'todo test should pass, marked as TODO' )
+
+    test_out( 'not ok 11 # TODO failing test' )
+    todo( 0, 'failing test', 'todo reason' )
+    test_test( 'todo test should fail, marked as TODO' )
+
+    test_out( 'not ok 12 # TODO' )
+    todo( 0 )
+    test_test( 'todo test with no description or reason' )
+
+.end
+
 .sub test_isa_ok
        .local pmc dog, terrier, daschund, Spot, Sossy
 

Reply via email to