[svn:parrot] r43421 - in branches/tt389_fix/t: compilers/imcc/syn oo op pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Tue Jan 12 01:27:17 UTC 2010
Author: chromatic
Date: Tue Jan 12 01:27:16 2010
New Revision: 43421
URL: https://trac.parrot.org/parrot/changeset/43421
Log:
[t] Fixed tests which relied on the deprecated behavior of :methods accessible
through NameSpaces. See TT #389.
Modified:
branches/tt389_fix/t/compilers/imcc/syn/subflags.t
branches/tt389_fix/t/oo/composition.t
branches/tt389_fix/t/op/calling.t
branches/tt389_fix/t/pmc/class.t
branches/tt389_fix/t/pmc/context.t
branches/tt389_fix/t/pmc/pmcproxy.t
Modified: branches/tt389_fix/t/compilers/imcc/syn/subflags.t
==============================================================================
--- branches/tt389_fix/t/compilers/imcc/syn/subflags.t Mon Jan 11 02:44:39 2010 (r43420)
+++ branches/tt389_fix/t/compilers/imcc/syn/subflags.t Tue Jan 12 01:27:16 2010 (r43421)
@@ -1,5 +1,5 @@
#!./parrot
-# Copyright (C) 2001-2008, Parrot Foundation.
+# Copyright (C) 2001-2010, Parrot Foundation.
# $Id$
=head1 NAME
@@ -69,7 +69,7 @@
isa_ok($P30, 'Sub', ":method sub found w/.const")
$P0 = get_global 'method1'
$I0 = isnull $P0
- todo($I0, ":method sub not found in namespace")
+ ok($I0, ":method sub not found in namespace")
## :subid subs
.const 'Sub' $P40 = 'subid1'
@@ -89,7 +89,7 @@
ok($I0, "subid2 not found in namespace")
$P0 = get_global 'nsentry2'
$I0 = issame $P50, $P0
- ok($I0, "nsentry2 found in namespace")
+ nok($I0, "nsentry2 found in namespace")
$P0 = get_global 'method2'
$I0 = isnull $P0
ok($I0, "method2 not found in namespace")
Modified: branches/tt389_fix/t/oo/composition.t
==============================================================================
--- branches/tt389_fix/t/oo/composition.t Mon Jan 11 02:44:39 2010 (r43420)
+++ branches/tt389_fix/t/oo/composition.t Tue Jan 12 01:27:16 2010 (r43421)
@@ -1,5 +1,5 @@
#! parrot
-# Copyright (C) 2007, Parrot Foundation.
+# Copyright (C) 2007-2010, Parrot Foundation.
# $Id$
=head1 NAME
@@ -34,26 +34,36 @@
multi_composition()
.end
+.namespace [ 'Methods' ]
+
.sub badger :method
.return('Badger!')
.end
+
.sub badger2 :method
.return('Second Badger!')
.end
+
.sub mushroom :method
.return('Mushroom!')
.end
+
.sub snake :method
.return('Snake!')
.end
+
+.namespace []
+
.sub fire
.return("You're FIRED!")
.end
+
.sub fire2
.return('BURNINATION!')
.end
-.sub give_payrise
- .return('You all get a pay rise of 0.0005%.')
+
+.sub give_payraise
+ .return('You all get a pay raise of 0.0005%.')
.end
.sub role_with_no_methods
@@ -75,7 +85,11 @@
$P0 = new 'Role'
$P1 = new 'Class'
- $P2 = get_global "badger"
+ .local pmc mc, meths
+ mc = newclass [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P2 = meths['badger']
+
$P0.'add_method'("badger", $P2)
ok(1, 'added method to a role')
@@ -98,16 +112,20 @@
$P1 = new 'Role'
$P2 = new 'Class'
- $P3 = get_global "snake"
+ .local pmc mc, meths
+ mc = get_class [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P3 = meths['snake']
+
$P2.'add_method'("snake", $P3)
ok(1, 'class has a method')
- $P3 = get_global "badger"
+ $P3 = meths['badger']
$P0.'add_method'("badger", $P3)
$P2.'add_role'($P0)
ok(1, 'composed first role into the class')
- $P3 = get_global "mushroom"
+ $P3 = meths['mushroom']
$P1.'add_method'("mushroom", $P3)
$P2.'add_role'($P1)
ok(1, 'composed second role into the class')
@@ -131,12 +149,16 @@
$P1 = new 'Role'
$P2 = new 'Class'
- $P3 = get_global "badger"
+ .local pmc mc, meths
+ mc = get_class [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P3 = meths['badger']
+
$P0.'add_method'("badger", $P3)
$P2.'add_role'($P0)
ok(1, 'composed first role into the class')
- $P3 = get_global "badger2"
+ $P3 = meths['badger2']
$P1.'add_method'("badger", $P3)
try:
@@ -162,18 +184,22 @@
$P0 = new 'Role'
$P1 = new 'Class'
- $P2 = get_global "badger"
+ .local pmc mc, meths
+ mc = get_class [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P2 = meths['badger']
+
$P1.'add_method'("badger", $P2)
ok(1, 'class has a method')
- $P2 = get_global "badger2"
+ $P2 = meths['badger2']
$P0.'add_method'("badger", $P2)
try:
eh = new 'ExceptionHandler'
eh.'handle_types'(.EXCEPTION_ROLE_COMPOSITION_METHOD_CONFLICT)
set_addr eh, catch
-
+
push_eh eh
$P1.'add_role'($P0)
$I0 = 1
@@ -191,13 +217,17 @@
$P0 = new 'Role'
$P1 = new 'Class'
- $P2 = get_global "badger"
+ .local pmc mc, meths
+ mc = get_class [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P2 = meths['badger']
+
$P1.'add_method'("badger", $P2)
ok(1, 'class has a method')
- $P2 = get_global "badger2"
+ $P2 = meths['badger2']
$P0.'add_method'("badger", $P2)
- $P2 = get_global "snake"
+ $P2 = meths['snake']
$P0.'add_method'("snake", $P2)
$P3 = new 'ResizableStringArray'
push $P3, "badger"
@@ -216,13 +246,17 @@
$P0 = new 'Role'
$P1 = new 'Class'
- $P2 = get_global 'badger'
+ .local pmc mc, meths
+ mc = get_class [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P2 = meths['badger']
+
$P1.'add_method'('badger', $P2)
ok(1, 'class has a method')
- $P2 = get_global 'badger2'
+ $P2 = meths['badger2']
$P0.'add_method'('badger', $P2)
- $P2 = get_global 'snake'
+ $P2 = meths['snake']
$P0.'add_method'('snake', $P2)
$P3 = new 'Hash'
$P3['badger'] = 'role_badger'
@@ -255,13 +289,17 @@
$S0 = $P4[0]
is($S0, 'badger', 'got resolve list and it matched')
- $P2 = get_global 'badger'
+ .local pmc mc, meths
+ mc = get_class [ 'Methods' ]
+ meths = inspect mc, 'methods'
+ $P2 = meths['badger']
+
$P1.'add_method'('badger', $P2)
ok(1, 'class has a method')
- $P2 = get_global 'badger2'
+ $P2 = meths['badger2']
$P0.'add_method'('badger', $P2)
- $P2 = get_global 'snake'
+ $P2 = meths['snake']
$P0.'add_method'('snake', $P2)
$P1.'add_role'($P0)
ok(1, 'composition worked due to resolve')
@@ -282,8 +320,8 @@
FirePeople.'add_method'("fire", $P0)
Manage = new 'Role'
- $P0 = get_global 'give_payrise'
- Manage.'add_method'("give_payrise", $P0)
+ $P0 = get_global 'give_payraise'
+ Manage.'add_method'("give_payraise", $P0)
Manage.'add_role'(FirePeople)
ok(1, 'adding one role to another happens')
@@ -292,8 +330,8 @@
ok(1, 'added one rule that does another role to the class')
$P0 = PHB.'new'()
- $S0 = $P0.'give_payrise'()
- is($S0, 'You all get a pay rise of 0.0005%.', 'called method from direct role')
+ $S0 = $P0.'give_payraise'()
+ is($S0, 'You all get a pay raise of 0.0005%.', 'called method from direct role')
$S1 = $P0.'fire'()
is($S1, "You're FIRED!", 'called method from indirect role')
@@ -307,8 +345,8 @@
FirePeople.'add_method'('fire', $P0)
Manage = new 'Role'
- $P0 = get_global 'give_payrise'
- FirePeople.'add_method'('give_payrise', $P0)
+ $P0 = get_global 'give_payraise'
+ FirePeople.'add_method'('give_payraise', $P0)
Manage.'add_role'(FirePeople)
Burninator = new 'Role'
Modified: branches/tt389_fix/t/op/calling.t
==============================================================================
--- branches/tt389_fix/t/op/calling.t Mon Jan 11 02:44:39 2010 (r43420)
+++ branches/tt389_fix/t/op/calling.t Tue Jan 12 01:27:16 2010 (r43421)
@@ -1,5 +1,5 @@
#!perl
-# Copyright (C) 2001-2009, Parrot Foundation.
+# Copyright (C) 2001-2010, Parrot Foundation.
# $Id$
use strict;
@@ -982,27 +982,34 @@
.sub main :main
.local pmc cl, o, f
cl = newclass "Foo"
- o = new "Foo"
- o."bar"("ok 1\n")
- f = get_global ["Foo"], "bar"
- f(o, "ok 2\n")
- o."baz"("ok 3\n")
- f = get_global ["Foo"], "baz"
- f(o, "ok 4\n")
+ o = new "Foo"
+
+ o."bar"("ok 1")
+
+ f = find_method o, "bar"
+ f(o, "ok 2")
+
+ o."baz"("ok 3")
+ f = find_method o, "baz"
+ f(o, "ok 4")
.end
+
.namespace ["Foo"]
+
.sub bar :method
.param string s
print self
print " "
- print s
+ say s
.end
+
.sub baz :method
.param string s
print self
print " "
- print s
+ say s
.end
+
.sub get_string :vtable :method
$S0 = typeof self
.return ($S0)
Modified: branches/tt389_fix/t/pmc/class.t
==============================================================================
--- branches/tt389_fix/t/pmc/class.t Mon Jan 11 02:44:39 2010 (r43420)
+++ branches/tt389_fix/t/pmc/class.t Tue Jan 12 01:27:16 2010 (r43421)
@@ -1,5 +1,5 @@
#! parrot
-# Copyright (C) 2007-2008, Parrot Foundation.
+# Copyright (C) 2007-2010, Parrot Foundation.
# $Id$
=head1 NAME
@@ -17,13 +17,13 @@
=cut
-.const int TESTS = 63
+.const int TESTS = 63
.sub 'main' :main
load_bytecode 'Test/More.pbc'
.local pmc exporter, test_ns
- test_ns = get_namespace [ 'Test'; 'More' ]
+ test_ns = get_namespace [ 'Test'; 'More' ]
exporter = new ['Exporter']
exporter.'import'( test_ns :named('source'), 'plan ok is isa_ok todo' :named('globals') )
@@ -243,13 +243,13 @@
# note this test depends on 'add_attribute' and 'attributes'
class.'add_attribute'( 'foo', 'String' )
- attribs = class.'attributes'()
+ attribs = class.'attributes'()
attribs['foo'] = 'bar'
.const 'Sub' meth_to_add = 'foo'
class.'add_method'( 'foo', meth_to_add )
- attribs = class.'methods'()
+ attribs = class.'methods'()
test_val = attribs
is(test_val, 1, 'add_method() one method added')
@@ -362,9 +362,9 @@
.local string test_name
.local int test_val
- attrs = new ['Hash']
+ attrs = new ['Hash']
attrs['name'] = 'Monkey'
- class = new ['Class'], attrs
+ class = new ['Class'], attrs
class.'add_attribute'('banana')
class_instance = class.'new'()
ok(1, 'clone() created class Monkey and instantiated it')
@@ -393,8 +393,8 @@
.local string test_string_val
.local int num_elems
- class = new ['Hash']
- class['name'] = 'Monkey2'
+ class = new ['Hash']
+ class['name'] = 'Monkey2'
class_instance = new ['Class'], class
class_instance.'add_attribute'('banana')
monkey = class_instance.'new'()
@@ -426,16 +426,20 @@
.local pmc attr_val, result
init_hash = new ['Hash']
+ # grab the methods from the 'Add' namespace
+ .local pmc add_class
+ add_class = newclass [ 'Add' ]
+
+ .local pmc methods
+ methods = inspect add_class, 'methods'
+
# We'll have some attributes...
- attrs = new ['ResizablePMCArray']
- attrs[0] = 'x'
- attrs[1] = 'y'
+ attrs = new ['ResizablePMCArray']
+ attrs[0] = 'x'
+ attrs[1] = 'y'
init_hash['attributes'] = attrs
# And a method.
- methods = new ['Hash']
- meth_to_add = get_global 'add'
- methods['add'] = meth_to_add
init_hash['methods'] = methods
class = new ['Class'], init_hash
@@ -443,8 +447,9 @@
# Instantiate and try setting each attribute.
class_instance = class.'new'()
- attr_val = new ['Integer']
- attr_val = 37
+ attr_val = new ['Integer']
+ attr_val = 37
+
setattribute class_instance, 'x', attr_val
ok(1, 'new() set first attribute')
@@ -458,7 +463,9 @@
is(result, 42, 'new() added method returns expected value')
.end
-.sub add :method
+.namespace [ 'Add' ]
+
+.sub 'add' :method
$P0 = getattribute self, "x"
$P1 = getattribute self, "y"
$P2 = new ['Integer']
@@ -466,6 +473,7 @@
.return($P2)
.end
+.namespace []
# L<PDD15/Class PMC API/=item isa>
.sub 'isa'
Modified: branches/tt389_fix/t/pmc/context.t
==============================================================================
--- branches/tt389_fix/t/pmc/context.t Mon Jan 11 02:44:39 2010 (r43420)
+++ branches/tt389_fix/t/pmc/context.t Tue Jan 12 01:27:16 2010 (r43421)
@@ -1,5 +1,5 @@
#! parrot
-# Copyright (C) 2009, Parrot Foundation.
+# Copyright (C) 2009-2010, Parrot Foundation.
# $Id$
=head1 NAME
@@ -94,8 +94,8 @@
$P0 = getattribute ctx, 'current_namespace'
ok($P0, 'Got CallContext.current_namespace')
- $P1 = $P0['test_inspect']
- is($P1, 'test_inspect', '... with proper content')
+
+ is($P0, 'Foo', '... with proper content')
# Checking handlers
push_eh done
Modified: branches/tt389_fix/t/pmc/pmcproxy.t
==============================================================================
--- branches/tt389_fix/t/pmc/pmcproxy.t Mon Jan 11 02:44:39 2010 (r43420)
+++ branches/tt389_fix/t/pmc/pmcproxy.t Tue Jan 12 01:27:16 2010 (r43421)
@@ -1,5 +1,5 @@
#! parrot
-# Copyright (C) 2007-2008, Parrot Foundation.
+# Copyright (C) 2007-2010, Parrot Foundation.
# $Id$
=head1 NAME
@@ -178,8 +178,11 @@
addparent $P0, $P1
ok(1, "added Class's PMCProxy as a parent of the PDD15 class")
- #We will override the inspect_str vtable method.
- $P2 = get_global 'always42'
+ # We will override the inspect_str vtable method.
+ .local pmc a42, methods
+ a42 = newclass [ 'A42' ]
+ methods = inspect a42, 'methods'
+ $P2 = methods['always42']
$P0.'add_vtable_override'('inspect_str', $P2)
ok(1, 'overrode inspect_str method')
@@ -190,6 +193,9 @@
is($P3, 42, "the magic overriding sub was called")
ok(1, 'Called non-overridden method, which called overridden vtable method')
.end
+
+.namespace [ 'A42' ]
+
.sub always42 :method
.param string what
$P0 = new ['Integer']
@@ -197,6 +203,7 @@
.return($P0)
.end
+.namespace []
.sub get_class_and_typeof_return_same_pmcproxy
$P0 = get_class 'Integer'
More information about the parrot-commits
mailing list