]> gitweb.factorcode.org Git - factor.git/commitdiff
fix bug when a TYPED: word takes no inputs or gives no outputs
authorJoe Groff <arcata@gmail.com>
Sun, 25 Oct 2009 04:49:08 +0000 (23:49 -0500)
committerJoe Groff <arcata@gmail.com>
Sun, 25 Oct 2009 04:49:08 +0000 (23:49 -0500)
basis/typed/typed-tests.factor
basis/typed/typed.factor

index d8cbb814d8f9cf076118aad56bf63e18f07cfd45..f7b853cff796911ab36b3655984c3dc4f5cf3218 100644 (file)
@@ -1,4 +1,5 @@
-USING: accessors effects eval kernel layouts math quotations tools.test typed words ;
+USING: accessors effects eval kernel layouts math namespaces
+quotations tools.test typed words ;
 IN: typed.tests
 
 TYPED: f+ ( a: float b: float -- c: float )
@@ -71,3 +72,28 @@ IN: typed.tests
 T{ unboxable f 12 3 4.0 } unboxy xy>>
 """ eval( -- xy )
 ] unit-test
+
+TYPED: no-inputs ( -- out: integer )
+    1 ;
+
+[ 1 ] [ no-inputs ] unit-test
+
+TUPLE: unboxable3
+    { x read-only } ;
+
+TYPED: no-inputs-unboxable-output ( -- out: unboxable3 )
+    T{ unboxable3 } ;
+
+[ T{ unboxable3 } ] [ no-inputs-unboxable-output ] unit-test
+
+SYMBOL: buh
+
+TYPED: no-outputs ( x: integer -- )
+    buh set ;
+
+[ 2 ] [ 2 no-outputs buh get ] unit-test
+
+TYPED: no-outputs-unboxable-input ( x: unboxable3 -- )
+    buh set ;
+
+[ T{ unboxable3 } ] [ T{ unboxable3 } no-outputs-unboxable-input buh get ] unit-test
index 84a8ea3217353a2b04e39a5cefb220821b635b66..ec96902d727de909e6a84f0ec4ea53fa97b28bff 100644 (file)
@@ -79,7 +79,8 @@ DEFER: make-boxer
     [ drop [ ] ] if ;
 
 : make-boxer ( types -- quot )
-    [ boxer ] [ swap '[ @ _ dip ] ] map-reduce ;
+    [ [ ] ]
+    [ [ boxer ] [ swap '[ @ _ dip ] ] map-reduce ] if-empty ;
 
 ! defining typed words