[svn:parrot] r40999 - trunk/t/pmc
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Sat Sep 5 13:57:42 UTC 2009
Author: whiteknight
Date: Sat Sep 5 13:57:39 2009
New Revision: 40999
URL: https://trac.parrot.org/parrot/changeset/40999
Log:
[t] convert 4 more test and refactor the test file again for more sanity
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 13:34:37 2009 (r40998)
+++ trunk/t/pmc/namespace-old.t Sat Sep 5 13:57:39 2009 (r40999)
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 61;
+use Parrot::Test tests => 56;
use Parrot::Config;
=head1 NAME
@@ -23,74 +23,6 @@
=cut
-pir_output_is( <<'CODE', <<'OUTPUT', "get_global Foo::bar hash" );
-.sub 'main' :main
-.end
-
-.namespace ["Foo"]
-.sub 'bar'
- print "bar\n"
-.end
-CODE
-ok
-bar
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "get_global Foo::Bar::baz" );
-.sub 'main' :main
- $P2 = get_global ["Foo";"Bar"], "baz"
- print "ok\n"
- $P2()
-.end
-
-.namespace ["Foo" ; "Bar"]
-.sub 'baz'
- print "baz\n"
-.end
-CODE
-ok
-baz
-OUTPUT
-
-pir_error_output_like( <<'CODE', <<'OUTPUT', "get_global Foo::bazz not found" );
-.sub 'main' :main
- $P2 = get_global ["Foo"], "bazz"
- $P2()
- print "ok\n"
-.end
-CODE
-/Null PMC access in invoke\(\)/
-OUTPUT
-
-# [this used to behave differently from the previous case.]
-pir_error_output_like( <<'CODE', <<'OUTPUT', "get_global Foo::Bar::bazz not found" );
-.sub 'main' :main
- $P2 = get_global ["Foo";"Bar"], "bazz"
- $P2()
- print "ok\n"
-.end
-CODE
-/Null PMC access in invoke\(\)/
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "get_global Foo::Bar::baz hash" );
-.sub 'main' :main
- $P0 = get_global "Foo"
- $P1 = $P0["Bar"]
- $P2 = $P1["baz"]
- print "ok\n"
- $P2()
-.end
-
-.namespace ["Foo"; "Bar"]
-.sub 'baz'
- print "baz\n"
-.end
-CODE
-ok
-baz
-OUTPUT
-
pir_output_is( <<'CODE', <<'OUTPUT', "get_global Foo::Bar::baz hash 2" );
.sub 'main' :main
$P0 = get_global "Foo"
Modified: trunk/t/pmc/namespace.t
==============================================================================
--- trunk/t/pmc/namespace.t Sat Sep 5 13:34:37 2009 (r40998)
+++ trunk/t/pmc/namespace.t Sat Sep 5 13:57:39 2009 (r40999)
@@ -18,7 +18,7 @@
.sub main :main
.include 'test_more.pir'
- plan(8)
+ plan(12)
create_namespace_pmc()
verify_namespace_type()
@@ -33,12 +33,9 @@
$P0 = new ['NameSpace']
pop_eh
ok(1, "Create new Namespace PMC")
- $I0 = does $P0, 'hash'
- ok($I0, "Namespace does hash")
goto _end
eh1:
ok(0, "Could not create Namespace PMC")
- ok(0, "NameSpace does not does hash")
_end:
.end
@@ -51,7 +48,7 @@
# L<PDD21//>
.sub 'get_global_opcode'
push_eh eh1
- $P0 = get_global "bar"
+ $P0 = get_global "baz"
$S0 = $P0()
pop_eh
is($S0, "", "Can get_global a .sub")
@@ -61,33 +58,72 @@
test2:
push_eh eh2
- $P0 = get_global ["Foo"], "bar"
+ $P0 = get_global ["Foo"], "baz"
$S0 = $P0()
pop_eh
is($S0, "Foo", "Get Sub from NameSpace")
- goto _end
+ goto test3
eh2:
- ok(0, "Cannot get Sub from NameSpace")
+ ok(0, "Cannot get Sub from NameSpace Foo")
+
+ test3:
+ push_eh eh3
+ $P0 = get_global ["Foo";"Bar"], "baz"
+ $S0 = $P0()
+ pop_eh
+ is($S0, "Foo::Bar", "Get Sub from nested NameSpace")
+ goto test4
+ eh3:
+ ok(0, "Cannot get Sub from NameSpace Foo::Bar")
+
+ test4:
+ push_eh eh4
+ $P0 = get_global ["Foo"], "SUB_THAT_DOES_NOT_EXIST"
+ $P0()
+ ok(0, "Found and invoked a non-existant sub")
+ goto test5
+ eh4:
+ # Should we check the exact error message here?
+ ok(1, "Cannot invoke a Sub that doesn't exist")
+
+ test5:
+ # this used to behave differently from the previous case.
+ push_eh eh5
+ $P0 = get_global ["Foo";"Bar"], "SUB_THAT_DOES_NOT_EXIST"
+ $P0()
+ ok(0, "Found and invoked a non-existant sub")
+ goto _end
+ eh5:
+ # Should we check the exact error message here?
+ ok(1, "Cannot invoke a Sub that doesn't exist")
_end:
.end
.sub 'get_sub_from_namespace_hash'
$P0 = get_global "Foo"
- $P1 = $P0["bar"]
+ $I0 = does $P0, 'hash'
+ ok($I0, "Namespace does hash")
+
+ $P1 = $P0["baz"]
$S0 = $P1()
is($S0, "Foo", "Get the Sub from the NameSpace as a Hash")
+
+ $P1 = $P0["Bar"]
+ $P2 = $P1["baz"]
+ $S0 = $P2()
+ is($S0, "Foo::Bar", "Get the Sub from the nested NameSpace as a Hash")
.end
.sub 'get_namespace_from_sub'
- $P0 = get_global ["Foo"], "bar"
+ $P0 = get_global "baz"
$P1 = $P0."get_namespace"()
$S0 = $P1
- is($S0, "Foo", "Get the namespace from a Sub in the NameSpace")
+ is($S0, "parrot", "Get the root namespace from a sub in the root namespace")
- $P0 = get_global "bar"
+ $P0 = get_global ["Foo"], "baz"
$P1 = $P0."get_namespace"()
$S0 = $P1
- is($S0, "parrot", "Get the root namespace from a sub in the root namespace")
+ is($S0, "Foo", "Get the namespace from a Sub in the NameSpace")
.end
@@ -96,11 +132,16 @@
.namespace []
-.sub 'bar'
+.sub 'baz'
.return("")
.end
.namespace ["Foo"]
-.sub 'bar'
+.sub 'baz'
.return("Foo")
.end
+
+.namespace ["Foo";"Bar"]
+.sub 'baz'
+ .return("Foo::Bar")
+.end
More information about the parrot-commits
mailing list