Skip to content

Commit

Permalink
[t] Increase code coverage of Key PMC, a GCI task by David Czech
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Dec 27, 2010
1 parent 035b964 commit dbc7745
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions t/pmc/key.t
Expand Up @@ -18,14 +18,28 @@ Tests the C<Key> PMC.
.sub main :main
.include 'test_more.pir'

plan(12)
plan(15)

test_push_bad_args()
test_clone()
traverse_key_chain()
extract_int_from_string_keys()
extract_string_from_int_keys()
use_number_keys()
do_not_collect_string_keys_early_rt_60128()
'get_repr'()

.end

.sub test_push_bad_args
push_eh bad_push
new $P1, ['FileHandle']
new $P0, ['Key']
push $P0, $P1
pop_eh

bad_push:
ok( 1, 'Bad Arguments to push handled.')
.end

.sub traverse_key_chain
Expand Down Expand Up @@ -102,6 +116,24 @@ e2:
is(foo, "FOO", "set/get via number-valued Key works")
.end

.sub test_clone
.local pmc key
key = new ['Key']
key = 1.234

# Test cloning number keys.
clone $P0, key

# Test get_number
$N0 = $P0

is ($N0, "1.234", "cloning numeric keys works")

freeze $S0, $P0
thaw $P2, $S0
is ($P2, "1.234", "freeze/thaw numeric keys works")
.end


.sub do_not_collect_string_keys_early_rt_60128
.local pmc proc, a
Expand Down Expand Up @@ -189,15 +221,15 @@ code
# XXX PCC treats key arguments as special. Don't pass keys to subroutines.
# repr_is($P0, '[ S1 ]')
$S0 = get_repr $P0
is($S0, '[ S1 ]')
is($S0, '[ S1 ]', 'get_repr')
.end

.sub repr_is
.param pmc x
.param pmc repr
.include 'test_more.pir'
$S0 = get_repr x
is($S0, repr)
is($S0, repr, 'get_repr')
.end

# Local Variables:
Expand Down

0 comments on commit dbc7745

Please sign in to comment.