From 6035bb31308b8997dece7ac1002c3be1c3bc91d0 Mon Sep 17 00:00:00 2001 From: James Cash Date: Thu, 6 Nov 2008 00:44:25 -0500 Subject: [PATCH] Tests of around-advice --- extra/advice/advice-tests.factor | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/extra/advice/advice-tests.factor b/extra/advice/advice-tests.factor index 868f81cbe8..17b60c8fb1 100644 --- a/extra/advice/advice-tests.factor +++ b/extra/advice/advice-tests.factor @@ -1,22 +1,40 @@ ! Copyright (C) 2008 James Cash ! See http://factorcode.org/license.txt for BSD license. -USING: kernel sequences tools.test advice parser ; +USING: kernel sequences math tools.test advice parser namespaces ; IN: advice.tests [ : foo "foo" ; \ foo make-advised - { "bar" "foo" } [ + { "bar" "foo" } [ [ "bar" ] "barify" \ foo advise-before foo ] unit-test - { "bar" "foo" "baz" } [ + { "bar" "foo" "baz" } [ [ "baz" ] "bazify" \ foo advise-after foo ] unit-test - { "foo" "baz" } [ + { "foo" "baz" } [ "barify" \ foo before remove-advice foo ] unit-test - ] with-interactive-vocabs \ No newline at end of file +: bar ( a -- b ) 1+ ; +\ bar make-advised + + { 11 } [ + [ 2 * ] "double" \ bar advise-before + 5 bar + ] unit-test + + { 11/3 } [ + [ 3 / ] "third" \ bar advise-after + 5 bar + ] unit-test + + { -2 } [ + [ -1 * ad-do-it 3 + ] "frobnobicate" \ bar advise-around + 5 bar + ] unit-test + + ] with-scope \ No newline at end of file