[svn:parrot] r44100 - branches/tt_1449/t/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Wed Feb 17 18:02:14 UTC 2010


Author: whiteknight
Date: Wed Feb 17 18:02:13 2010
New Revision: 44100
URL: https://trac.parrot.org/parrot/changeset/44100

Log:
[TT #1449]add some basic tests for the new behavior

Modified:
   branches/tt_1449/t/pmc/namespace.t

Modified: branches/tt_1449/t/pmc/namespace.t
==============================================================================
--- branches/tt_1449/t/pmc/namespace.t	Wed Feb 17 17:51:18 2010	(r44099)
+++ branches/tt_1449/t/pmc/namespace.t	Wed Feb 17 18:02:13 2010	(r44100)
@@ -61,6 +61,7 @@
     create_namespace_pmc()
     verify_namespace_type()
     get_namespace_class()
+    keyed_namespace_lookup()
     get_global_opcode()
     get_sub_from_namespace_hash()
     access_sub_in_namespace()
@@ -167,6 +168,40 @@
 
 .end
 
+.sub keyed_namespace_lookup
+    # Tests to verify behavior of TT #1449
+    $P0 = get_root_namespace
+
+    # Keyed lookup
+    $P1 = $P0["parrot";"Foo";"Bar"]
+    $I0 = isnull $P1
+    is($I0, 0, "can lookup nested namespace by Key")
+    # TODO: Get the function from this namespace and call it to verify we have
+    #       the correct one.
+
+    # Array lookup
+    $P1 = new ['ResizableStringArray']
+    $P1[0] = "parrot"
+    $P1[1] = "Foo"
+    $P1[2] = "Bar"
+    $P1[3] = "Baz"
+    $P2 = $P0[$P1]
+    $I0 = isnull $P1
+    is($I0, 0, "can lookup nested namespace by RSA")
+    # TODO: Get the function from this namespace and call it to verify we have
+    #       the correct one.
+
+    # String lookup
+    $P1 = $P0["parrot"]
+    $P2 = $P1["Foo"]
+    $I0 = isnull $P1
+    is($I0, 0, "can lookup namespace by string")
+    $I0 = isnull $P2
+    is($I0, 0, "can lookup namespace by string")
+    # TODO: Get the function from this namespace and call it to verify we have
+    #       the correct one.
+.end
+
 # L<PDD21//>
 .sub 'get_global_opcode'
   test1:
@@ -486,7 +521,7 @@
 
     # ...now we do!
     $P1 = $P0.'make_namespace'("NewNamespace1")
-    $P2 = $P1["baz"]    
+    $P2 = $P1["baz"]
     $I0 = isnull $P2
     is($I0, 1, "make_namespace also creates new namespaces")
 
@@ -632,6 +667,12 @@
     .return("Foo::Bar")
 .end
 
+# Namespace "Foo";"Bar";"Baz". Nested namespace
+.namespace ["Foo";"Bar";"Baz"]
+.sub 'widget'
+    .return("Foo::Bar::Baz")
+.end
+
 # Namespace specified in ISO-8859-1
 .namespace [ iso-8859-1:"Fran\x{E7}ois" ]
 .sub 'baz'


More information about the parrot-commits mailing list