From 0fa425b03a7564fc0b55a039d02d48c1abbb56b2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 27 Jan 2010 22:23:04 +1300 Subject: [PATCH] combinators.smart: smart-if was declared inline, and had no unit tests, and so was broken. This was not caught until inline macros became a parse error. Add unit tests for it --- basis/combinators/smart/smart-tests.factor | 6 ++++++ basis/combinators/smart/smart.factor | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/combinators/smart/smart-tests.factor b/basis/combinators/smart/smart-tests.factor index bd224919f9..afafd174d3 100644 --- a/basis/combinators/smart/smart-tests.factor +++ b/basis/combinators/smart/smart-tests.factor @@ -53,3 +53,9 @@ IN: combinators.smart.tests { 2 0 } [ [ + ] nullary ] must-infer-as { 2 2 } [ [ [ + ] nullary ] preserving ] must-infer-as + +: smart-if-test ( a b -- b ) + [ < ] [ swap - ] [ - ] smart-if ; + +[ 7 ] [ 10 3 smart-if-test ] unit-test +[ 16 ] [ 25 41 smart-if-test ] unit-test diff --git a/basis/combinators/smart/smart.factor b/basis/combinators/smart/smart.factor index cb1b309c86..05185fec2e 100644 --- a/basis/combinators/smart/smart.factor +++ b/basis/combinators/smart/smart.factor @@ -50,4 +50,4 @@ MACRO: nullary ( quot -- quot' ) dup outputs '[ @ _ ndrop ] ; MACRO: smart-if ( pred true false -- ) - '[ _ preserving _ _ if ] ; inline + '[ _ preserving _ _ if ] ;