cvsuser 05/03/29 08:04:27
Modified: t/pmc namespace.t Log: two more namespace tests - retrieve current Revision Changes Path 1.5 +61 -2 parrot/t/pmc/namespace.t Index: namespace.t =================================================================== RCS file: /cvs/public/parrot/t/pmc/namespace.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- namespace.t 26 Mar 2005 12:07:30 -0000 1.4 +++ namespace.t 29 Mar 2005 16:04:26 -0000 1.5 @@ -1,6 +1,6 @@ #! perl -w # Copyright: 2001-2005 The Perl Foundation. All Rights Reserved. -# $Id: namespace.t,v 1.4 2005/03/26 12:07:30 leo Exp $ +# $Id: namespace.t,v 1.5 2005/03/29 16:04:26 leo Exp $ =head1 NAME @@ -16,7 +16,7 @@ =cut -use Parrot::Test tests => 12; +use Parrot::Test tests => 14; use Test::More; pir_output_is(<<'CODE', <<'OUTPUT', "find_global bar"); @@ -262,3 +262,62 @@ .*baz.*not found/ OUTPUT +pir_output_is(<<'CODE', <<'OUTPUT', "get namespace in Foo::bar"); +.sub main @MAIN + $P0 = find_global "Foo", "bar" + print "ok\n" + $P0() +.end + +.namespace ["Foo"] +.sub bar + print "bar\n" + .include "interpinfo.pasm" + $P0 = interpinfo .INTERPINFO_CURRENT_SUB + $P1 = $P0."get_name_space"() + print $P1 + print "\n" +.end +CODE +ok +bar +Foo +OUTPUT + +pir_output_is(<<'CODE', <<'OUTPUT', "get namespace in Foo::Bar::baz"); +.sub main @MAIN + $P0 = find_global "\0Foo" + $P1 = find_global $P0, "\0Bar" + $P2 = find_global $P1, "baz" + print "ok\n" + $P2() +.end + +.namespace ["Foo" ; "Bar"] +.sub baz + print "baz\n" + .include "interpinfo.pasm" + .include "pmctypes.pasm" + $P0 = interpinfo .INTERPINFO_CURRENT_SUB + $P1 = $P0."get_name_space"() + typeof $I0, $P1 + if $I0 == .Key goto is_key + print $P1 + print "\n" + .return() +is_key: + print $P1 + $P1 = shift $P1 + $I1 = defined $P1 + unless $I1 goto ex + print "::" + goto is_key +ex: + print "\n" +.end +CODE +ok +baz +Foo::Bar +OUTPUT +
