Skip to content

Commit

Permalink
more test for Exporter PMC
Browse files Browse the repository at this point in the history
  • Loading branch information
NotFound committed Dec 22, 2010
1 parent 8e59a00 commit a0cf037
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion t/pmc/exporter.t
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 12;
use Parrot::Test tests => 14;

=head1 NAME
Expand Down Expand Up @@ -153,6 +153,27 @@ ok 4 - destination() with too many args fails
ok 5 - destination() with non-namespace arg throws exception
OUT

pir_output_is( <<'CODE', <<'OUT', 'globals - invalid' );
.include 'except_types.pasm'
.sub 'test' :main
$P0 = new ['Exporter']
$P1 = new ['Undef']
push_eh catch
$P2 = $P0.'globals'($P1)
say 'not thrown'
goto end
catch:
.get_results($P3)
$I0 = $P3['type']
$I1 = iseq $I0, .EXCEPTION_INVALID_OPERATION
print 'Exception type is as expected: '
say $I1
end:
.end
CODE
Exception type is as expected: 1
OUT

pir_output_is( <<'CODE', <<'OUT', 'globals' );
.sub 'test' :main
$P0 = new ['Exporter']
Expand Down Expand Up @@ -236,6 +257,14 @@ pir_output_is( <<'CODE', <<'OUT', 'globals' );
ok_6:
say 'ok 6 - globals() with too many args fails'
null $P99
$P0.'globals'($P99)
$P1 = $P0.'globals'()
$I0 = isnull $P1
mul $I0, 7
print 'ok '
print $I0
say ' - globals() with null arg sets null'
.end
CODE
ok 1 - globals() returns PMCNULL upon Exporter init
Expand All @@ -244,6 +273,7 @@ ok 3 - globals() with array arg sets globals hash (hash with two keys)
ok 4 - globals() with empty hash arg sets PMCNULL
ok 5 - globals() with hash arg sets globals hash (hash with two keys)
ok 6 - globals() with too many args fails
ok 7 - globals() with null arg sets null
OUT

pir_error_output_like( <<'CODE', <<'OUT', 'import - no args' );
Expand All @@ -258,6 +288,28 @@ CODE
/^source namespace not set\n/
OUT

pir_output_is( <<'CODE', <<'OUT', 'import - null destination' );
.include 'except_types.pasm'
.sub 'test' :main
$P0 = new ['Exporter']
$P1 = get_namespace
null $P2
push_eh catch
$P0.'import'($P1, $P2)
say 'not thrown'
goto end
catch:
.get_results($P3)
$I0 = $P3['type']
$I1 = iseq $I0, .EXCEPTION_INVALID_OPERATION
print 'Exception type is as expected: '
say $I1
end:
.end
CODE
Exception type is as expected: 1
OUT

pir_output_is( <<'CODE', <<'OUT', 'import - same source and destination namespaces' );
.sub 'test' :main
.local pmc exporter, src
Expand Down

0 comments on commit a0cf037

Please sign in to comment.