Hi,

To simplify initialization of my production Money object in tests I've written 
an extension module to use explicit coercion:

> Money tenDolars = 10.0 as Money       //works fine, but could be shorter

It works fine, but it's Groovy so I would like to achieve more :).

My idea is to be able to write:

> Money tenDolars = 10.0        //desired construction

I was thinking about AST transformation (global or annotation based) to modify 
assignments like those (with Money on the left side and BigDecimal on the 
right) in a given class (or globally in a test context) to add explicit 
coercion automatically.

Unfortunately, usually AST transformations I've found deal with adding methods 
or statements in a method.


Could you point a Groovy build-in transformation or a place in Groovy code 
which deals with implicit coercion?


Marcin

-- 
http://blog.solidsoft.info/ - Working code is not enough



Reply via email to