Paste: [PATCH] extras/roles/roles-test.factor

Author: mncharity
Mode: factor
Date: Mon, 12 Jul 2010 15:45:51
Plain Text |
Add a (currently failing) test of method overriding.

--- extra/roles/roles-tests.factor.orig	2010-07-08 19:39:57.000000000 -0400
+++ extra/roles/roles-tests.factor	2010-07-12 11:38:54.000000000 -0400
@@ -66,3 +66,19 @@
 
 [ "potato got poked" "potato got scooped" "potato got tuned" ]
 [ "potato" tuning-spork new [ poke ] [ scoop ] [ tune ] 2tri ] unit-test
+
+! test method overriding
+ROLE: Cx ;
+TUPLE: Ca ;
+TUPLE: Cb <{ Ca Cx } ;
+TUPLE: Cc <{ Cb } ;
+
+GENERIC: m1 ( a -- b )
+M: Ca m1 drop "sa" ;
+M: Cx m1 drop "sx" ;
+
+[ "sa" ] [ Ca new m1 ] unit-test
+[ "sx" ] [ Cb new m1 ] unit-test
+[ "sx" ] [ Cc new m1 ] unit-test
+: f1 ( -- o ) Cb new m1 ;
+[ "sx" ] [ f1 ] unit-test

New Annotation

Summary:
Author:
Mode:
Body: