[ 
https://issues.apache.org/jira/browse/GROOVY-4808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14996530#comment-14996530
 ] 

Jason Winnebeck commented on GROOVY-4808:
-----------------------------------------

I was wondering how to do this myself. Requiring the parens would be a little 
annoying since the point of command chains is to eliminate extra parens and 
dots, but not a "deal breaker". That said though I think allowing command 
chains in parens would be a great idea in a general case because I've wanted to 
use command chains inside of statements, plus I can see how it would be useful 
even within another command chain in the same way Richard showed (I can see how 
it would apply even outside of assert), and parens make sense in natural 
language. I also would say that when the assert did not work for me I did try 
putting into parens to see if that would work, so I think it's an intuitive 
workaround a developer would try in this case.

> Command Chain + Power Assert doesn't work
> -----------------------------------------
>
>                 Key: GROOVY-4808
>                 URL: https://issues.apache.org/jira/browse/GROOVY-4808
>             Project: Groovy
>          Issue Type: Improvement
>          Components: syntax
>    Affects Versions: 1.8.0
>            Reporter: Richard Allwood
>
> Command Chaining cannot be used in conjunction with Power Asserts:
> {code}
> class Driver {
>     static EnterInto enter(text) {
>         new EnterInto(text: text)
>     }
> }
> class EnterInto {
>     def text
>     
>     def into(field) {
>         println "enter $text into $field"
>         text
>     }
> }
> import static Driver.*
> assert "1234" == enter("1234").into("field1") 
> def value = enter "5678" into "field2"
> assert "5678" == value
> //assert "9012" == enter "9012" into "field3"
> {code}
> if the last assert is uncommented then a compilation error occurs.
> You can work around this problem by assigning the value to a temporary value 
> and using the power asset on that value, but this means that you loose the 
> breakdown from the power assert showing why the assert failed:
> {code}
> assert "1234" == enter("2345").into("field1")
>               |  |             |
>               |  |             2345
>               |  EnterInto@882dfc
>               false
> {code} 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to