icanfly / expect4j

Automatically exported from code.google.com/p/expect4j
Apache License 2.0
0 stars 0 forks source link

Expect4j and Groovy #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'd like to make use of expect4j in Groovy scripts.  However Groovy does
not support inner classes and pretty much all the sample code I've found
make use of inner classes.  What is another way of implementing the
following Groovy code snippet without introducing helper classes?

        expect.expect(new Match[] {
            new RegExpMatch('.+$', new Closure() {
                public void run(ExpectState state) {
                    if (state.getMatch().trim().length() == 0) {
                        state.exp_continue()
                    } else {
                        println("Possible prompt: ${state.getMatch()}")
                    }
                }
            }), new TimeoutMatch(new Closure() {
                public void run(ExpectState state) {
                    println("Timed out waiting for an initial match")
                    state.addVar("timeout", Boolean.TRUE)
                }
            })
        })

Original issue reported on code.google.com by mjkah...@gmail.com on 11 Nov 2008 at 9:55

GoogleCodeExporter commented 9 years ago
I should add that the code above is basically Java code converted to Groovy but
keeping the inner class constructs that are not allowed by Groovy

Original comment by mjkah...@gmail.com on 11 Nov 2008 at 9:57

GoogleCodeExporter commented 9 years ago
Never mind I'm all set, I created new closure classes in Groovy to replace the 
inline
classes.

Original comment by mjkah...@gmail.com on 2 Dec 2008 at 12:10

GoogleCodeExporter commented 9 years ago

Original comment by travelin...@gmail.com on 25 Feb 2009 at 9:36

GoogleCodeExporter commented 9 years ago
mjkahlke, thanks for you comments.  When I wrote expect4j, I wasn't a groovy 
developer. Interestingly, I now am, but just haven't gone back to support 
groovy 
explicitely.  Using expect4j in java can get quite verbose, because of the lack 
of 
closures. Groovy would be a good fit, like tcl was. Could you explain a little 
bit 
about what you did and any ideas on how you'd like expect4j to work with groovy?

Original comment by travelin...@gmail.com on 25 Feb 2009 at 9:40