Author: mdiep
Date: Wed Mar 14 21:48:22 2007
New Revision: 17484

Modified:
   trunk/src/pmc/sub.pmc
   trunk/t/op/lexicals.t
   trunk/t/pmc/eval.t
   trunk/t/pmc/namespace.t
   trunk/t/pmc/object-meths.t
   trunk/t/pmc/sub.t

Log:
#41790: [PATCH] Change sub's get_string to return short name
 - Update the tests to expect the short name
 - Add a test for the get_namespace() method


Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc       (original)
+++ trunk/src/pmc/sub.pmc       Wed Mar 14 21:48:22 2007
@@ -120,7 +120,8 @@
 */
 
     STRING* get_string() {
-        return Parrot_full_sub_name(INTERP, SELF);
+        struct Parrot_sub * const sub = PMC_sub(SELF);
+        return Parrot_make_COW_reference(INTERP, sub->name);
     }
 
     void set_string_native(STRING *subname) {

Modified: trunk/t/op/lexicals.t
==============================================================================
--- trunk/t/op/lexicals.t       (original)
+++ trunk/t/op/lexicals.t       Wed Mar 14 21:48:22 2007
@@ -383,7 +383,7 @@
     print "\n"
 .end
 CODE
-parrot;main
+main
 OUTPUT
 
 pir_output_is( <<'CODE', <<'OUTPUT', 'get_outer 2' );
@@ -404,8 +404,8 @@
     print "\n"
 .end
 CODE
-parrot;foo
-parrot;main
+foo
+main
 OUTPUT
 
 pir_output_is( <<'CODE', <<'OUTPUT', 'get_outer via interp' );
@@ -444,10 +444,10 @@
     pad['a'] = $P0
 .end
 CODE
-parrot;foo
-parrot;foo
-parrot;main
-parrot;main
+foo
+foo
+main
+main
 I messed with your var
 OUTPUT
 

Modified: trunk/t/pmc/eval.t
==============================================================================
--- trunk/t/pmc/eval.t  (original)
+++ trunk/t/pmc/eval.t  Wed Mar 14 21:48:22 2007
@@ -469,10 +469,10 @@
     .local pmc e, s, compi
     code = <<"EOC"
     .sub foo
-    noop
+        noop
     .end
     .sub bar
-    noop
+        noop
     .end
 EOC
     compi = compreg "PIR"
@@ -485,8 +485,8 @@
     print "\n"
 .end
 CODE
-parrot;foo
-parrot;bar
+foo
+bar
 OUTPUT
 
 pir_output_is( <<'CODE', <<'OUTPUT', "catch compile err: RT:#39892" );

Modified: trunk/t/pmc/namespace.t
==============================================================================
--- trunk/t/pmc/namespace.t     (original)
+++ trunk/t/pmc/namespace.t     Wed Mar 14 21:48:22 2007
@@ -886,7 +886,7 @@
 CODE
 Found namespace: Foo
 Found nested namespace: Bar
-Found sub: parrot;Foo;Bar;a_sub
+Found sub: a_sub
 Found var: a string PMC
 OUTPUT
 

Modified: trunk/t/pmc/object-meths.t
==============================================================================
--- trunk/t/pmc/object-meths.t  (original)
+++ trunk/t/pmc/object-meths.t  Wed Mar 14 21:48:22 2007
@@ -868,7 +868,7 @@
 CODE
 main
 in meth
-parrot;Foo;meth
+meth
 back
 OUTPUT
 

Modified: trunk/t/pmc/sub.t
==============================================================================
--- trunk/t/pmc/sub.t   (original)
+++ trunk/t/pmc/sub.t   Wed Mar 14 21:48:22 2007
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 60;
+use Parrot::Test tests => 61;
 use Parrot::Config;
 
 =head1 NAME
@@ -828,9 +828,9 @@
     interpinfo P1, .INTERPINFO_CURRENT_CONT
     returncc
 CODE
-parrot;main
-parrot;the_sub
-parrot;main
+main
+the_sub
+main
 OUTPUT
 
 pasm_output_is( <<'CODE', <<'OUTPUT', "sub names w MAIN" );
@@ -855,9 +855,9 @@
     interpinfo P1, .INTERPINFO_CURRENT_CONT
     returncc
 CODE
-parrot;main
-parrot;the_sub
-parrot;main
+main
+the_sub
+main
 OUTPUT
 
 pir_output_is( <<'CODE', <<'OUTPUT', "caller introspection via interp" );
@@ -904,15 +904,15 @@
 CODE
 main foo
 Bar bar
-subname: parrot;Bar;bar
+subname: bar
 Bar foo
-caller 0 parrot;Bar;foo
-caller 1 parrot;Bar;bar
-caller 2 parrot;foo
-caller 3 parrot;main
+caller 0 foo
+caller 1 bar
+caller 2 foo
+caller 3 main
 Bar foo
-caller 0 parrot;Bar;foo
-caller 1 parrot;main
+caller 0 foo
+caller 1 main
 ok
 OUTPUT
 
@@ -1353,6 +1353,30 @@
 ok
 OUTPUT
 
+pir_output_is(<<'CODE', <<'OUTPUT', 'get_namespace()');
+.sub main :main
+    $P0 = get_global 'main'
+    $P0 = $P0.'get_namespace'()
+    $P0 = $P0.'get_name'()
+    $S0 = join ';', $P0
+    say $S0
+
+    $P0 = get_global ['Foo'; 'Bar'], 'foo'
+    $P0 = $P0.'get_namespace'()
+    $P0 = $P0.'get_name'()
+    $S0 = join ';', $P0
+    say $S0
+.end
+
+.namespace ['Foo'; 'Bar']
+.sub foo
+    noop
+.end
+CODE
+parrot
+parrot;Foo;Bar
+OUTPUT
+
 
 # Local Variables:
 #   mode: cperl

Reply via email to