Ticket #763: test-is_deeply-undef-vs-nonexist-handling.patch

File test-is_deeply-undef-vs-nonexist-handling.patch, 1.3 KB (added by Infinoid, 13 years ago)

test is_deeply()'s undef handling (though I'm not sure what the eventual diagnostic message should say)

  • t/library/test_more.t

    commit 2a1c636156dd0abb61f4da117dd42b6283e877ec
    Author: Mark Glines <mark@glines.org>
    Date:   Sun Jun 14 18:41:47 2009 -0400
    
        Test is_deeply()'s Undef vs. !exists handling.
    
    diff --git a/t/library/test_more.t b/t/library/test_more.t
    index 396b0b7..ee006ec 100644
    a b  
    2222    exports = split " ", "plan test_out test_diag test_fail test_pass test_test" 
    2323    test_namespace.'export_to'(curr_namespace, exports) 
    2424 
    25     plan( 75 ) 
     25    plan( 76 ) 
    2626 
    2727    test_skip() 
    2828    test_todo() 
     
    326326.sub test_is_deeply_hash 
    327327    .local pmc left 
    328328    .local pmc right 
     329    .local pmc undef1 
     330    .local pmc undef2 
    329331 
    330     left  = new 'Hash' 
    331     right = new 'Hash' 
     332    left   = new 'Hash' 
     333    right  = new 'Hash' 
     334    undef1 = new 'Undef' 
     335    undef2 = new 'Undef' 
    332336 
    333337    test_pass() 
    334338    is_deeply( left, right ) 
     
    369373    test_pass() 
    370374    is_deeply( left, right ) 
    371375    test_test( 'passing test is_deeply() for hashes created in different orders' ) 
     376 
     377    right['undef1'] = undef1 
     378    left['undef2']  = undef2 
     379    test_fail() 
     380    is_deeply( left, right ) 
     381    test_diag( 'Mismatch at [undef2]: expected Undef, received nonexistent' ) 
     382    test_test( 'failing is_deeply() for undef in left, nonexistent in right' ) 
    372383.end 
    373384 
    374385.sub test_is_deeply_mismatch