On Wed, Jun 9, 2010 at 1:03 PM, Jim mack <j...@less2do.com> wrote:
> I'm writing unit-tests and I need to change the behavior of a word.   It's
> something I didn't write myself so it doesn't lend itself to generics.  What
> is the syntax for changing what executes?  Forth allows you to change the
> cfa or something (long time ago, blurry memory).  If I just redefine the
> word within the test, is there any danger something will use the prior
> version rather than my new definition?  I'm thinking of macros, but don't
> really know anything :)

The best way to do this is by making the API you want to mock generic,
either on an explicit object or as a set of hooks on a dynamic
variable. You can then wrap your unit tests in a with-variable form
that will ensure the variable is changed only within the extent of the
tests. If you need to mock an existing API that isn't generic you'll
need to wrap it. There's no facility to change non-generic words
safely.

-Joe

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to