[svn:parrot] r41007 - trunk/t/pmc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sat Sep 5 17:35:37 UTC 2009
Author: whiteknight
Date: Sat Sep 5 17:35:36 2009
New Revision: 41007
URL: https://trac.parrot.org/parrot/changeset/41007
Log:
[t] convert more tests to PIR, delete unnecessary tests, and add new HLL-related tests
Modified:
trunk/t/pmc/namespace-old.t
trunk/t/pmc/namespace.t
Modified: trunk/t/pmc/namespace-old.t
==============================================================================
--- trunk/t/pmc/namespace-old.t Sat Sep 5 17:31:25 2009 (r41006)
+++ trunk/t/pmc/namespace-old.t Sat Sep 5 17:35:36 2009 (r41007)
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 50;
+use Parrot::Test tests => 45;
use Parrot::Config;
=head1 NAME
@@ -68,119 +68,6 @@
unicode namespaces are fun
OUT
-pir_output_is( <<'CODE', <<'OUTPUT', "verify root and parrot namespaces" );
-# name may change though
-.sub main :main
- # root namespace
- $P0 = get_root_namespace
- typeof $S0, $P0
- print $S0
- print "\n"
- print $P0
- print "\n"
- # parrot namespace
- $P1 = $P0["parrot"]
- print $P1
- print "\n"
- typeof $S0, $P1
- print $S0
- print "\n"
-.end
-CODE
-NameSpace
-
-parrot
-NameSpace
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "ns.name()" );
-.sub main :main
- .include "interpinfo.pasm"
- $P0 = get_root_namespace
- $P1 = $P0["parrot"]
- $P3 = new ['NameSpace']
- $P1["Foo"] = $P3
- $P2 = $P3.'get_name'()
- $I2 = elements $P2
- print $I2
- print "\n"
- $S0 = join '::', $P2
- print $S0
- print "\n"
-.end
-CODE
-2
-parrot::Foo
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "get_namespace_p_p, getnamespace_p_kc" );
-.sub main :main
- .include "interpinfo.pasm"
- $P3 = new ['NameSpace']
- set_hll_global "Foo", $P3
- # fetch w array
- $P4 = new ['FixedStringArray']
- $P4 = 1
- $P4[0] = 'Foo'
- $P0 = get_hll_namespace $P4
- $P2 = $P0.'get_name'()
- $I2 = elements $P2
- print $I2
- print "\n"
- $S0 = join '::', $P2
- print $S0
- print "\n"
- # fetch w key
- $P2 = get_hll_namespace ["Foo"]
- $P2 = $P2.'get_name'()
- $I2 = elements $P2
- print $I2
- print "\n"
- $S0 = join '::', $P2
- print $S0
- print "\n"
-.end
-CODE
-2
-parrot::Foo
-2
-parrot::Foo
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "Sub.get_namespace, get_namespace" );
-.sub 'main' :main
- $P0 = get_global ["Foo"], "bar"
- print "ok\n"
- $P1 = $P0."get_namespace"()
- $P2 = $P1.'get_name'()
- $S0 = join '::', $P2
- print $S0
- print "\n"
- $P0()
-.end
-
-.namespace ["Foo"]
-.sub 'bar'
- $P1 = get_namespace
- print $P1
- print "\n"
-.end
-CODE
-ok
-parrot::Foo
-Foo
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "check parrot ns" );
-.sub 'main' :main
- $P0 = get_global ["String"], "lower"
- $S0 = $P0("OK\n")
- print $S0
-.end
-CODE
-ok
-OUTPUT
-
my $temp_a = "temp_a";
my $temp_b = "temp_b";
Modified: trunk/t/pmc/namespace.t
==============================================================================
--- trunk/t/pmc/namespace.t Sat Sep 5 17:31:25 2009 (r41006)
+++ trunk/t/pmc/namespace.t Sat Sep 5 17:35:36 2009 (r41007)
@@ -20,7 +20,7 @@
.sub main :main
.include 'test_more.pir'
- plan(23)
+ plan(30)
create_namespace_pmc()
verify_namespace_type()
@@ -28,6 +28,8 @@
get_sub_from_namespace_hash()
access_sub_in_namespace()
get_namespace_from_sub()
+ build_namespaces_at_runtime()
+ hll_namespaces()
.end
# L<PDD21/Namespace PMC API/=head4 Untyped Interface>
@@ -46,6 +48,20 @@
$P0 = get_global "Foo"
typeof $S0, $P0
is($S0, "NameSpace", "A NameSpace is a NameSpace")
+
+ # root namespace
+ $P0 = get_root_namespace
+ typeof $S0, $P0
+ is($S0, "NameSpace", "Root NameSpace is a NameSpace")
+
+ # parrot namespace
+ $P1 = $P0["parrot"]
+ typeof $S0, $P1
+ is($S0, "NameSpace", "::parrot NameSpace is a NameSpace")
+
+ $P0 = get_namespace
+ typeof $S0, $P1
+ is($S0, "NameSpace", "Current NameSpace is a NameSpace")
.end
# L<PDD21//>
@@ -114,10 +130,22 @@
$P0 = get_global [ "Foo";iso-8859-1:"François" ], "baz"
$S0 = $P0()
is($S0, iso-8859-1:"Foo::François", "Found sub in nested ISO-8859 NameSpace")
- goto _end
+ goto test8
eh7:
ok(0, "Cannot find sub in ISO-8859 NameSpace")
+ test8:
+# TODO: This should probably be possible. We should be able to look up a
+# string if it is iso-8895-1 and we are Unicode
+# push_eh eh8
+# $P0 = get_global [ unicode:"François" ], "baz"
+# $S0 = $P0()
+# say $S0
+# is($S0, iso-8859-1:"François", "ISO-8859 NameSpace with Unicode name")
+# goto _end
+# eh8:
+# ok(0, "Cannot find ISO-8859 NameSpace using Unicode name")
+
_end:
.end
@@ -206,6 +234,38 @@
is($S0, "Sub", "Get the current sub from namespace from current sub")
.end
+.sub 'build_namespaces_at_runtime'
+ $P0 = get_root_namespace
+ $P1 = $P0["parrot"]
+ $P3 = new ['NameSpace']
+ $P1["Temp1"] = $P3
+ $P2 = $P3.'get_name'()
+ $S0 = join '::', $P2
+ is($S0, "parrot::Temp1", "Add a NameSpace with a given name")
+.end
+
+.sub 'hll_namespaces'
+ # Fetch HLL Global using an RSA. Current HLL == parrot
+ $P4 = new ['FixedStringArray']
+ $P4 = 1
+ $P4[0] = 'Foo'
+ $P0 = get_hll_namespace $P4
+ $P2 = $P0.'get_name'()
+ $S0 = join '::', $P2
+ is($S0, "parrot::Foo", "get_hll_namespace_p")
+
+ # Get an HLL namespace using a key. Current HLL == parrot
+ $P2 = get_hll_namespace ["Foo"]
+ $P2 = $P2.'get_name'()
+ $S0 = join '::', $P2
+ is($S0, "parrot::Foo", "get_hll_namespace_kc")
+
+ # Get a sub from an HLL Namespace using a key. Current HLL == parrot
+ $P0 = get_hll_namespace ["Foo"]
+ $P1 = $P0["baz"]
+ $S0 = $P1()
+ is($S0, "Foo", "get a Sub from a HLL namespace")
+.end
##### TEST NAMESPACES AND FUNCTIONS #####
# These functions and namespaces are used for the tests above
More information about the parrot-commits
mailing list