[svn:parrot] r47716 - trunk/t/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Sat Jun 19 18:03:25 UTC 2010
Author: NotFound
Date: Sat Jun 19 18:03:25 2010
New Revision: 47716
URL: https://trac.parrot.org/parrot/changeset/47716
Log:
some more tests for Hash PMC
Modified:
trunk/t/pmc/hash.t
Modified: trunk/t/pmc/hash.t
==============================================================================
--- trunk/t/pmc/hash.t Sat Jun 19 16:17:11 2010 (r47715)
+++ trunk/t/pmc/hash.t Sat Jun 19 18:03:25 2010 (r47716)
@@ -18,15 +18,18 @@
=cut
+.include 'except_types.pasm'
+.include 'datatypes.pasm'
+.include 'hash_key_type.pasm'
+
.sub main :main
.include 'test_more.pir'
- .include 'except_types.pasm'
- .include 'datatypes.pasm'
- plan(168)
+ plan(171)
initial_hash_tests()
more_than_one_hash()
+ hash_key_type()
null_key()
hash_keys_with_nulls_in_them()
nearly_the_same_hash_keys()
@@ -125,6 +128,32 @@
is( $I1, 2, 'two hashes: lookup Int from hash via Str in second' )
.end
+.sub hash_key_type
+ .local pmc h
+ .local int i
+ h = new ['Hash']
+ h = .Hash_key_type_int
+ h['01'] = 42
+ i = h[1]
+ is(i, 42, 'key type int')
+
+ # Use the method here to check it at the same time.
+ h.'set_key_type'(.Hash_key_type_STRING)
+ h[1] = 42
+ i = h['01']
+ isnt(i, 42, 'key type STRING')
+
+ push_eh invalid_type
+ h = -973 # Let's hope it will never become a valid type
+ pop_eh
+ ok(0, "Setting invalid type should throw")
+ goto end
+invalid_type:
+ pop_eh
+ ok(1, 'Setting invalid type throws')
+end:
+.end
+
.sub null_key
new $P0, ['Hash']
$P0['yum'] = 5
More information about the parrot-commits
mailing list