📄 tedsclosurebug.groovy
字号:
import groovy.xml.MarkupBuilder/** * @author Ted Leung * @version $Revision: 1.8 $ */class TedsClosureBug extends GroovyTestCase { void testBug() { def f = new Feed() f.author = new Person(name:'Ted Leung',url:'http://www.sauria.com/blog', email:'twl@sauria.com') f.entries = [ new Entry(title:'one',summary:'first post'), new Entry(title:'two',summary:'the second post'), new Entry(title:'three', summary:'post the third'), new Entry(title:'four',summary:'the ponderous fourth post') ] //f.entries.each { println it.title } //println f.author.name def xml = new MarkupBuilder() def atom = xml.atom() { title("Ted Leung off the air") link("http://www.sauria.com/noblog") author() { person() { name(f.author.name) url(f.author.url) email(f.author.email) } } for (e in f.entries) { entry() { /** @todo if use the non-existent title() method then a confusing exception is thrown */ title(e.title) summary(e.summary) } } } } }class Feed { String title String link Person author String tagline String generator String copyright String modified List entries}class Entry { String title String link String id String summary String content Person author String created String issued String modified}class Person { String name String url String email}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -