[svn:parrot] r41541 - in trunk: runtime/parrot/library/Test t/library
dukeleto at svn.parrot.org
dukeleto at svn.parrot.org
Mon Sep 28 08:30:19 UTC 2009
Author: dukeleto
Date: Mon Sep 28 08:30:18 2009
New Revision: 41541
URL: https://trac.parrot.org/parrot/changeset/41541
Log:
[t][TT #763] Fix is_deeply() on hashes with undefs and add tests
Modified:
trunk/runtime/parrot/library/Test/More.pir
trunk/t/library/test_more.t
Modified: trunk/runtime/parrot/library/Test/More.pir
==============================================================================
--- trunk/runtime/parrot/library/Test/More.pir Sun Sep 27 22:00:44 2009 (r41540)
+++ trunk/runtime/parrot/library/Test/More.pir Mon Sep 28 08:30:18 2009 (r41541)
@@ -519,9 +519,32 @@
.local string left_value
.local string right_value
- right_value = pop position
- left_value = pop position
+ .local pmc left, right
+ right = pop position
+ left = pop position
+
+ check_right_null:
+ .local int rnull
+ rnull = isnull right
+ unless rnull goto set_right
+ right_value = 'nonexistent'
+ goto check_left_null
+
+ set_right:
+ right_value = right
+
+ check_left_null:
+ .local int lnull
+ lnull = isnull left
+ unless lnull goto set_left
+ left_value = 'undef'
+ goto create_diag
+
+ set_left:
+ left_value = left
+
+ create_diag:
.local string nested_path
nested_path = join '][', position
Modified: trunk/t/library/test_more.t
==============================================================================
--- trunk/t/library/test_more.t Sun Sep 27 22:00:44 2009 (r41540)
+++ trunk/t/library/test_more.t Mon Sep 28 08:30:18 2009 (r41541)
@@ -22,7 +22,7 @@
exports = split " ", "plan test_out test_diag test_fail test_pass test_test"
test_namespace.'export_to'(curr_namespace, exports)
- plan( 89 )
+ plan( 93 )
test_skip()
test_todo()
@@ -393,6 +393,7 @@
.sub test_is_deeply
test_is_deeply_array()
test_is_deeply_hash()
+ test_is_deeply_hash_tt763()
test_is_deeply_mismatch()
test_is_deeply_nested()
.end
@@ -443,9 +444,13 @@
.sub test_is_deeply_hash
.local pmc left
.local pmc right
+ .local pmc undef1
+ .local pmc undef2
- left = new 'Hash'
- right = new 'Hash'
+ left = new 'Hash'
+ right = new 'Hash'
+ undef1 = new 'Undef'
+ undef2 = new 'Undef'
test_pass()
is_deeply( left, right )
@@ -488,6 +493,44 @@
test_test( 'passing test is_deeply() for hashes created in different orders' )
.end
+.sub test_is_deeply_hash_tt763
+ .local pmc left
+ .local pmc right
+ .local pmc undef1
+ .local pmc undef2
+
+ left = new 'Hash'
+ right = new 'Hash'
+ undef1 = new 'Undef'
+ undef2 = new 'Undef'
+ right['undef1'] = undef1
+ left['undef2'] = undef2
+
+ test_fail()
+ is_deeply( left, right )
+ test_diag( 'Mismatch at [undef2]: expected (undef), received nonexistent' )
+ test_test( 'failing is_deeply() for undef in left, nonexistent in right' )
+
+ test_fail()
+ is_deeply( right, left )
+ test_diag( 'Mismatch at [undef1]: expected (undef), received nonexistent' )
+ test_test( 'failing is_deeply() for undef in left, nonexistent in right' )
+
+ right['undef2'] = undef2
+ left['undef1'] = undef1
+
+ test_pass()
+ is_deeply( left, right )
+ test_test( 'passing is_deeply() with undef values' )
+
+ left['foo'] = undef1
+ test_fail()
+ is_deeply( left, right )
+ test_diag( 'Mismatch: expected 3 elements, received 2')
+ test_test( 'failing is_deeply() for hashes differing by keys with undef values' )
+
+.end
+
.sub test_is_deeply_mismatch
.end
More information about the parrot-commits
mailing list