1 USING: descriptive kernel math tools.test continuations prettyprint io.streams.string ;
\r
2 IN: descriptive.tests
\r
4 DESCRIPTIVE: divide ( num denom -- fraction ) / ;
\r
6 [ 3 ] [ 9 3 divide ] unit-test
\r
7 [ T{ descriptive-error f { { "num" 3 } { "denom" 0 } } "Division by zero" divide } ] [ [ 3 0 divide ] [ ] recover ] unit-test
\r
9 [ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE: divide ( num denom -- fraction ) / ;\n" ] [ \ divide [ see ] with-string-writer ] unit-test
\r
11 DESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;
\r
13 [ 3 ] [ 9 3 divide* ] unit-test
\r
14 [ T{ descriptive-error f { { "num" 3 } { "denom" 0 } } "Division by zero" divide* } ] [ [ 3 0 divide* ] [ ] recover ] unit-test
\r
16 [ "USING: descriptive math ;\nIN: descriptive.tests\nDESCRIPTIVE:: divide* ( num denom -- fraction ) num denom / ;\n" ] [ \ divide* [ see ] with-string-writer ] unit-test
\r