~ubuntu-branches/ubuntu/lucid/groovy/lucid

« back to all changes in this revision

Viewing changes to src/test/groovy/bugs/Groovy1059_Bug.groovy

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath, Torsten Werner, Varun Hiremath
  • Date: 2009-04-01 19:24:19 UTC
  • mfrom: (3.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090401192419-c5mpylqhcdkv3zuv
Tags: 1.6.0-1
[ Torsten Werner ]
* New upstream release (Closes: #521648)
* Remove Build-Depends: libclassworlds-java.
* Switch to source and target version 1.5.

[ Varun Hiremath ]
* Fix build.xml file
* Add ivy to Build-Depends
* Remove unnecessary Depends -- collections3, mx4j and xpp3 
* Add build.diff patch to fix a build error
* Use quilt to manage patches
* Update manpage (Closes: #507862)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package groovy.bugs
2
 
 
3
 
/**
4
 
 * TODO: GROOVY-1059
5
 
 *
6
 
 *    Accessible to a closure attribute of an abject with the operator ".@".
7
 
 *    For examples, all of the expressions
8
 
 *
9
 
 *            object.@closure()
10
 
 *            object.@closure.call()
11
 
 *            object.@closure.doCall()
12
 
 *            (object.@closure)()
13
 
 *
14
 
 *    have the same meaning.
15
 
 *
16
 
 * @author  John Wilson
17
 
 * @author  Pilho Kim
18
 
 */
19
 
 
20
 
class Groovy1059_Bug extends GroovyTestCase {
21
 
 
22
 
    void testClosureAsAttribute() {
23
 
        def x = new Groovy1059Foo()
24
 
 
25
 
        println( x.say() )
26
 
        println( (x.@say)() )
27
 
        println( x.@say() )  // TODO: Groovy-1059 should work
28
 
        println( x.@say.call() )
29
 
        println( x.@say.doCall() )
30
 
        println( x.@say2() )
31
 
 
32
 
        assert "I am a Method" == x.say()
33
 
        assert "I am a Method" == x.@say2()
34
 
        assert "I am a Closure" == (x.@say)()
35
 
        assert "I am a Closure" == x.@say()
36
 
        assert x.@say() == (x.@say)()
37
 
        assert x.@say() == x.@say.call()
38
 
        assert x.@say() == x.@say.doCall()
39
 
        assert x.@say() != x.say()
40
 
        assert x.@say2() == x.say()
41
 
    }
42
 
 
43
 
}
44
 
 
45
 
class Groovy1059Foo {
46
 
 
47
 
    def public say = { it -> return "I am a Closure" }
48
 
    def public say2 = this.&say
49
 
 
50
 
    public Object say() {
51
 
       return "I am a Method"
52
 
    }
53
 
}
 
1
package groovy.bugs
 
2
 
 
3
/**
 
4
 * TODO: GROOVY-1059
 
5
 *
 
6
 *    Accessible to a closure attribute of an abject with the operator ".@".
 
7
 *    For examples, all of the expressions
 
8
 *
 
9
 *            object.@closure()
 
10
 *            object.@closure.call()
 
11
 *            object.@closure.doCall()
 
12
 *            (object.@closure)()
 
13
 *
 
14
 *    have the same meaning.
 
15
 *
 
16
 * @author  John Wilson
 
17
 * @author  Pilho Kim
 
18
 */
 
19
 
 
20
class Groovy1059_Bug extends GroovyTestCase {
 
21
 
 
22
    void testClosureAsAttribute() {
 
23
        def x = new Groovy1059Foo()
 
24
 
 
25
        println( x.say() )
 
26
        println( (x.@say)() )
 
27
        println( x.@say() )  // TODO: Groovy-1059 should work
 
28
        println( x.@say.call() )
 
29
        println( x.@say.doCall() )
 
30
        println( x.@say2() )
 
31
 
 
32
        assert "I am a Method" == x.say()
 
33
        assert "I am a Method" == x.@say2()
 
34
        assert "I am a Closure" == (x.@say)()
 
35
        assert "I am a Closure" == x.@say()
 
36
        assert x.@say() == (x.@say)()
 
37
        assert x.@say() == x.@say.call()
 
38
        assert x.@say() == x.@say.doCall()
 
39
        assert x.@say() != x.say()
 
40
        assert x.@say2() == x.say()
 
41
    }
 
42
 
 
43
}
 
44
 
 
45
class Groovy1059Foo {
 
46
 
 
47
    def public say = { it -> return "I am a Closure" }
 
48
    def public say2 = this.&say
 
49
 
 
50
    public Object say() {
 
51
       return "I am a Method"
 
52
    }
 
53
}