From e1b9e3485ae0f8524849902f5eed3473ca7a8183 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Tue, 24 Jun 2008 10:40:27 -0500 Subject: [PATCH] combinators.short-circuit: tests --- .../short-circuit/short-circuit-tests.factor | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 extra/combinators/short-circuit/short-circuit-tests.factor diff --git a/extra/combinators/short-circuit/short-circuit-tests.factor b/extra/combinators/short-circuit/short-circuit-tests.factor new file mode 100644 index 0000000000..e392d67d2a --- /dev/null +++ b/extra/combinators/short-circuit/short-circuit-tests.factor @@ -0,0 +1,32 @@ + +USING: kernel math tools.test combinators.short-circuit ; + +IN: combinators.short-circuit.tests + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: must-be-t ( in -- ) [ t ] swap unit-test ; +: must-be-f ( in -- ) [ f ] swap unit-test ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +[ { [ 1 ] [ 2 ] [ 3 ] } 0&& 3 = ] must-be-t +[ 3 { [ 0 > ] [ odd? ] [ 2 + ] } 1&& 5 = ] must-be-t +[ 10 20 { [ + 0 > ] [ - even? ] [ + ] } 2&& 30 = ] must-be-t + +[ { [ 1 ] [ f ] [ 3 ] } 0&& 3 = ] must-be-f +[ 3 { [ 0 > ] [ even? ] [ 2 + ] } 1&& ] must-be-f +[ 10 20 { [ + 0 > ] [ - odd? ] [ + ] } 2&& 30 = ] must-be-f + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +[ { [ 10 0 < ] [ f ] [ "factor" ] } 0|| "factor" = ] must-be-t + +[ 10 { [ odd? ] [ 100 > ] [ 1 + ] } 1|| 11 = ] must-be-t + +[ 10 20 { [ + odd? ] [ + 100 > ] [ + ] } 2|| 30 = ] must-be-t + +[ { [ 10 0 < ] [ f ] [ 0 1 = ] } 0|| ] must-be-f + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +