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

db4
Slava Pestov 2010-01-27 22:23:04 +13:00
parent ca19d44350
commit 0fa425b03a
2 changed files with 7 additions and 1 deletions

View File

@ -53,3 +53,9 @@ IN: combinators.smart.tests
{ 2 0 } [ [ + ] nullary ] must-infer-as { 2 0 } [ [ + ] nullary ] must-infer-as
{ 2 2 } [ [ [ + ] nullary ] preserving ] 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

View File

@ -50,4 +50,4 @@ MACRO: nullary ( quot -- quot' )
dup outputs '[ @ _ ndrop ] ; dup outputs '[ @ _ ndrop ] ;
MACRO: smart-if ( pred true false -- ) MACRO: smart-if ( pred true false -- )
'[ _ preserving _ _ if ] ; inline '[ _ preserving _ _ if ] ;