develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35826 - trunk/t/oo

From:
jonathan
Date:
January 20, 2009 10:11
Subject:
[svn:parrot] r35826 - trunk/t/oo
Message ID:
20090120181123.B561CCB9AE@x12.develooper.com
Author: jonathan
Date: Tue Jan 20 10:11:22 2009
New Revision: 35826

Modified:
   trunk/t/oo/composition.t

Log:
[t] Tests for composition with multis.

Modified: trunk/t/oo/composition.t
==============================================================================
--- trunk/t/oo/composition.t	(original)
+++ trunk/t/oo/composition.t	Tue Jan 20 10:11:22 2009
@@ -19,7 +19,7 @@
 .sub main :main
     .include 'except_types.pasm'
     .include 'test_more.pir'
-    plan(41)
+    plan(45)
 
     role_with_no_methods()
     role_with_one_method_no_methods_in_class()
@@ -31,6 +31,7 @@
     conflict_resolution_by_resolve()
     role_that_does_a_role()
     conflict_from_indirect_role()
+    multi_composition()
 .end
 
 .sub badger :method
@@ -337,6 +338,31 @@
     nok($I0, 'second role conflicts with method from indirect role')
 .end
 
+.sub 'multi_composition'
+    .local pmc R, C
+    R = new 'Role'
+    $P0 = get_global 'mctest_2'
+    R.'add_method'("mctest", $P0)
+    C = new 'Class'
+    $P0 = get_global 'mctest_1'
+    C.'add_method'("mctest", $P0)
+    C.'add_role'(R)
+    ok(1, 'a multi in the class prevents a role conflict')
+
+    $P0 = inspect C, 'methods'
+    $I0 = elements $P0
+    is($I0, 1, 'class had still one method after composition')
+    $P0 = $P0['mctest']
+    $I0 = isa $P0, 'MultiSub'
+    is($I0, 1, 'method was a multi sub')
+    $I0 = elements $P0
+    is($I0, 2, 'multi holds both candidates')
+.end
+.sub 'mctest_1' :multi()
+.end
+.sub 'mctest_2'
+.end
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About