[svn:parrot] r40127 - trunk/t/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Jul 16 22:53:37 UTC 2009
Author: bacek
Date: Thu Jul 16 22:53:36 2009
New Revision: 40127
URL: https://trac.parrot.org/parrot/changeset/40127
Log:
[cage] Add tests for Hash.elements
Modified:
trunk/t/pmc/hash.t
Modified: trunk/t/pmc/hash.t
==============================================================================
--- trunk/t/pmc/hash.t Thu Jul 16 22:07:32 2009 (r40126)
+++ trunk/t/pmc/hash.t Thu Jul 16 22:53:36 2009 (r40127)
@@ -23,7 +23,7 @@
.include 'except_types.pasm'
.include 'datatypes.pasm'
- plan(155)
+ plan(161)
initial_hash_tests()
more_than_one_hash()
@@ -70,6 +70,7 @@
integer_keys()
value_types_convertion()
+ elements_in_hash()
.end
.sub initial_hash_tests
@@ -1338,6 +1339,36 @@
# TODO Add tests for String.
.end
+# Check number of elements in Hash
+.sub 'elements_in_hash'
+ .local pmc hash
+ hash = new ['Hash']
+
+ $I0 = elements hash
+ is($I0, 0, "Empty hash has 0 items")
+
+ hash['foo'] = 'FOO'
+ $I0 = elements hash
+ is($I0, 1, "Hash has 1 item")
+
+ hash['foo'] = 'BAR'
+ $I0 = elements hash
+ is($I0, 1, "Hash still has 1 item after update")
+
+ hash['bar'] = 'BAR'
+ $I0 = elements hash
+ is($I0, 2, "Hash has 2 items")
+
+ delete hash['foo']
+ $I0 = elements hash
+ is($I0, 1, "Hash has 1 item after delete")
+
+ delete hash['bar']
+ $I0 = elements hash
+ is($I0, 0, "Hash has 0 items after delete")
+
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
More information about the parrot-commits
mailing list